@orbe-agro/client-core 5.6.337 → 5.6.338

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 (48) hide show
  1. package/dist/@ecme/assets/styles/app.css +13 -0
  2. package/dist/@ecme/assets/styles/tailwind/index.css +13 -0
  3. package/dist/@ecme/components/template/Footer.js +1 -1
  4. package/dist/@ecme/components/view/ChatBox/ChatBox.js +3 -1
  5. package/dist/@ecme/components/view/ChatBox/ChatBox.js.map +1 -1
  6. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +16 -14
  7. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
  8. package/dist/@ecme/index.js +2 -1
  9. package/dist/@ecme/services/AiService.js +13 -1
  10. package/dist/@ecme/services/AiService.js.map +1 -1
  11. package/dist/@ecme/services/index.js +2 -1
  12. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +11 -3
  13. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
  14. package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js +35 -0
  15. package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js.map +1 -0
  16. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js +14 -11
  17. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js.map +1 -1
  18. package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js +31 -0
  19. package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js.map +1 -0
  20. package/dist/@ecme/views/concepts/ai/Chat/imagens.js +57 -0
  21. package/dist/@ecme/views/concepts/ai/Chat/imagens.js.map +1 -0
  22. package/dist/@types/@ecme/components/view/ChatBox/ChatBox.d.ts.map +1 -1
  23. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +3 -0
  24. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
  25. package/dist/@types/@ecme/services/AiService.d.ts +12 -2
  26. package/dist/@types/@ecme/services/AiService.d.ts.map +1 -1
  27. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatView.d.ts.map +1 -1
  28. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts +13 -0
  29. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts.map +1 -0
  30. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts +1 -1
  31. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts.map +1 -1
  32. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts +16 -0
  33. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts.map +1 -0
  34. package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts +27 -0
  35. package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts.map +1 -0
  36. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts +38 -0
  37. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts.map +1 -1
  38. package/dist/base/assets/styles/init.css +13 -0
  39. package/lib/@ecme/components/view/ChatBox/ChatBox.tsx +2 -0
  40. package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +20 -14
  41. package/lib/@ecme/services/AiService.ts +27 -2
  42. package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +13 -3
  43. package/lib/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.tsx +54 -0
  44. package/lib/@ecme/views/concepts/ai/Chat/hooks/useChatSend.ts +33 -11
  45. package/lib/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.ts +53 -0
  46. package/lib/@ecme/views/concepts/ai/Chat/imagens.ts +86 -0
  47. package/lib/@ecme/views/concepts/ai/Chat/types.ts +42 -0
  48. package/package.json +1 -1
@@ -5756,6 +5756,9 @@ video {
5756
5756
  .w-4{
5757
5757
  width: 1rem;
5758
5758
  }
5759
+ .w-40{
5760
+ width: 10rem;
5761
+ }
5759
5762
  .w-5{
5760
5763
  width: 1.25rem;
5761
5764
  }
@@ -5938,6 +5941,9 @@ video {
5938
5941
  .max-w-\[200px\]{
5939
5942
  max-width: 200px;
5940
5943
  }
5944
+ .max-w-\[240px\]{
5945
+ max-width: 240px;
5946
+ }
5941
5947
  .max-w-\[250px\]{
5942
5948
  max-width: 250px;
5943
5949
  }
@@ -6823,6 +6829,9 @@ video {
6823
6829
  --tw-bg-opacity: 1;
6824
6830
  background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
6825
6831
  }
6832
+ .bg-white\/10{
6833
+ background-color: rgb(255 255 255 / 0.1);
6834
+ }
6826
6835
  .bg-yellow-200{
6827
6836
  --tw-bg-opacity: 1;
6828
6837
  background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));
@@ -6947,6 +6956,10 @@ video {
6947
6956
  .stroke-transparent{
6948
6957
  stroke: transparent;
6949
6958
  }
6959
+ .object-cover{
6960
+ -o-object-fit: cover;
6961
+ object-fit: cover;
6962
+ }
6950
6963
  .\!p-2\.5{
6951
6964
  padding: 0.625rem !important;
6952
6965
  }
@@ -1833,6 +1833,9 @@ video {
1833
1833
  .w-4 {
1834
1834
  width: 1rem;
1835
1835
  }
1836
+ .w-40 {
1837
+ width: 10rem;
1838
+ }
1836
1839
  .w-5 {
1837
1840
  width: 1.25rem;
1838
1841
  }
@@ -2015,6 +2018,9 @@ video {
2015
2018
  .max-w-\[200px\] {
2016
2019
  max-width: 200px;
2017
2020
  }
2021
+ .max-w-\[240px\] {
2022
+ max-width: 240px;
2023
+ }
2018
2024
  .max-w-\[250px\] {
2019
2025
  max-width: 250px;
2020
2026
  }
@@ -2902,6 +2908,9 @@ video {
2902
2908
  --tw-bg-opacity: 1;
2903
2909
  background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
2904
2910
  }
2911
+ .bg-white\/10 {
2912
+ background-color: rgb(255 255 255 / 0.1);
2913
+ }
2905
2914
  .bg-yellow-200 {
2906
2915
  --tw-bg-opacity: 1;
2907
2916
  background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));
@@ -3026,6 +3035,10 @@ video {
3026
3035
  .stroke-transparent {
3027
3036
  stroke: transparent;
3028
3037
  }
3038
+ .object-cover {
3039
+ -o-object-fit: cover;
3040
+ object-fit: cover;
3041
+ }
3029
3042
  .\!p-2\.5 {
3030
3043
  padding: 0.625rem !important;
3031
3044
  }
@@ -3,7 +3,7 @@ import Container from "../shared/Container.js";
3
3
  import classNames from "../../utils/classNames.js";
4
4
  import { APP_NAME } from "../../constants/app.constant.js";
5
5
  import { PAGE_CONTAINER_GUTTER_X } from "../../constants/theme.constant.js";
6
- const version = true ? "5.6.337" : "0.0.0";
6
+ const version = true ? "5.6.338" : "0.0.0";
7
7
  const FooterContent = () => {
8
8
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-auto items-center justify-between", children: [
9
9
  /* @__PURE__ */ jsxs("span", { children: [
@@ -12,6 +12,7 @@ const ChatBox = forwardRef((props, ref) => {
12
12
  placeholder,
13
13
  onInputChange,
14
14
  inputActions,
15
+ uploadProps,
15
16
  showAvatar,
16
17
  avatarGap,
17
18
  customRenderer,
@@ -35,7 +36,8 @@ const ChatBox = forwardRef((props, ref) => {
35
36
  {
36
37
  placeholder,
37
38
  onInputChange,
38
- inputActions
39
+ inputActions,
40
+ uploadProps
39
41
  }
40
42
  ),
41
43
  children: [
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBox.js","sources":["../../../../../lib/@ecme/components/view/ChatBox/ChatBox.tsx"],"sourcesContent":["import ChatContainer from './components/ChatContainer'\nimport MessageList from './components/MessageList'\nimport ChatInput from './components/ChatInput'\nimport type { MessageListProps } from './components/MessageList'\nimport type { ChatContainerProps } from './components/ChatContainer'\nimport type { ChatInputProps } from './components/ChatInput'\nimport type { ReactNode } from 'react'\nimport { forwardRef } from 'react'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\nexport type MessageList = MessageListProps['list']\n\nexport type ChatBoxProps = {\n messageList: MessageList\n header?: ChatContainerProps['header']\n showMessageList?: boolean\n children?: ReactNode\n containerClass?: string\n} & Omit<MessageListProps, 'list'> &\n ChatInputProps\n\nconst ChatBox = forwardRef<ScrollBarRef, ChatBoxProps>((props, ref) => {\n const {\n messageList,\n showMessageList = true,\n children,\n header,\n placeholder,\n onInputChange,\n inputActions,\n showAvatar,\n avatarGap,\n customRenderer,\n customAction,\n bubbleClass,\n myBubbleClass,\n botBubbleClass,\n errorBubbleClass,\n renderTyping,\n typing,\n messageListClass,\n containerClass,\n } = props\n\n return (\n <ChatContainer\n className={containerClass}\n header={header}\n input={\n <ChatInput\n placeholder={placeholder}\n onInputChange={onInputChange}\n inputActions={inputActions}\n />\n }\n >\n {showMessageList && (\n <MessageList\n ref={ref}\n list={messageList}\n showAvatar={showAvatar}\n avatarGap={avatarGap}\n customRenderer={customRenderer}\n customAction={customAction}\n typing={typing}\n messageListClass={messageListClass}\n bubbleClass={bubbleClass}\n myBubbleClass={myBubbleClass}\n botBubbleClass={botBubbleClass}\n errorBubbleClass={errorBubbleClass}\n renderTyping={renderTyping}\n /> )}\n {children}\n </ChatContainer>\n )\n})\n\nChatBox.displayName = 'ChatBox'\n\nexport default ChatBox\n"],"names":[],"mappings":";;;;;AAqBA,MAAM,UAAU,WAAuC,CAAC,OAAO,QAAQ;AACnE,QAAM;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA;AAEJ,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW;AAAA,MACX;AAAA,MACA,OACI;AAAA,QAAC;AAAA,QAAA;AAAA,UACG;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;AAAA,MAIP,UAAA;AAAA,QAAA,mBACG;AAAA,UAAC;AAAA,UAAA;AAAA,YACG;AAAA,YACA,MAAM;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEP;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb,CAAC;AAED,QAAQ,cAAc;"}
1
+ {"version":3,"file":"ChatBox.js","sources":["../../../../../lib/@ecme/components/view/ChatBox/ChatBox.tsx"],"sourcesContent":["import ChatContainer from './components/ChatContainer'\nimport MessageList from './components/MessageList'\nimport ChatInput from './components/ChatInput'\nimport type { MessageListProps } from './components/MessageList'\nimport type { ChatContainerProps } from './components/ChatContainer'\nimport type { ChatInputProps } from './components/ChatInput'\nimport type { ReactNode } from 'react'\nimport { forwardRef } from 'react'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\nexport type MessageList = MessageListProps['list']\n\nexport type ChatBoxProps = {\n messageList: MessageList\n header?: ChatContainerProps['header']\n showMessageList?: boolean\n children?: ReactNode\n containerClass?: string\n} & Omit<MessageListProps, 'list'> &\n ChatInputProps\n\nconst ChatBox = forwardRef<ScrollBarRef, ChatBoxProps>((props, ref) => {\n const {\n messageList,\n showMessageList = true,\n children,\n header,\n placeholder,\n onInputChange,\n inputActions,\n uploadProps,\n showAvatar,\n avatarGap,\n customRenderer,\n customAction,\n bubbleClass,\n myBubbleClass,\n botBubbleClass,\n errorBubbleClass,\n renderTyping,\n typing,\n messageListClass,\n containerClass,\n } = props\n\n return (\n <ChatContainer\n className={containerClass}\n header={header}\n input={\n <ChatInput\n placeholder={placeholder}\n onInputChange={onInputChange}\n inputActions={inputActions}\n uploadProps={uploadProps}\n />\n }\n >\n {showMessageList && (\n <MessageList\n ref={ref}\n list={messageList}\n showAvatar={showAvatar}\n avatarGap={avatarGap}\n customRenderer={customRenderer}\n customAction={customAction}\n typing={typing}\n messageListClass={messageListClass}\n bubbleClass={bubbleClass}\n myBubbleClass={myBubbleClass}\n botBubbleClass={botBubbleClass}\n errorBubbleClass={errorBubbleClass}\n renderTyping={renderTyping}\n /> )}\n {children}\n </ChatContainer>\n )\n})\n\nChatBox.displayName = 'ChatBox'\n\nexport default ChatBox\n"],"names":[],"mappings":";;;;;AAqBA,MAAM,UAAU,WAAuC,CAAC,OAAO,QAAQ;AACnE,QAAM;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACA;AAEJ,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW;AAAA,MACX;AAAA,MACA,OACI;AAAA,QAAC;AAAA,QAAA;AAAA,UACG;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;AAAA,MAIP,UAAA;AAAA,QAAA,mBACG;AAAA,UAAC;AAAA,UAAA;AAAA,YACG;AAAA,YACA,MAAM;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEP;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb,CAAC;AAED,QAAQ,cAAc;"}
@@ -9,7 +9,13 @@ import Button from "../../../ui/Button/Button.js";
9
9
  const { useMergeRef } = hooks;
10
10
  const ChatInput = (props) => {
11
11
  const [attachments, setAttachments] = useState([]);
12
- const { placeholder, onInputChange, ref = null, inputActions } = props;
12
+ const {
13
+ placeholder,
14
+ onInputChange,
15
+ ref = null,
16
+ inputActions,
17
+ uploadProps
18
+ } = props;
13
19
  const inputRef = useRef(null);
14
20
  const handleInputClear = () => {
15
21
  if (inputRef.current) {
@@ -17,22 +23,17 @@ const ChatInput = (props) => {
17
23
  }
18
24
  setAttachments([]);
19
25
  };
20
- const handleChange = () => {
21
- if (inputRef.current?.value) {
22
- onInputChange?.({
23
- value: inputRef.current?.value || "",
24
- attachments
25
- });
26
- handleInputClear();
26
+ const enviar = () => {
27
+ const value = inputRef.current?.value ?? "";
28
+ if (!value.trim() && attachments.length === 0) {
29
+ return;
27
30
  }
31
+ onInputChange?.({ value, attachments });
32
+ handleInputClear();
28
33
  };
29
34
  const handleKeyDown = (event) => {
30
35
  if (event.key === "Enter") {
31
- onInputChange?.({
32
- value: inputRef.current?.value || "",
33
- attachments
34
- });
35
- handleInputClear();
36
+ enviar();
36
37
  }
37
38
  };
38
39
  return /* @__PURE__ */ jsxs("div", { className: "border-2 border-gray-200 dark:border-gray-700 rounded-xl min-h-[50px] px-3 flex flex-col", children: [
@@ -50,6 +51,7 @@ const ChatInput = (props) => {
50
51
  /* @__PURE__ */ jsx(
51
52
  Upload,
52
53
  {
54
+ ...uploadProps,
53
55
  fileList: attachments,
54
56
  showList: false,
55
57
  onChange: setAttachments,
@@ -80,7 +82,7 @@ const ChatInput = (props) => {
80
82
  shape: "circle",
81
83
  variant: "solid",
82
84
  icon: /* @__PURE__ */ jsx(TbArrowRight, {}),
83
- onClick: handleChange
85
+ onClick: enviar
84
86
  }
85
87
  )
86
88
  ] })
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.js","sources":["../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"sourcesContent":["import { useState, useRef } from 'react'\nimport Button from '@/components/ui/Button'\nimport Upload from '@/components/ui/Upload'\nimport hooks from '@/components/ui/hooks'\nimport { TbPhotoPlus, TbArrowRight } from 'react-icons/tb'\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\n\nexport type ChatInputProps = {\n placeholder?: string\n onInputChange?: (payload: { value: string; attachments: File[] }) => void\n ref?: Ref<HTMLInputElement>\n /** Controles extras dentro da caixa, logo antes do botão de enviar. */\n inputActions?: ReactNode\n}\n\nconst { useMergeRef } = hooks\n\nconst ChatInput = (props: ChatInputProps) => {\n const [attachments, setAttachments] = useState<File[]>([])\n\n const { placeholder, onInputChange, ref = null, inputActions } = props\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const handleInputClear = () => {\n if (inputRef.current) {\n inputRef.current.value = ''\n }\n setAttachments([])\n }\n\n const handleChange = () => {\n if (inputRef.current?.value) {\n onInputChange?.({\n value: inputRef.current?.value || '',\n attachments,\n })\n handleInputClear()\n }\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n onInputChange?.({\n value: inputRef.current?.value || '',\n attachments,\n })\n handleInputClear()\n }\n }\n\n return (\n <div className=\"border-2 border-gray-200 dark:border-gray-700 rounded-xl min-h-[50px] px-3 flex flex-col\">\n {attachments.length > 0 && (\n <Upload\n fileList={attachments}\n fileListClass=\"flex gap-4\"\n fileItemClass=\"flex gap-8\"\n onFileRemove={setAttachments}\n >\n <></>\n </Upload>\n )}\n <div className=\"flex items-center gap-2 w-full h-[50px]\">\n <Upload\n fileList={attachments}\n showList={false}\n onChange={setAttachments}\n >\n <button\n className=\"text-xl heading-text hover:text-primary px-1 py-2\"\n type=\"button\"\n >\n <TbPhotoPlus />\n </button>\n </Upload>\n <input\n ref={useMergeRef(inputRef, ref)}\n className=\"flex-1 h-full placeholder:text-gray-400 bg-transparent focus:outline-none heading-text\"\n placeholder={placeholder}\n onKeyDown={handleKeyDown}\n />\n {inputActions}\n <Button\n size=\"xs\"\n shape=\"circle\"\n variant=\"solid\"\n icon={<TbArrowRight />}\n onClick={handleChange}\n />\n </div>\n </div>\n )\n}\n\nexport default ChatInput\n"],"names":[],"mappings":";;;;;;;;A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AC;AAAA,QAAA;AAAA,UACG,KAAK,YAAY,UAAU,GAAG;AAAA,UAC9B,WAAU;AAAA,UACV;AAAA,UACA,WAAW;AAAA,QAAA;AAAA,MAAA;AAAA,MAEd;AAAA,MACD;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,MAAK;AAAA,UACL,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,0BAAO,cAAA,EAAa;AAAA,UACpB,SAAS;AAAA,QAAA;AAAA,MAAA;AAAA,IACb,EAAA,CACJ;AAAA,EAAA,GACJ;AAER;"}
1
+ {"version":3,"file":"ChatInput.js","sources":["../../../../../../lib/@ecme/components/view/ChatBox/components/ChatInput.tsx"],"sourcesContent":["import { useState, useRef } from 'react'\nimport Button from '@/components/ui/Button'\nimport Upload from '@/components/ui/Upload'\nimport hooks from '@/components/ui/hooks'\nimport { TbPhotoPlus, TbArrowRight } from 'react-icons/tb'\nimport type { UploadProps } from '@/components/ui/Upload'\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\n\nexport type ChatInputProps = {\n placeholder?: string\n onInputChange?: (payload: { value: string; attachments: File[] }) => void\n ref?: Ref<HTMLInputElement>\n /** Controles extras dentro da caixa, logo antes do botão de enviar. */\n inputActions?: ReactNode\n /** Restrições do seletor de anexos (tipos aceitos e validação). */\n uploadProps?: Pick<UploadProps, 'accept' | 'beforeUpload'>\n}\n\nconst { useMergeRef } = hooks\n\nconst ChatInput = (props: ChatInputProps) => {\n const [attachments, setAttachments] = useState<File[]>([])\n\n const {\n placeholder,\n onInputChange,\n ref = null,\n inputActions,\n uploadProps,\n } = props\n\n const inputRef = useRef<HTMLInputElement>(null)\n\n const handleInputClear = () => {\n if (inputRef.current) {\n inputRef.current.value = ''\n }\n setAttachments([])\n }\n\n /** Envia texto, anexos ou os dois; com a caixa vazia não faz nada. */\n const enviar = () => {\n const value = inputRef.current?.value ?? ''\n if (!value.trim() && attachments.length === 0) {\n return\n }\n onInputChange?.({ value, attachments })\n handleInputClear()\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n enviar()\n }\n }\n\n return (\n <div className=\"border-2 border-gray-200 dark:border-gray-700 rounded-xl min-h-[50px] px-3 flex flex-col\">\n {attachments.length > 0 && (\n <Upload\n fileList={attachments}\n fileListClass=\"flex gap-4\"\n fileItemClass=\"flex gap-8\"\n onFileRemove={setAttachments}\n >\n <></>\n </Upload>\n )}\n <div className=\"flex items-center gap-2 w-full h-[50px]\">\n <Upload\n {...uploadProps}\n fileList={attachments}\n showList={false}\n onChange={setAttachments}\n >\n <button\n className=\"text-xl heading-text hover:text-primary px-1 py-2\"\n type=\"button\"\n >\n <TbPhotoPlus />\n </button>\n </Upload>\n <input\n ref={useMergeRef(inputRef, ref)}\n className=\"flex-1 h-full placeholder:text-gray-400 bg-transparent focus:outline-none heading-text\"\n placeholder={placeholder}\n onKeyDown={handleKeyDown}\n />\n {inputActions}\n <Button\n size=\"xs\"\n shape=\"circle\"\n variant=\"solid\"\n icon={<TbArrowRight />}\n onClick={enviar}\n />\n </div>\n </div>\n )\n}\n\nexport default ChatInput\n"],"names":[],"mappings":";;;;;;;;AAkBA,MAAM,EAAE,gBAAgB;AAExB,MAAM,YAAY,CAAC,UAA0B;AACzC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAiB,CAAA,CAAE;AAEzD,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EAAA,IACA;AAEJ,QAAM,WAAW,OAAyB,IAAI;AAE9C,QAAM,mBAAmB,MAAM;AAC3B,QAAI,SAAS,SAAS;AAClB,eAAS,QAAQ,QAAQ;AAAA,IAC7B;AACA,mBAAe,CAAA,CAAE;AAAA,EACrB;AAGA,QAAM,SAAS,MAAM;AACjB,UAAM,QAAQ,SAAS,SAAS,SAAS;AACzC,QAAI,CAAC,MAAM,KAAA,KAAU,YAAY,WAAW,GAAG;AAC3C;AAAA,IACJ;AACA,oBAAgB,EAAE,OAAO,aAAa;AACtC,qBAAA;AAAA,EACJ;AAEA,QAAM,gBAAgB,CAAC,UAA2C;AAC9D,QAAI,MAAM,QAAQ,SAAS;AACvB,aAAA;AAAA,IACJ;AAAA,EACJ;AAEA,SACI,qBAAC,OAAA,EAAI,WAAU,4FACV,UAAA;AAAA,IAAA,YAAY,SAAS,KAClB;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,UAAU;AAAA,QACV,eAAc;AAAA,QACd,eAAc;AAAA,QACd,cAAc;AAAA,QAEd,UAAA,oBAAA,UAAA,CAAA,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,IAGV,qBAAC,OAAA,EAAI,WAAU,2CACX,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACI,GAAG;AAAA,UACJ,UAAU;AAAA,UACV,UAAU;AAAA,UACV,UAAU;AAAA,UAEV,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAU;AAAA,cACV,MAAK;AAAA,cAEL,8BAAC,aAAA,CAAA,CAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACjB;AAAA,MAAA;AAAA,MAEJ;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,KAAK,YAAY,UAAU,GAAG;AAAA,UAC9B,WAAU;AAAA,UACV;AAAA,UACA,WAAW;AAAA,QAAA;AAAA,MAAA;AAAA,MAEd;AAAA,MACD;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,MAAK;AAAA,UACL,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,0BAAO,cAAA,EAAa;AAAA,UACpB,SAAS;AAAA,QAAA;AAAA,MAAA;AAAA,IACb,EAAA,CACJ;AAAA,EAAA,GACJ;AAER;"}
@@ -10,7 +10,7 @@ import "./auth/index.js";
10
10
  import "./assets/index.js";
11
11
  import "./locales/index.js";
12
12
  import { ADMIN, USER } from "./constants/roles.constant.js";
13
- import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImages, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./services/AiService.js";
13
+ import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImagemDoChat, apiGetImages, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./services/AiService.js";
14
14
  import { APP_NAME, REDIRECT_URL_KEY } from "./constants/app.constant.js";
15
15
  import { AUTH_PREFIX_PATH, CONCEPTS_PREFIX_PATH, DASHBOARDS_PREFIX_PATH, GUIDE_PREFIX_PATH, PAGES_PREFIX_PATH, ROOT, UI_COMPONENTS_PREFIX_PATH } from "./constants/route.constant.js";
16
16
  import { default as default2 } from "./components/shared/AbbreviateNumber.js";
@@ -394,6 +394,7 @@ export {
394
394
  apiGetCustomersList,
395
395
  apiGetEcommerceDashboard,
396
396
  apiGetFiles,
397
+ apiGetImagemDoChat,
397
398
  apiGetImages,
398
399
  apiGetLogs,
399
400
  apiGetMail,
@@ -1,6 +1,8 @@
1
+ import "../../base/configs/index.js";
1
2
  import { authHeaders } from "./aiAuthHeaders.js";
2
3
  import ApiService from "./ApiService.js";
3
4
  import { readSse } from "./sseParser.js";
5
+ import endpointNavigationConfig from "../../base/configs/endpoints.config/endpoints.navigation.js";
4
6
  const AI_DEV_URL = "http://localhost:8000";
5
7
  const AI_QAS_URL = "https://orbe-ai.apps.qas.orbeagro.com.br";
6
8
  const AI_PRD_URL = "https://orbe-ai.apps.prd.orbeagro.com.br";
@@ -50,16 +52,25 @@ async function streamChat({
50
52
  prompt,
51
53
  conversationId,
52
54
  esforco,
55
+ imagens,
53
56
  signal,
54
57
  onEvent
55
58
  }) {
56
59
  await postarEConsumir(
57
60
  "/ai/chat/stream",
58
- { prompt, conversation_id: conversationId, esforco },
61
+ { prompt, conversation_id: conversationId, esforco, imagens },
59
62
  onEvent,
60
63
  signal
61
64
  );
62
65
  }
66
+ async function apiGetImagemDoChat(objectName) {
67
+ return ApiService.fetchDataWithAxios({
68
+ url: endpointNavigationConfig.objectStorage.minio.download,
69
+ method: "get",
70
+ params: { fileName: objectName },
71
+ skipGlobalLoading: true
72
+ });
73
+ }
63
74
  async function resumeChat({
64
75
  approved,
65
76
  dados,
@@ -115,6 +126,7 @@ export {
115
126
  apiDeleteConversation,
116
127
  apiGetChatHistory,
117
128
  apiGetConversations,
129
+ apiGetImagemDoChat,
118
130
  apiGetImages,
119
131
  apiPostImages,
120
132
  apiRenameConversation,
@@ -1 +1 @@
1
- {"version":3,"file":"AiService.js","sources":["../../../lib/@ecme/services/AiService.ts"],"sourcesContent":["import { authHeaders } from './aiAuthHeaders'\nimport ApiService from './ApiService'\nimport { readSse } from './sseParser'\nimport type { ChatEvent, Esforco } from '@/views/concepts/ai/Chat/types'\nimport type { AxiosRequestConfig } from 'axios'\n\nconst AI_DEV_URL = 'http://localhost:8000'\nconst AI_QAS_URL = 'https://orbe-ai.apps.qas.orbeagro.com.br'\nconst AI_PRD_URL = 'https://orbe-ai.apps.prd.orbeagro.com.br'\n\n/**\n * Host da API de IA.\n *\n * O /ai/* nao vive no gateway do resto da aplicacao, entao nao pode usar o\n * baseURL do AxiosBase (API_URL). A resolucao e por origin em runtime, e nao\n * por import.meta.env.MODE, porque o MODE e congelado na build da lib como\n * \"production\" e nao reflete o dev do MFE consumidor.\n */\nfunction getAiApiUrl() {\n const origin = globalThis?.location?.origin ?? ''\n\n if (origin.includes('localhost') || origin.includes('127.0.0.1')) {\n return AI_DEV_URL\n }\n\n if (origin.includes('.prd.')) {\n return AI_PRD_URL\n }\n\n return AI_QAS_URL\n}\n\nexport const AI_API_URL = getAiApiUrl()\n\n/**\n * Toda chamada de IA sai pelo AI_API_URL (o baseURL por requisicao vence o da\n * instancia do AxiosBase) e fica fora do loading global — o chat mostra o\n * proprio balaozinho de \"digitando\".\n */\nconst aiRequest = <T>(config: AxiosRequestConfig) =>\n ApiService.fetchDataWithAxios<T>({\n ...config,\n baseURL: AI_API_URL,\n skipGlobalLoading: true,\n })\n\nexport async function apiGetChatHistory<T>(conversationId?: string) {\n return aiRequest<T>({\n url: '/ai/chat/history',\n method: 'get',\n params: conversationId ? { conversation_id: conversationId } : undefined,\n })\n}\n\n/** Conversas do usuário (só o resumo), a mais recente primeiro. */\nexport async function apiGetConversations<T>() {\n return aiRequest<T>({\n url: '/ai/chat/conversations',\n method: 'get',\n })\n}\n\nexport async function apiRenameConversation(conversationId: string, title: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'patch',\n data: { title },\n })\n}\n\n/** Apaga a conversa e toda a memória dela no backend. */\nexport async function apiDeleteConversation(conversationId: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'delete',\n })\n}\n\nexport type StreamChatParams = {\n prompt: string\n /** Identifica a conversa; o backend usa como thread da memoria. */\n conversationId?: string\n /** Nivel de raciocinio desta mensagem; ausente = o padrao do backend. */\n esforco?: Esforco\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Resposta a pausa atual do agente. Ha duas, e um endpoint so:\n * - `approved` responde ao `approval_required` (true aprova, false nega).\n * - `dados` responde ao `input_required`; `null` = o usuario fechou o\n * formulario sem preencher.\n */\nexport type ResumeChatParams = {\n approved?: boolean\n dados?: Record<string, unknown> | null\n conversationId?: string\n /** A retomada tambem chama o modelo: vale o mesmo nivel do envio. */\n esforco?: Esforco\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Envia a mensagem e consome a resposta em streaming (SSE).\n *\n * Usa `fetch`, e nao o Axios, porque o Axios no browser so resolve a Promise\n * com a resposta inteira — nao ha como ler o corpo enquanto ele chega.\n */\nexport async function streamChat({\n prompt,\n conversationId,\n esforco,\n signal,\n onEvent,\n}: StreamChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/stream',\n { prompt, conversation_id: conversationId, esforco },\n onEvent,\n signal,\n )\n}\n\n/**\n * Retoma uma conversa parada numa pausa (aprovacao ou coleta de dados).\n *\n * Devolve o mesmo tipo de stream do `streamChat`, e a resposta continua na\n * MESMA mensagem do chat — o backend so volta do ponto onde parou.\n *\n * O `JSON.stringify` descarta chaves `undefined`, entao o backend recebe apenas\n * o campo da pausa que esta sendo respondida.\n */\nexport async function resumeChat({\n approved,\n dados,\n conversationId,\n esforco,\n signal,\n onEvent,\n}: ResumeChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/resume',\n { approved, dados, conversation_id: conversationId, esforco },\n onEvent,\n signal,\n )\n}\n\n/** POST + leitura do SSE, comum ao envio e a retomada. */\nasync function postarEConsumir(\n caminho: string,\n corpo: Record<string, unknown>,\n onEvent: (evento: ChatEvent) => void,\n signal?: AbortSignal,\n): Promise<void> {\n const resposta = await fetch(`${AI_API_URL}${caminho}`, {\n method: 'POST',\n headers: {\n ...authHeaders(),\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(corpo),\n signal,\n })\n\n if (!resposta.ok || !resposta.body) {\n throw new Error(`Falha ao falar com a IA (HTTP ${resposta.status})`)\n }\n\n await readSse(resposta.body, ({ event, data }) => {\n try {\n onEvent({ type: event, data: JSON.parse(data) } as ChatEvent)\n } catch (error) {\n // Evento malformado nao pode derrubar o stream inteiro.\n console.debug('Evento SSE ignorado:', event, error)\n }\n })\n}\n\nexport async function apiGetImages<T, U extends Record<string, unknown>>(\n params: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'get',\n params,\n })\n}\n\nexport async function apiPostImages<T, U extends Record<string, unknown>>(\n data: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'post',\n data,\n })\n}\n"],"names":[],"mappings":";;;AAMA,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAUnB,SAAS,cAAc;AACnB,QAAM,SAAS,YAAY,UAAU,UAAU;AAE/C,MAAI,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,WAAW,GAAG;AAC9D,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,SAAS,OAAO,GAAG;AAC1B,WAAO;AA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O,IAAI;AAAA,IACpD,QAAQ;AAAA,IACR,SAAS;AAAA,MACL,GAAG,YAAA;AAAA,MACH,gBAAgB;AAAA,IAAA;AAAA,IAEpB,MAAM,KAAK,UAAU,KAAK;AAAA,IAC1B;AAAA,EAAA,CACH;AAED,MAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,UAAM,IAAI,MAAM,iCAAiC,SAAS,MAAM,GAAG;AAAA,EACvE;AAEA,QAAM,QAAQ,SAAS,MAAM,CAAC,EAAE,OAAO,WAAW;AAC9C,QAAI;AACA,cAAQ,EAAE,MAAM,OAAO,MAAM,KAAK,MAAM,IAAI,GAAgB;AAAA,IAChE,SAAS,OAAO;AAEZ,cAAQ,MAAM,wBAAwB,OAAO,KAAK;AAAA,IACtD;AAAA,EACJ,CAAC;AACL;AAEA,eAAsB,aAClB,QACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;AAEA,eAAsB,cAClB,MACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;"}
1
+ {"version":3,"file":"AiService.js","sources":["../../../lib/@ecme/services/AiService.ts"],"sourcesContent":["import { endpointsConfig } from '@base/configs'\nimport { authHeaders } from './aiAuthHeaders'\nimport ApiService from './ApiService'\nimport { readSse } from './sseParser'\nimport type {\n ArquivoDoStorage,\n ChatEvent,\n Esforco,\n ImagemEnviada,\n} from '@/views/concepts/ai/Chat/types'\nimport type { AxiosRequestConfig } from 'axios'\n\nconst AI_DEV_URL = 'http://localhost:8000'\nconst AI_QAS_URL = 'https://orbe-ai.apps.qas.orbeagro.com.br'\nconst AI_PRD_URL = 'https://orbe-ai.apps.prd.orbeagro.com.br'\n\n/**\n * Host da API de IA.\n *\n * O /ai/* nao vive no gateway do resto da aplicacao, entao nao pode usar o\n * baseURL do AxiosBase (API_URL). A resolucao e por origin em runtime, e nao\n * por import.meta.env.MODE, porque o MODE e congelado na build da lib como\n * \"production\" e nao reflete o dev do MFE consumidor.\n */\nfunction getAiApiUrl() {\n const origin = globalThis?.location?.origin ?? ''\n\n if (origin.includes('localhost') || origin.includes('127.0.0.1')) {\n return AI_DEV_URL\n }\n\n if (origin.includes('.prd.')) {\n return AI_PRD_URL\n }\n\n return AI_QAS_URL\n}\n\nexport const AI_API_URL = getAiApiUrl()\n\n/**\n * Toda chamada de IA sai pelo AI_API_URL (o baseURL por requisicao vence o da\n * instancia do AxiosBase) e fica fora do loading global — o chat mostra o\n * proprio balaozinho de \"digitando\".\n */\nconst aiRequest = <T>(config: AxiosRequestConfig) =>\n ApiService.fetchDataWithAxios<T>({\n ...config,\n baseURL: AI_API_URL,\n skipGlobalLoading: true,\n })\n\nexport async function apiGetChatHistory<T>(conversationId?: string) {\n return aiRequest<T>({\n url: '/ai/chat/history',\n method: 'get',\n params: conversationId ? { conversation_id: conversationId } : undefined,\n })\n}\n\n/** Conversas do usuário (só o resumo), a mais recente primeiro. */\nexport async function apiGetConversations<T>() {\n return aiRequest<T>({\n url: '/ai/chat/conversations',\n method: 'get',\n })\n}\n\nexport async function apiRenameConversation(conversationId: string, title: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'patch',\n data: { title },\n })\n}\n\n/** Apaga a conversa e toda a memória dela no backend. */\nexport async function apiDeleteConversation(conversationId: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'delete',\n })\n}\n\nexport type StreamChatParams = {\n prompt: string\n /** Identifica a conversa; o backend usa como thread da memoria. */\n conversationId?: string\n /** Nivel de raciocinio desta mensagem; ausente = o padrao do backend. */\n esforco?: Esforco\n /** Imagens desta mensagem; ausente = so texto. */\n imagens?: ImagemEnviada[]\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Resposta a pausa atual do agente. Ha duas, e um endpoint so:\n * - `approved` responde ao `approval_required` (true aprova, false nega).\n * - `dados` responde ao `input_required`; `null` = o usuario fechou o\n * formulario sem preencher.\n */\nexport type ResumeChatParams = {\n approved?: boolean\n dados?: Record<string, unknown> | null\n conversationId?: string\n /** A retomada tambem chama o modelo: vale o mesmo nivel do envio. */\n esforco?: Esforco\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Envia a mensagem e consome a resposta em streaming (SSE).\n *\n * Usa `fetch`, e nao o Axios, porque o Axios no browser so resolve a Promise\n * com a resposta inteira — nao ha como ler o corpo enquanto ele chega.\n */\nexport async function streamChat({\n prompt,\n conversationId,\n esforco,\n imagens,\n signal,\n onEvent,\n}: StreamChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/stream',\n { prompt, conversation_id: conversationId, esforco, imagens },\n onEvent,\n signal,\n )\n}\n\n/**\n * Imagem do chat guardada no object storage, pelo `objectName` do historico.\n *\n * Vai pelo gateway, como os outros modulos (e nao pelo AI_API_URL): e o mesmo\n * endpoint do `ObjectStorageService`, mas fora do loading global - a miniatura\n * carrega dentro da mensagem, sem travar a tela.\n */\nexport async function apiGetImagemDoChat(objectName: string) {\n return ApiService.fetchDataWithAxios<ArquivoDoStorage>({\n url: endpointsConfig.objectStorage.minio.download,\n method: 'get',\n params: { fileName: objectName },\n skipGlobalLoading: true,\n })\n}\n\n/**\n * Retoma uma conversa parada numa pausa (aprovacao ou coleta de dados).\n *\n * Devolve o mesmo tipo de stream do `streamChat`, e a resposta continua na\n * MESMA mensagem do chat — o backend so volta do ponto onde parou.\n *\n * O `JSON.stringify` descarta chaves `undefined`, entao o backend recebe apenas\n * o campo da pausa que esta sendo respondida.\n */\nexport async function resumeChat({\n approved,\n dados,\n conversationId,\n esforco,\n signal,\n onEvent,\n}: ResumeChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/resume',\n { approved, dados, conversation_id: conversationId, esforco },\n onEvent,\n signal,\n )\n}\n\n/** POST + leitura do SSE, comum ao envio e a retomada. */\nasync function postarEConsumir(\n caminho: string,\n corpo: Record<string, unknown>,\n onEvent: (evento: ChatEvent) => void,\n signal?: AbortSignal,\n): Promise<void> {\n const resposta = await fetch(`${AI_API_URL}${caminho}`, {\n method: 'POST',\n headers: {\n ...authHeaders(),\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(corpo),\n signal,\n })\n\n if (!resposta.ok || !resposta.body) {\n throw new Error(`Falha ao falar com a IA (HTTP ${resposta.status})`)\n }\n\n await readSse(resposta.body, ({ event, data }) => {\n try {\n onEvent({ type: event, data: JSON.parse(data) } as ChatEvent)\n } catch (error) {\n // Evento malformado nao pode derrubar o stream inteiro.\n console.debug('Evento SSE ignorado:', event, error)\n }\n })\n}\n\nexport async function apiGetImages<T, U extends Record<string, unknown>>(\n params: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'get',\n params,\n })\n}\n\nexport async function apiPostImages<T, U extends Record<string, unknown>>(\n data: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'post',\n data,\n })\n}\n"],"names":["endpointsConfig"],"mappings":";;;;;AAYA,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAUnB,SAAS,cAAc;AACnB,QAAM,SAAS,YAAY,UAAU,UAAU;AAE/C,MAAI,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,WAAW,GAAG;AAC9D,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,SAAS,OAAO,GAAG;AAC1B,WAAO;AAAA,EACX;AAEA,SAAO;AACX;AAEO,MAAM,aAAa,YAAA;AAO1B,MAAM,YAAY,CAAI,WAClB,WAAW,mBAAsB;AAAA,EAC7B,GAAG;AAAA,EACH,SAAS;AAAA,EACT,mBAAmB;AACvB,CAAC;AAEL,eAAsB,kBAAqB,gBAAyB;AAChE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ,iBAAiB,EAAE,iBAAiB,mBAAmB;AAAA,E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AA;AAAA,IAEpB,MAAM,KAAK,UAAU,KAAK;AAAA,IAC1B;AAAA,EAAA,CACH;AAED,MAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,UAAM,IAAI,MAAM,iCAAiC,SAAS,MAAM,GAAG;AAAA,EACvE;AAEA,QAAM,QAAQ,SAAS,MAAM,CAAC,EAAE,OAAO,WAAW;AAC9C,QAAI;AACA,cAAQ,EAAE,MAAM,OAAO,MAAM,KAAK,MAAM,IAAI,GAAgB;AAAA,IAChE,SAAS,OAAO;AAEZ,cAAQ,MAAM,wBAAwB,OAAO,KAAK;AAAA,IACtD;AAAA,EACJ,CAAC;AACL;AAEA,eAAsB,aAClB,QACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;AAEA,eAAsB,cAClB,MACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;"}
@@ -1,6 +1,6 @@
1
1
  import { default as default2 } from "./ApiService.js";
2
2
  import { apiGetPricingPlans, apiGetRolesPermissionsRoles, apiGetRolesPermissionsUsers, apiGetSettingsBilling, apiGetSettingsIntergration, apiGetSettingsNotification, apiGetSettingsProfile } from "./AccontsService.js";
3
- import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImages, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./AiService.js";
3
+ import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImagemDoChat, apiGetImages, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./AiService.js";
4
4
  import { apiForgotPassword, apiResetPassword, apiSignIn, apiSignOut, apiSignUp } from "./AuthService.js";
5
5
  import { apiGetCalendar } from "./CalendarService.js";
6
6
  import { apiGetChats, apiGetContactDetails, apiGetContacts, apiGetConversation } from "./ChatService.js";
@@ -34,6 +34,7 @@ export {
34
34
  apiGetCustomersList,
35
35
  apiGetEcommerceDashboard,
36
36
  apiGetFiles,
37
+ apiGetImagemDoChat,
37
38
  apiGetImages,
38
39
  apiGetLogs,
39
40
  apiGetMail,
@@ -14,6 +14,8 @@ import ToolCallChip from "./ToolCallChip.js";
14
14
  import ApprovalCard from "./ApprovalCard.js";
15
15
  import DataRequestCard from "./DataRequestCard.js";
16
16
  import EsforcoRaciocinio from "./EsforcoRaciocinio.js";
17
+ import ImagensDaMensagem from "./ImagensDaMensagem.js";
18
+ import { UPLOAD_DE_IMAGENS } from "../imagens.js";
17
19
  import { usGenerativeChatStore } from "../store/generativeChatStore.js";
18
20
  import useChatSend from "../hooks/useChatSend.js";
19
21
  import useConversationMessages from "../hooks/useConversationMessages.js";
@@ -46,9 +48,10 @@ const ChatView = ({
46
48
  return chat?.conversation || [];
47
49
  }, [selectedConversation, chatHistory]);
48
50
  const handleInputChange = async ({
49
- value
51
+ value,
52
+ attachments
50
53
  }) => {
51
- await handleSend(value);
54
+ await handleSend(value, attachments);
52
55
  };
53
56
  const handleFinish = (id) => {
54
57
  disabledChatFresh(id);
@@ -154,7 +157,11 @@ const ChatView = ({
154
157
  )
155
158
  ] });
156
159
  }
157
- return message.content;
160
+ const { imagens } = message;
161
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
162
+ /* @__PURE__ */ jsx(ImagensDaMensagem, { imagens }),
163
+ message.content
164
+ ] });
158
165
  },
159
166
  customAction: (message) => {
160
167
  if (message.sender.id === "ai" && !message.isError) {
@@ -168,6 +175,7 @@ const ChatView = ({
168
175
  return null;
169
176
  },
170
177
  onInputChange: handleInputChange,
178
+ uploadProps: UPLOAD_DE_IMAGENS,
171
179
  inputActions: /* @__PURE__ */ jsx(EsforcoRaciocinio, { floatingClass: dropdownFloatingClass }),
172
180
  children: selectedConversation ? /* @__PURE__ */ jsx("p", { className: "py-1 text-center text-xs text-gray-500 dark:text-gray-400", children: "Orbe-AI é uma inteligência artificial e pode cometer erros." }) : /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-y-auto", children: /* @__PURE__ */ jsx(ChatLandingView, {}) })
173
181
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo, useCallback } from 'react'\nimport { TbDownload } from 'react-icons/tb'\nimport * as XLSX from 'xlsx'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport EsforcoRaciocinio from './EsforcoRaciocinio'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const { selectedConversation, chatHistory, isTyping, disabledChatFresh } =\n usGenerativeChatStore()\n const { handleSend, handleApproval, handleDataSubmit } = useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n }: {\n value: string\n attachments?: File[]\n }) => {\n await handleSend(value)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n const handleSpreadsheetDownload = useCallback(\n (titulo: string, abas: Array<{ nome: string; colunas: string[]; linhas: Record<string, unknown>[] }>) => {\n const workbook = XLSX.utils.book_new()\n for (const aba of abas) {\n const sheet = XLSX.utils.aoa_to_sheet([\n aba.colunas,\n ...aba.linhas.map((linha) =>\n aba.colunas.map((col) => linha[col] ?? ''),\n ),\n ])\n XLSX.utils.book_append_sheet(workbook, sheet, aba.nome.slice(0, 31))\n }\n XLSX.writeFile(workbook, `${titulo}.xlsx`)\n },\n [],\n )\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // +24px sobre a altura do input: espaco da linha de aviso.\n messageListClass=\"h-[calc(100%-124px)] xl:h-[calc(100%-94px)]\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const { tools, pendingApproval, pendingInput, spreadsheet } =\n message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {spreadsheet && (\n <button\n type=\"button\"\n onClick={() =>\n handleSpreadsheetDownload(\n spreadsheet.titulo,\n spreadsheet.abas,\n )\n }\n className=\"inline-flex items-center gap-2 rounded-lg border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400 dark:hover:bg-emerald-900/50\"\n >\n <TbDownload size={18} />\n <span>Baixar {spreadsheet.titulo}.xlsx</span>\n </button>\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n </div>\n )\n }\n\n return message.content\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n inputActions={\n <EsforcoRaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"flex-1 min-h-0 overflow-y-auto\">\n <ChatLandingView />\n </div>\n )}\n </ChatBox>\n </Card>\n )\n}\n\nexport default ChatView\n"],"names":["chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,eACF;AAeJ,MAAM,WAAW,CAAC;AAAA,EACd,gBAAgB;AAAA,EAChB;AACJ,MAAqB;AACjB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM,EAAE,sBAAsB,aAAa,UAAU,kBAAA,IACjD,sBAAA;AACJ,QAAM,EAAE,YAAY,gBAAgB,iBAAA,IAAqB,YAAA;AAEzD,QAAM,EAAE,WAAA,IAAe,wBAAA;AAEvB,QAAM,iBAAiB,MAAM;AACzB,QAAI,UAAU,SAAS,kBAAkB;AAC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AQ,YAAY;AAAA,sBAAO;AAAA,oBAAA,EAAA,CAAK;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,cAG7C,gBACG;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,OAAO;AAAA,kBACP,UAAU,CAAC,UACP;AAAA,oBACI;AAAA,oBACA,QAAQ;AAAA,oBACR;AAAA,kBAAA;AAAA,gBACJ;AAAA,cAAA;AAAA,cAIX,mBACG;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,UAAU;AAAA,kBACV,UAAU,CAAC,aACP;AAAA,oBACI;AAAA,oBACA,QAAQ;AAAA,oBACR;AAAA,kBAAA;AAAA,gBACJ;AAAA,cAAA;AAAA,YAER,GAER;AAAA,UAER;AAEA,iBAAO,QAAQ;AAAA,QACnB;AAAA,QACA,cAAc,CAAC,YAAY;AACvB,cAAI,QAAQ,OAAO,OAAO,QAAQ,CAAC,QAAQ,SAAS;AAChD,mBACI;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,SAAS,QAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UAG7B;AAEA,iBAAO;AAAA,QACX;AAAA,QACA,eAAe;AAAA,QACf,cACI,oBAAC,mBAAA,EAAkB,eAAe,sBAAA,CAAuB;AAAA,QAK5D,UAAA,uBACG,oBAAC,KAAA,EAAE,WAAU,6DAA4D,UAAA,8DAAA,CAGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
1
+ {"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo, useCallback } from 'react'\nimport { TbDownload } from 'react-icons/tb'\nimport * as XLSX from 'xlsx'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport EsforcoRaciocinio from './EsforcoRaciocinio'\nimport ImagensDaMensagem from './ImagensDaMensagem'\nimport { UPLOAD_DE_IMAGENS } from '../imagens'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const { selectedConversation, chatHistory, isTyping, disabledChatFresh } =\n usGenerativeChatStore()\n const { handleSend, handleApproval, handleDataSubmit } = useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments: File[]\n }) => {\n await handleSend(value, attachments)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n const handleSpreadsheetDownload = useCallback(\n (titulo: string, abas: Array<{ nome: string; colunas: string[]; linhas: Record<string, unknown>[] }>) => {\n const workbook = XLSX.utils.book_new()\n for (const aba of abas) {\n const sheet = XLSX.utils.aoa_to_sheet([\n aba.colunas,\n ...aba.linhas.map((linha) =>\n aba.colunas.map((col) => linha[col] ?? ''),\n ),\n ])\n XLSX.utils.book_append_sheet(workbook, sheet, aba.nome.slice(0, 31))\n }\n XLSX.writeFile(workbook, `${titulo}.xlsx`)\n },\n [],\n )\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // +24px sobre a altura do input: espaco da linha de aviso.\n messageListClass=\"h-[calc(100%-124px)] xl:h-[calc(100%-94px)]\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const { tools, pendingApproval, pendingInput, spreadsheet } =\n message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {spreadsheet && (\n <button\n type=\"button\"\n onClick={() =>\n handleSpreadsheetDownload(\n spreadsheet.titulo,\n spreadsheet.abas,\n )\n }\n className=\"inline-flex items-center gap-2 rounded-lg border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400 dark:hover:bg-emerald-900/50\"\n >\n <TbDownload size={18} />\n <span>Baixar {spreadsheet.titulo}.xlsx</span>\n </button>\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n </div>\n )\n }\n\n const { imagens } = message as Conversation\n return (\n <div className=\"flex flex-col gap-2\">\n <ImagensDaMensagem imagens={imagens} />\n {message.content}\n </div>\n )\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n uploadProps={UPLOAD_DE_IMAGENS}\n inputActions={\n <EsforcoRaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"flex-1 min-h-0 overflow-y-auto\">\n <ChatLandingView />\n </div>\n )}\n </ChatBox>\n </Card>\n )\n}\n\nexport default ChatView\n"],"names":["chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,eACF;AAeJ,MAAM,WAAW,CAAC;AAAA,EACd,gBAAgB;AAAA,EAChB;AACJ,MAAqB;AACjB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM,EAAE,sBAAsB,aAAa,UAAU,kBAAA,IACjD,sBAAA;AACJ,QAAM,EAAE,YAAY,gBAAgB,iBAAA,IAAqB,YAAA;AAEzD,QAAM,EAAE,WAAA,IAAe,wBAAA;AAEvB,QAAM,iBAAiB,MAAM;AACzB,QAAI,UAAU,SAAS,kBAAkB;AACrC,YAAM,gBAAgB,UAAU,QAAQ,iBAAA;AACxC,UAAI,eAAe;AACf,sBAAc,YAAY,cAAc;AAAA,MAC5C;AAAA,IACJ;AAAA,EACJ;AAEA,YAAU,MAAM;AACZ,mBAAA;AAAA,EACJ,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OAAO;AAAA,kBACP,UAAU,CAAC,UACP;AAAA,oBACI;AAAA,oBACA,QAAQ;AAAA,oBACR;AAAA,kBAAA;AAAA,gBACJ;AAAA,cAAA;AAAA,cAIX,mBACG;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,UAAU;AAAA,kBACV,UAAU,CAAC,aACP;AAAA,oBACI;AAAA,oBACA,QAAQ;AAAA,oBACR;AAAA,kBAAA;AAAA,gBACJ;AAAA,cAAA;AAAA,YAER,GAER;AAAA,UAER;AAEA,gBAAM,EAAE,YAAY;AACpB,iBACI,qBAAC,OAAA,EAAI,WAAU,uBACX,UAAA;AAAA,YAAA,oBAAC,qBAAkB,SAAkB;AAAA,YACpC,QAAQ;AAAA,UAAA,GACb;AAAA,QAER;AAAA,QACA,cAAc,CAAC,YAAY;AACvB,cAAI,QAAQ,OAAO,OAAO,QAAQ,CAAC,QAAQ,SAAS;AAChD,mBACI;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,SAAS,QAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UAG7B;AAEA,iBAAO;AAAA,QACX;AAAA,QACA,eAAe;AAAA,QACf,aAAa;AAAA,QACb,cACI,oBAAC,mBAAA,EAAkB,eAAe,sBAAA,CAAuB;AAAA,QAK5D,UAAA,uBACG,oBAAC,KAAA,EAAE,WAAU,6DAA4D,UAAA,8DAAA,CAGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
@@ -0,0 +1,35 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { TbPhotoOff } from "react-icons/tb";
3
+ import "../../../../../components/ui/Skeleton/index.js";
4
+ import useImagemDoStorage from "../hooks/useImagemDoStorage.js";
5
+ import Skeleton from "../../../../../components/ui/Skeleton/Skeleton.js";
6
+ const MINIATURA = "h-40 max-w-[240px] rounded-lg object-cover";
7
+ const Miniatura = ({ imagem }) => {
8
+ const { src, carregando, falhou } = useImagemDoStorage(imagem);
9
+ if (carregando) {
10
+ return /* @__PURE__ */ jsx(Skeleton, { width: 160, height: 160, className: "rounded-lg" });
11
+ }
12
+ if (falhou || !src) {
13
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-40 w-40 flex-col items-center justify-center gap-1 rounded-lg bg-white/10 text-xs", children: [
14
+ /* @__PURE__ */ jsx(TbPhotoOff, { className: "text-2xl" }),
15
+ "Imagem indisponível"
16
+ ] });
17
+ }
18
+ return /* @__PURE__ */ jsx("img", { className: MINIATURA, src, alt: "Imagem enviada" });
19
+ };
20
+ const ImagensDaMensagem = ({ imagens }) => {
21
+ if (!imagens?.length) {
22
+ return null;
23
+ }
24
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: imagens.map((imagem, indice) => /* @__PURE__ */ jsx(
25
+ Miniatura,
26
+ {
27
+ imagem
28
+ },
29
+ imagem.objectName ?? imagem.url ?? indice
30
+ )) });
31
+ };
32
+ export {
33
+ ImagensDaMensagem as default
34
+ };
35
+ //# sourceMappingURL=ImagensDaMensagem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImagensDaMensagem.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.tsx"],"sourcesContent":["import { TbPhotoOff } from 'react-icons/tb'\nimport Skeleton from '@/components/ui/Skeleton'\nimport useImagemDoStorage from '../hooks/useImagemDoStorage'\nimport type { ImagemDaMensagem } from '../types'\n\nconst MINIATURA = 'h-40 max-w-[240px] rounded-lg object-cover'\n\nconst Miniatura = ({ imagem }: { imagem: ImagemDaMensagem }) => {\n const { src, carregando, falhou } = useImagemDoStorage(imagem)\n\n if (carregando) {\n return <Skeleton width={160} height={160} className=\"rounded-lg\" />\n }\n\n if (falhou || !src) {\n return (\n <div className=\"flex h-40 w-40 flex-col items-center justify-center gap-1 rounded-lg bg-white/10 text-xs\">\n <TbPhotoOff className=\"text-2xl\" />\n Imagem indisponível\n </div>\n )\n }\n\n return <img className={MINIATURA} src={src} alt=\"Imagem enviada\" />\n}\n\ntype ImagensDaMensagemProps = {\n imagens?: ImagemDaMensagem[]\n}\n\n/**\n * As imagens que o usuário enviou, em miniatura, acima do texto da mensagem.\n *\n * Serve a mensagem recém-enviada (blob local) e a que veio do histórico\n * (baixada do object storage) - quem resolve de onde vem é o hook.\n */\nconst ImagensDaMensagem = ({ imagens }: ImagensDaMensagemProps) => {\n if (!imagens?.length) {\n return null\n }\n\n return (\n <div className=\"flex flex-wrap gap-2\">\n {imagens.map((imagem, indice) => (\n <Miniatura\n key={imagem.objectName ?? imagem.url ?? indice}\n imagem={imagem}\n />\n ))}\n </div>\n )\n}\n\nexport default ImagensDaMensagem\n"],"names":[],"mappings":";;;;;AAKA,MAAM,YAAY;AAElB,MAAM,YAAY,CAAC,EAAE,aAA2C;AAC5D,QAAM,EAAE,KAAK,YAAY,OAAA,IAAW,mBAAmB,MAAM;AAE7D,MAAI,YAAY;AACZ,+BAAQ,UAAA,EAAS,OAAO,KAAK,QAAQ,KAAK,WAAU,cAAa;AAAA,EACrE;AAEA,MAAI,UAAU,CAAC,KAAK;AAChB,WACI,qBAAC,OAAA,EAAI,WAAU,4FACX,UAAA;AAAA,MAAA,oBAAC,YAAA,EAAW,WAAU,WAAA,CAAW;AAAA,MAAE;AAAA,IAAA,GAEvC;AAAA,EAER;AAEA,6BAAQ,OAAA,EAAI,WAAW,WAAW,KAAU,KAAI,kBAAiB;AACrE;AAYA,MAAM,oBAAoB,CAAC,EAAE,cAAsC;AAC/D,MAAI,CAAC,SAAS,QAAQ;AAClB,WAAO;AAAA,EACX;AAEA,SACI,oBAAC,SAAI,WAAU,wBACV,kBAAQ,IAAI,CAAC,QAAQ,WAClB;AAAA,IAAC;AAAA,IAAA;AAAA,MAEG;AAAA,IAAA;AAAA,IADK,OAAO,cAAc,OAAO,OAAO;AAAA,EAAA,CAG/C,GACL;AAER;"}
@@ -5,6 +5,7 @@ import "../../../../../auth/index.js";
5
5
  import dayjs from "dayjs";
6
6
  import uniqueId from "lodash/uniqueId";
7
7
  import { novoIdDeConversa } from "../utils.js";
8
+ import { paraImagensDaMensagem, paraImagemEnviada, TITULO_SO_IMAGEM } from "../imagens.js";
8
9
  import useAuth from "../../../../../auth/useAuth.js";
9
10
  const AI_ERROR_MESSAGE = "Desculpe, estou com um pequeno problema de comunicação e não consigo te atender no momento. Tente novamente em instantes.";
10
11
  const useChatSend = () => {
@@ -18,7 +19,7 @@ const useChatSend = () => {
18
19
  setIsTyping
19
20
  } = usGenerativeChatStore();
20
21
  const esforco = useEsforcoStore((state) => state.esforco);
21
- const creteMyMessage = (id, prompt) => {
22
+ const creteMyMessage = (id, prompt, imagens) => {
22
23
  pushConversation(id, {
23
24
  id: uniqueId("ai-conversation-"),
24
25
  sender: {
@@ -27,6 +28,7 @@ const useChatSend = () => {
27
28
  avatarImageUrl: user.avatar ?? void 0
28
29
  },
29
30
  content: prompt,
31
+ imagens: paraImagensDaMensagem(imagens),
30
32
  timestamp: dayjs().toDate(),
31
33
  type: "regular",
32
34
  isMyMessage: true
@@ -129,41 +131,42 @@ const useChatSend = () => {
129
131
  setIsTyping(false);
130
132
  }
131
133
  };
132
- const sendMessage = async (chatId, prompt) => {
134
+ const sendMessage = async (chatId, prompt, imagens) => {
133
135
  const messageId = createAiMessage(chatId);
134
136
  await consumirStream(
135
137
  chatId,
136
138
  messageId,
137
- (onEvent) => streamChat({
139
+ async (onEvent) => streamChat({
138
140
  prompt,
139
141
  conversationId: chatId,
140
142
  esforco,
143
+ imagens: imagens.length ? await Promise.all(imagens.map(paraImagemEnviada)) : void 0,
141
144
  onEvent
142
145
  }),
143
146
  { texto: "", tools: [] }
144
147
  );
145
148
  };
146
- const createConversation = async (chatId, prompt) => {
149
+ const createConversation = async (chatId, prompt, imagens) => {
147
150
  setSelectedConversation(chatId);
148
- await sendMessage(chatId, prompt);
151
+ await sendMessage(chatId, prompt, imagens);
149
152
  };
150
- const handleSend = async (prompt) => {
153
+ const handleSend = async (prompt, imagens = []) => {
151
154
  setIsTyping(true);
152
155
  if (selectedConversation) {
153
- creteMyMessage(selectedConversation, prompt);
154
- await sendMessage(selectedConversation, prompt);
156
+ creteMyMessage(selectedConversation, prompt, imagens);
157
+ await sendMessage(selectedConversation, prompt, imagens);
155
158
  } else {
156
159
  const newId = novoIdDeConversa();
157
160
  pushChatHistory({
158
161
  id: newId,
159
- title: prompt,
162
+ title: prompt.trim() || TITULO_SO_IMAGEM,
160
163
  lastConversation: "",
161
164
  createdTime: dayjs().unix(),
162
165
  updatedTime: dayjs().unix(),
163
166
  enable: true
164
167
  });
165
- creteMyMessage(newId, prompt);
166
- await createConversation(newId, prompt);
168
+ creteMyMessage(newId, prompt, imagens);
169
+ await createConversation(newId, prompt, imagens);
167
170
  }
168
171
  };
169
172
  const handleApproval = async (chatId, messageId, approved) => {