@epam/ai-dial-chat-hooks 1.1.0-dev.423 → 1.1.0-dev.430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{api-error-DuLNy43N.js → api-error/api-error.js} +1 -1
- package/api-transport/create-csrf-middleware.js +21 -0
- package/api-transport/create-unauthorized-middleware.js +41 -0
- package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
- package/attachments.js +3 -2
- package/catalog/catalog-derivations.js +10 -0
- package/catalog/catalog-primary-action.js +21 -0
- package/catalog/create-publish-api.js +27 -0
- package/catalog/deployment-endpoint-url.js +34 -0
- package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
- package/catalog/entity-details.js +6 -0
- package/catalog/map-deployment-limits-to-catalog.js +73 -0
- package/catalog/map-deployment-limits-to-input.js +14 -0
- package/catalog/map-deployment-to-catalog-item.js +92 -0
- package/catalog/map-entity-details-to-catalog.js +350 -0
- package/catalog/map-prompt-to-catalog-item.js +49 -0
- package/catalog/map-skill-to-catalog-item.js +123 -0
- package/catalog/mcp-endpoint-url.js +26 -0
- package/catalog/publish.js +18 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
- package/catalog/useCatalogItemDetails.js +101 -0
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
- package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
- package/catalog/usePublishFolders/usePublishFolders.js +72 -0
- package/catalog.js +22 -3
- package/conversation/announcement-message.js +42 -0
- package/conversation/conversation-transfer/async.js +18 -0
- package/conversation/conversation-transfer/attachment-refs.js +11 -0
- package/conversation/conversation-transfer/build-upload-path.js +27 -0
- package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
- package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
- package/conversation/conversation-transfer/export-conversation.js +32 -0
- package/conversation/conversation-transfer/import-conversation.js +93 -0
- package/conversation/conversation-transfer/progress.js +39 -0
- package/conversation/conversation-transfer/queue.js +84 -0
- package/conversation/conversation-transfer/types.js +9 -0
- package/conversation/conversation-transfer/zip-export.js +19 -0
- package/conversation/conversation-transfer/zip-import.js +29 -0
- package/conversation/create-chat-stream-api.js +96 -0
- package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
- package/conversation/display-name-watch.js +5 -0
- package/conversation/footer-message.js +23 -0
- package/conversation/get-model-id-from-conversation-id.js +14 -0
- package/conversation/greeting.js +7 -0
- package/conversation/message-factory.js +19 -0
- package/conversation/message-utils.js +13 -0
- package/conversation/overlay-messages.js +8 -0
- package/conversation/quick-app-conversation-starters.js +29 -0
- package/conversation/starter-option.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
- package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
- package/conversation/useConversationExport/useConversationExport.js +285 -0
- package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
- package/conversation/useConversationHandlers/message-factory.js +21 -0
- package/conversation/useConversationHandlers/message-utils.js +8 -0
- package/conversation/useConversationHandlers/starter-option.js +11 -0
- package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
- package/conversation/useConversationImport/useConversationImport.js +239 -0
- package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
- package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
- package/conversation/useConversationStream/apply-chunk.js +78 -0
- package/conversation/useConversationStream/buffered-generation.js +18 -0
- package/conversation/useConversationStream/conversation-path.js +8 -0
- package/conversation/useConversationStream/generation-resume.js +126 -0
- package/conversation/useConversationStream/useConversationStream.js +148 -0
- package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
- package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
- package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
- package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
- package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
- package/conversation-sources.js +1 -1
- package/conversation-transfer.js +7 -3
- package/conversation.d.ts +66 -0
- package/conversation.js +31 -2
- package/file-manager.d.ts +3 -4
- package/file-manager.js +28 -3
- package/files/annotation.js +15 -0
- package/files/attachment-canvas.js +218 -0
- package/files/attachment-dto-to-display.js +15 -0
- package/files/attachment-types.js +16 -0
- package/files/create-files-api.js +40 -0
- package/files/create-upload-file-with-progress.js +42 -0
- package/files/dial-file-manager-copy-move.util.js +55 -0
- package/files/dial-file-manager-mapping.util.js +140 -0
- package/files/dial-file-manager-path.util.js +72 -0
- package/files/dial-file-manager.model.js +25 -0
- package/files/dial-file-manager.types.js +10 -0
- package/files/dial-file-to-attachment.js +37 -0
- package/files/dial-file.js +30 -0
- package/files/dial-files-api.js +6 -0
- package/files/download-destination.js +6 -0
- package/files/file-manager-variant.js +11 -0
- package/files/file-name.js +19 -0
- package/files/prepare-download-destination.js +24 -0
- package/files/resolve-dial-file-api-path.js +33 -0
- package/files/source-content.js +37 -0
- package/files/useDialFileListing/useDialFileListing.js +295 -0
- package/files/useDialFileManager/useDialFileManager.js +146 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
- package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
- package/files/useDialFileMutations/useDialFileMutations.js +359 -0
- package/files/useDialFileSharing/useDialFileSharing.js +70 -0
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
- package/index.d.ts +69 -4
- package/index.js +134 -28
- package/mcp-apps/mcp-apps-api-client.js +48 -0
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
- package/mcp-apps.js +6 -2
- package/oauth/authorize-url.js +12 -0
- package/oauth/handshake.js +65 -0
- package/oauth/popup.js +29 -0
- package/oauth/toolset-id.js +10 -0
- package/oauth/types.js +24 -0
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
- package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
- package/oauth.js +9 -3
- package/package.json +35 -23
- package/prompt/export-prompt.js +28 -0
- package/prompt/prompt-resource.js +15 -0
- package/prompt/prompt.js +12 -0
- package/prompt/usePromptsState/usePromptsState.js +42 -0
- package/scheduled-task/scheduled-task-mapping.js +6 -0
- package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
- package/scheduled-tasks.js +3 -2
- package/scroll-anchoring.js +1 -1
- package/shared/application-schema.js +4 -0
- package/shared/browser-timezone.js +10 -0
- package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
- package/shared/custom-apps.js +30 -0
- package/shared/external-services.js +18 -0
- package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
- package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
- package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
- package/shared/toolset-login-events.js +13 -0
- package/sharing.js +3 -3
- package/skill/skill-file-batch-validation.js +48 -0
- package/skill/skill-file-preview.js +15 -0
- package/skill/skill-manifest.js +70 -0
- package/skill/skill-types.js +15 -0
- package/skill/skill.js +48 -0
- package/skill/useSkillEditorLoad.js +103 -0
- package/skill/useSkillEditorSubmit.js +135 -0
- package/skill/useSkillFileActions.js +99 -0
- package/skill/useSkillFilePreview.js +29 -0
- package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
- package/skill-editor.js +8 -3
- package/skills-state.js +1 -1
- package/source-content.d.ts +29 -0
- package/source-content.js +2 -0
- package/usage/useUsageData/useUsageData.js +32 -0
- package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
- package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
- package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
- package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
- package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
- package/useToolsMenu/useToolsMenu.js +50 -0
- package/useViewportWidth/useViewportWidth.js +12 -0
- package/utils.js +17 -7
- package/viewport-layout.js +4 -2
- package/attachment-types-AAoN9E95.js +0 -7760
- package/browser-Btsa0Lmr.js +0 -607
- package/skill-manifest-CeG6-WSK.js +0 -4056
- package/useAttachmentValidation-CkMTd5lA.js +0 -102
- package/useConversationImport-CDRs7JF1.js +0 -826
- package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
- package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
- package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
- package/useSkillFileActions-B-VaGD20.js +0 -373
- package/useSkillFilePreview-B5o1n_0F.js +0 -1244
- package/useToolsMenu-zURpMEn1.js +0 -1882
- package/useToolsetLogin-B05m134e.js +0 -195
- package/useUsageData-D7BxloKZ.js +0 -201
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { formatDateYM as e } from "../conversation-transfer/date.js";
|
|
2
|
+
import { ConversationTransferWarningCode as t } from "../conversation-transfer/types.js";
|
|
3
|
+
import { UnsupportedImportFormatError as n, getFolderBreadcrumb as r, parseImportEnvelope as i, planAttachmentUploads as a, rebaseConversationId as o, rewriteAttachmentUrls as s } from "../conversation-transfer/import-conversation.js";
|
|
4
|
+
import { runWithConcurrency as c } from "../conversation-transfer/async.js";
|
|
5
|
+
import { ConversationTransferKind as l, ConversationTransferPhase as u, buildTransferProgress as d } from "../conversation-transfer/progress.js";
|
|
6
|
+
import { useConversationTransferQueue as f } from "../conversation-transfer/queue.js";
|
|
7
|
+
import { createUploadPathAllocator as p } from "../conversation-transfer/build-upload-path.js";
|
|
8
|
+
import { parseDialArchive as m } from "../conversation-transfer/zip-import.js";
|
|
9
|
+
import { ConversationTransferErrorCode as h, ConversationTransferSubjectKind as g, ConversationTransferUnitKind as _, generateUUID as v } from "@epam/ai-dial-chat-shared";
|
|
10
|
+
import { useCallback as y } from "react";
|
|
11
|
+
//#region src/conversation/useConversationImport/useConversationImport.ts
|
|
12
|
+
var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promise((t, n) => {
|
|
13
|
+
let r = new FileReader();
|
|
14
|
+
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsText(e);
|
|
15
|
+
}), w = async (e) => {
|
|
16
|
+
if (S(e)) {
|
|
17
|
+
let { envelope: t, attachments: n } = await m(e);
|
|
18
|
+
return {
|
|
19
|
+
history: t.history,
|
|
20
|
+
attachments: n,
|
|
21
|
+
isArchive: !0
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
history: i(await C(e)).history,
|
|
26
|
+
attachments: /* @__PURE__ */ new Map(),
|
|
27
|
+
isArchive: !1
|
|
28
|
+
};
|
|
29
|
+
}, T = async (e, t, n, r, i, o, s, l) => {
|
|
30
|
+
let { plan: u, skippedNames: d } = a(e, t, r), f = !1, p = await c(u, b, async (e) => {
|
|
31
|
+
if (l.aborted || f) return;
|
|
32
|
+
let t = e.allocated;
|
|
33
|
+
for (let a = 0; a <= x; a += 1) try {
|
|
34
|
+
let r = new File([new Uint8Array(e.bytes)], t.fileName), a = await i.uploadFile({
|
|
35
|
+
bucket: n,
|
|
36
|
+
path: t.path,
|
|
37
|
+
file: r,
|
|
38
|
+
uploadMode: "create-only"
|
|
39
|
+
}, { signal: l });
|
|
40
|
+
return s(), {
|
|
41
|
+
kind: "uploaded",
|
|
42
|
+
oldFileId: e.fileId,
|
|
43
|
+
newFileId: a.url,
|
|
44
|
+
newTitle: t.isRenamed ? t.fileName : void 0
|
|
45
|
+
};
|
|
46
|
+
} catch (n) {
|
|
47
|
+
if (l.aborted) return;
|
|
48
|
+
if (o(n)) {
|
|
49
|
+
f = !0;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || a === x) return s(), {
|
|
53
|
+
kind: "skipped",
|
|
54
|
+
name: e.originalFileName
|
|
55
|
+
};
|
|
56
|
+
r.markTaken(t.fileName), t = r.allocate(e.originalFileName);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kind: "skipped",
|
|
60
|
+
name: e.originalFileName
|
|
61
|
+
};
|
|
62
|
+
}), m = /* @__PURE__ */ new Map(), h = [...d];
|
|
63
|
+
for (let e of p) e.kind === "uploaded" ? m.set(e.oldFileId, {
|
|
64
|
+
url: e.newFileId,
|
|
65
|
+
...e.newTitle == null ? {} : { title: e.newTitle }
|
|
66
|
+
}) : h.push(e.name);
|
|
67
|
+
return {
|
|
68
|
+
targetMap: m,
|
|
69
|
+
skippedNames: l.aborted || f ? [] : h,
|
|
70
|
+
isUnauthorized: !l.aborted && f
|
|
71
|
+
};
|
|
72
|
+
}, E = ({ conversationsApi: i, filesApi: a, bucket: c, onImported: m, classifyTransferError: b = () => ({}), resolveErrorTraceId: x = async () => void 0, onSuccess: S, onWarning: C, onError: E }) => {
|
|
73
|
+
let D = f(), O = y(async (n, r, f) => {
|
|
74
|
+
if (!c) {
|
|
75
|
+
E?.({
|
|
76
|
+
jobId: n,
|
|
77
|
+
code: h.MissingBucket
|
|
78
|
+
}), D.failJob(n, h.MissingBucket);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let g = l.Import, v = r.attachments.size, y = 0, w = () => {
|
|
82
|
+
y += 1, D.setJobProgress(n, d({
|
|
83
|
+
kind: g,
|
|
84
|
+
phase: u.Transfer,
|
|
85
|
+
completed: y,
|
|
86
|
+
total: v
|
|
87
|
+
}, {
|
|
88
|
+
completed: Math.min(y, v),
|
|
89
|
+
total: v,
|
|
90
|
+
kind: _.Attachment
|
|
91
|
+
}));
|
|
92
|
+
}, O = (e) => {
|
|
93
|
+
D.setJobProgress(n, d({
|
|
94
|
+
kind: g,
|
|
95
|
+
phase: u.Finalize,
|
|
96
|
+
completed: e,
|
|
97
|
+
total: r.history.length
|
|
98
|
+
}, {
|
|
99
|
+
completed: e,
|
|
100
|
+
total: r.history.length,
|
|
101
|
+
kind: _.Conversation
|
|
102
|
+
}));
|
|
103
|
+
}, k = [], A = [], j = /* @__PURE__ */ new Set(), M = !1, N, P = /* @__PURE__ */ new Date(), F = (e) => !!b(e).isUnauthorized, I;
|
|
104
|
+
if (r.isArchive) {
|
|
105
|
+
let t = `uploads/${e(P)}`, r = [];
|
|
106
|
+
try {
|
|
107
|
+
r = (await a.listFiles({
|
|
108
|
+
bucket: c,
|
|
109
|
+
path: t
|
|
110
|
+
}, { signal: f })).items.map((e) => e.name);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
if (f.aborted) return;
|
|
113
|
+
if (F(e)) {
|
|
114
|
+
E?.({
|
|
115
|
+
jobId: n,
|
|
116
|
+
code: h.Unauthorized
|
|
117
|
+
}), D.failJob(n, h.Unauthorized);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
console.error("Failed to list the upload folder for attachment name disambiguation", e);
|
|
121
|
+
}
|
|
122
|
+
I = p({
|
|
123
|
+
date: P,
|
|
124
|
+
existingNames: r
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
D.setJobProgress(n, d({
|
|
128
|
+
kind: g,
|
|
129
|
+
phase: u.Prepare
|
|
130
|
+
})), v === 0 && D.setJobProgress(n, d({
|
|
131
|
+
kind: g,
|
|
132
|
+
phase: u.Transfer
|
|
133
|
+
}));
|
|
134
|
+
for (let e of r.history) {
|
|
135
|
+
if (f.aborted) return;
|
|
136
|
+
if (M) break;
|
|
137
|
+
try {
|
|
138
|
+
let t = /* @__PURE__ */ new Map();
|
|
139
|
+
if (r.isArchive && I) {
|
|
140
|
+
let n = await T(e, r.attachments, c, I, a, F, w, f);
|
|
141
|
+
if (f.aborted) return;
|
|
142
|
+
if (n.isUnauthorized) {
|
|
143
|
+
M = !0;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
for (let e of n.skippedNames) j.add(e);
|
|
147
|
+
t = n.targetMap;
|
|
148
|
+
}
|
|
149
|
+
let { conversation: n, subPath: l } = o(s(e, t), c);
|
|
150
|
+
if (await i.saveConversation({
|
|
151
|
+
path: l,
|
|
152
|
+
saveConversationBodyDto: { conversation: {
|
|
153
|
+
...n,
|
|
154
|
+
llmNamingDone: !0
|
|
155
|
+
} }
|
|
156
|
+
}, { signal: f }), f.aborted) return;
|
|
157
|
+
k.push(e.name);
|
|
158
|
+
} catch (t) {
|
|
159
|
+
if (f.aborted) return;
|
|
160
|
+
if (F(t)) {
|
|
161
|
+
M = !0;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
A.push(e.name), N === void 0 && (N = await x(t)), console.error("Failed to import a conversation", t);
|
|
165
|
+
}
|
|
166
|
+
O(k.length + A.length);
|
|
167
|
+
}
|
|
168
|
+
if (!f.aborted) {
|
|
169
|
+
if (M) {
|
|
170
|
+
E?.({
|
|
171
|
+
jobId: n,
|
|
172
|
+
code: h.Unauthorized
|
|
173
|
+
}), D.failJob(n, h.Unauthorized);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (k.length > 0) {
|
|
177
|
+
try {
|
|
178
|
+
await m?.();
|
|
179
|
+
} catch {}
|
|
180
|
+
S?.({
|
|
181
|
+
jobId: n,
|
|
182
|
+
titles: k
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
A.length > 0 && E?.({
|
|
186
|
+
jobId: n,
|
|
187
|
+
code: h.Unknown,
|
|
188
|
+
titles: A,
|
|
189
|
+
traceId: N
|
|
190
|
+
}), j.size > 0 && C?.({
|
|
191
|
+
jobId: n,
|
|
192
|
+
code: t.AttachmentSkipped,
|
|
193
|
+
names: [...j]
|
|
194
|
+
}), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped) : D.succeedJob(n);
|
|
195
|
+
}
|
|
196
|
+
}, [
|
|
197
|
+
c,
|
|
198
|
+
b,
|
|
199
|
+
i,
|
|
200
|
+
a,
|
|
201
|
+
E,
|
|
202
|
+
m,
|
|
203
|
+
S,
|
|
204
|
+
C,
|
|
205
|
+
D,
|
|
206
|
+
x
|
|
207
|
+
]), k = y(async (e) => {
|
|
208
|
+
let t;
|
|
209
|
+
try {
|
|
210
|
+
t = await w(e);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
E?.({
|
|
213
|
+
jobId: v(),
|
|
214
|
+
code: h.UnsupportedFormat
|
|
215
|
+
}), e instanceof n || console.error("Failed to parse import file", e);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
let i = t.history.length > 1, a = t.history[0], o = i ? { kind: g.All } : {
|
|
219
|
+
kind: g.Single,
|
|
220
|
+
title: a?.name ?? e.name,
|
|
221
|
+
sourceBreadcrumb: a ? r(a) : void 0
|
|
222
|
+
}, s = D.addJob(o, e.name);
|
|
223
|
+
return D.startJob(s, (e) => O(s, t, e));
|
|
224
|
+
}, [
|
|
225
|
+
E,
|
|
226
|
+
D,
|
|
227
|
+
O
|
|
228
|
+
]);
|
|
229
|
+
return {
|
|
230
|
+
jobs: D.jobs,
|
|
231
|
+
importConversations: k,
|
|
232
|
+
cancelJob: D.cancelJob,
|
|
233
|
+
dismissJob: D.dismissJob,
|
|
234
|
+
retryJob: D.retryJob,
|
|
235
|
+
dismissAll: D.dismissAll
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
export { E as useConversationImport };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo as e } from "react";
|
|
2
|
+
//#region src/conversation/useConversationLookupMaps/useConversationLookupMaps.ts
|
|
3
|
+
var t = ({ items: t, toPanelConversationId: n }) => e(() => {
|
|
4
|
+
let e = new Map(t.map((e) => [n(e.id), e.id])), r = new Map(t.map((e) => [n(e.id), e]));
|
|
5
|
+
return {
|
|
6
|
+
toContextId: (t) => e.get(t),
|
|
7
|
+
getRawItem: (e) => r.get(e)
|
|
8
|
+
};
|
|
9
|
+
}, [t, n]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as useConversationLookupMaps };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { safeDecodeURIComponent as e } from "../../shared/string-utils.js";
|
|
2
|
+
import { findDeploymentByIdOrReference as t } from "../../catalog/deployment-id.js";
|
|
3
|
+
import { getModelIdFromConversationId as n } from "../get-model-id-from-conversation-id.js";
|
|
4
|
+
import { FilterTab as r } from "@epam/ai-dial-chat-shared";
|
|
5
|
+
import { useMemo as i } from "react";
|
|
6
|
+
//#region src/conversation/useConversationPanelItems/useConversationPanelItems.ts
|
|
7
|
+
var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization : r.MyChats, o = ({ items: r, deployments: o, isDeploymentsLoading: s, toPanelConversationId: c, resolveIconUrl: l, resolveIconTooltip: u, resolveHref: d, resolveTaskBadge: f }) => i(() => r.map((r) => {
|
|
8
|
+
let i = c(r.id), p = n(r.id), m = p ? t(o, p) : void 0, h = p ? e(p.split("/").pop() ?? p) : "", g = f?.(r);
|
|
9
|
+
return {
|
|
10
|
+
id: i,
|
|
11
|
+
title: r.title,
|
|
12
|
+
isPinned: r.isPinned ?? !1,
|
|
13
|
+
iconUrl: l(m),
|
|
14
|
+
iconTooltip: u(m, h),
|
|
15
|
+
isIconLoading: s,
|
|
16
|
+
source: a(r),
|
|
17
|
+
href: d(i),
|
|
18
|
+
...g == null ? {} : {
|
|
19
|
+
showTaskBadge: !0,
|
|
20
|
+
taskBadgeLabel: g.label,
|
|
21
|
+
isUnread: g.isUnread
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}), [
|
|
25
|
+
r,
|
|
26
|
+
o,
|
|
27
|
+
s,
|
|
28
|
+
c,
|
|
29
|
+
l,
|
|
30
|
+
u,
|
|
31
|
+
d,
|
|
32
|
+
f
|
|
33
|
+
]);
|
|
34
|
+
//#endregion
|
|
35
|
+
export { a as getConversationSource, o as useConversationPanelItems };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { normalizeRawAnnotations as e } from "@epam/ai-dial-quotations";
|
|
2
|
+
//#region src/conversation/useConversationStream/apply-chunk.ts
|
|
3
|
+
var t = (e) => {
|
|
4
|
+
let t = e.target?.selector;
|
|
5
|
+
return t?.type === "html_tag" ? t.id : void 0;
|
|
6
|
+
}, n = (e, n) => {
|
|
7
|
+
if (e.index != null && n.index != null) return e.index === n.index;
|
|
8
|
+
let r = t(e), i = t(n);
|
|
9
|
+
return r != null && r === i;
|
|
10
|
+
}, r = (e, t) => {
|
|
11
|
+
let r = [...e];
|
|
12
|
+
for (let e of t) {
|
|
13
|
+
let t = r.findIndex((t) => n(t, e));
|
|
14
|
+
if (t >= 0) {
|
|
15
|
+
let n = r[t];
|
|
16
|
+
r[t] = {
|
|
17
|
+
...n,
|
|
18
|
+
...e,
|
|
19
|
+
body: {
|
|
20
|
+
...n.body,
|
|
21
|
+
...e.body,
|
|
22
|
+
title: (n.body?.title ?? "") + (e.body?.title ?? "") || void 0,
|
|
23
|
+
quote: (n.body?.quote ?? "") + (e.body?.quote ?? "") || void 0
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
} else r.push(e);
|
|
27
|
+
}
|
|
28
|
+
return r;
|
|
29
|
+
}, i = (e, t) => {
|
|
30
|
+
let n = [...e];
|
|
31
|
+
for (let e of t) {
|
|
32
|
+
let t = e.index == null ? -1 : n.findIndex((t) => t.index === e.index);
|
|
33
|
+
t >= 0 ? n[t] = {
|
|
34
|
+
...n[t],
|
|
35
|
+
...e,
|
|
36
|
+
title: (n[t].title ?? "") + (e.title ?? ""),
|
|
37
|
+
data: e.data == null ? n[t].data : (n[t].data ?? "") + e.data
|
|
38
|
+
} : n.push(e);
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
}, a = (e, t) => {
|
|
42
|
+
let n = [...e];
|
|
43
|
+
for (let e of t) {
|
|
44
|
+
let t = n.findIndex((t) => t.index === e.index);
|
|
45
|
+
t >= 0 ? n[t] = {
|
|
46
|
+
...n[t],
|
|
47
|
+
...e,
|
|
48
|
+
name: (n[t].name ?? "") + (e.name ?? ""),
|
|
49
|
+
content: (n[t].content ?? "") + (e.content ?? "") || void 0,
|
|
50
|
+
attachments: e.attachments?.length ? i(n[t].attachments ?? [], e.attachments) : n[t].attachments
|
|
51
|
+
} : n.push({
|
|
52
|
+
...e,
|
|
53
|
+
name: e.name ?? ""
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return n;
|
|
57
|
+
}, o = (t, n, i) => {
|
|
58
|
+
let o = i.choices[0]?.delta, s = o?.content ?? "", c = o?.custom_content?.form_schema, l = o?.custom_content?.attachments, u = o?.custom_content?.stages, d = o?.custom_content?.annotations, f = o?.custom_fields?.annotations, p = o?.custom_content?.state, m = !!s || !!c || !!l?.length || !!u?.length || !!d?.length || !!f?.length || !!p, h = o?.responseId ?? (m ? i.id : void 0);
|
|
59
|
+
return !m && !h ? null : t.map((t, i) => {
|
|
60
|
+
if (i !== n) return t;
|
|
61
|
+
let o = [...t.custom_content?.attachments ?? [], ...l ?? []], m = f?.length ? e(f, o) : [], g = [...d ?? [], ...m], _ = c || l?.length || u?.length || g.length || p;
|
|
62
|
+
return {
|
|
63
|
+
...t,
|
|
64
|
+
content: s ? t.content + s : t.content,
|
|
65
|
+
...h && { responseId: h },
|
|
66
|
+
..._ && { custom_content: {
|
|
67
|
+
...t.custom_content,
|
|
68
|
+
...c && { form_schema: c },
|
|
69
|
+
...l?.length && { attachments: o },
|
|
70
|
+
...u?.length && { stages: a(t.custom_content?.stages ?? [], u) },
|
|
71
|
+
...g.length && { annotations: r(t.custom_content?.annotations ?? [], g) },
|
|
72
|
+
...p && { state: p }
|
|
73
|
+
} }
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { o as applyChunkToMessages };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/conversation/useConversationStream/buffered-generation.ts
|
|
2
|
+
var e = (e, t) => ({
|
|
3
|
+
...e,
|
|
4
|
+
...t,
|
|
5
|
+
...(e.custom_content || t.custom_content) && { custom_content: {
|
|
6
|
+
...e.custom_content,
|
|
7
|
+
...t.custom_content
|
|
8
|
+
} }
|
|
9
|
+
}), t = (t, n) => {
|
|
10
|
+
if (n.messageIndex > t.messages.length) return t;
|
|
11
|
+
let r = [...t.messages];
|
|
12
|
+
return n.messageIndex === r.length ? r.push(n.message) : r[n.messageIndex] = e(r[n.messageIndex], n.message), {
|
|
13
|
+
...t,
|
|
14
|
+
messages: r
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { t as restoreBufferedMessage };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
+
//#region src/conversation/useConversationStream/conversation-path.ts
|
|
3
|
+
var t = (t) => {
|
|
4
|
+
let n = t.indexOf("/");
|
|
5
|
+
return e(n === -1 ? t : t.substring(n + 1));
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { t as getConversationPath };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
+
import { getConversationPath as t } from "./conversation-path.js";
|
|
3
|
+
import { applyChunkToMessages as n } from "./apply-chunk.js";
|
|
4
|
+
import { restoreBufferedMessage as r } from "./buffered-generation.js";
|
|
5
|
+
import { MessageRole as i } from "@epam/ai-dial-chat-shared";
|
|
6
|
+
//#region src/conversation/useConversationStream/generation-resume.ts
|
|
7
|
+
var a = (e) => {
|
|
8
|
+
let t = e.custom_content;
|
|
9
|
+
return !!e.content || e.responseId != null || !!t?.attachments?.length || !!t?.stages?.length || !!t?.annotations?.length || !!t?.form_schema || t?.state != null;
|
|
10
|
+
}, o = (e) => {
|
|
11
|
+
let t = e.messages[e.messages.length - 1];
|
|
12
|
+
return !!t && t.role === i.Assistant && !a(t) && t.streamErrorMessage == null && !t.wasStoppedByUser;
|
|
13
|
+
}, s = 300 * 1e3, c = "awaiting-resume", l = async (e, t) => {
|
|
14
|
+
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
15
|
+
try {
|
|
16
|
+
for (;;) {
|
|
17
|
+
let { done: e, value: a } = await n.read();
|
|
18
|
+
if (e) break;
|
|
19
|
+
i += r.decode(a, { stream: !0 });
|
|
20
|
+
let o = i.split("\n");
|
|
21
|
+
i = o.pop() ?? "";
|
|
22
|
+
let s = !1;
|
|
23
|
+
for (let e of o) {
|
|
24
|
+
let n = e.trim();
|
|
25
|
+
if (!n.startsWith("data:")) continue;
|
|
26
|
+
let r = n.slice(5).trim(), i;
|
|
27
|
+
try {
|
|
28
|
+
i = JSON.parse(r);
|
|
29
|
+
} catch {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (await t(i)) {
|
|
33
|
+
s = !0;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (s) break;
|
|
38
|
+
}
|
|
39
|
+
} catch {} finally {
|
|
40
|
+
n.releaseLock();
|
|
41
|
+
}
|
|
42
|
+
}, u = ({ transport: i, setConversation: a, conversationRef: u, resumingPathsRef: d, bufferedGenerationsRef: f, addStreamingPath: p, removeStreamingPath: m, isPathDisplayed: h }) => (g, _) => {
|
|
43
|
+
if (!o(_)) return;
|
|
44
|
+
let v = t(g);
|
|
45
|
+
if (d.current.has(v)) return;
|
|
46
|
+
d.current.add(v), p(v);
|
|
47
|
+
let y = _.messages.length - 1, b = (e) => {
|
|
48
|
+
d.current.delete(v), m(v), f.current.delete(v), e && h(v) && (a(e), u.current = e);
|
|
49
|
+
}, x = async () => {
|
|
50
|
+
try {
|
|
51
|
+
b(await i.getConversation(e(g)));
|
|
52
|
+
} catch {
|
|
53
|
+
b();
|
|
54
|
+
}
|
|
55
|
+
}, S = (e) => {
|
|
56
|
+
let t = {
|
|
57
|
+
generationId: c,
|
|
58
|
+
messageIndex: y,
|
|
59
|
+
message: e
|
|
60
|
+
};
|
|
61
|
+
f.current.set(v, t), h(v) && a((e) => {
|
|
62
|
+
if (!e) return e;
|
|
63
|
+
let n = r(e, t);
|
|
64
|
+
return u.current = n, n;
|
|
65
|
+
});
|
|
66
|
+
}, C = (e) => {
|
|
67
|
+
let t = f.current.get(v);
|
|
68
|
+
if (t?.generationId === c) {
|
|
69
|
+
let r = n([t.message], 0, e);
|
|
70
|
+
r && (t.message = r[0]);
|
|
71
|
+
}
|
|
72
|
+
h(v) && a((e) => {
|
|
73
|
+
if (!e) return e;
|
|
74
|
+
let t = f.current.get(v);
|
|
75
|
+
if (t?.generationId !== c) return e;
|
|
76
|
+
let n = r(e, t);
|
|
77
|
+
return u.current = n, n;
|
|
78
|
+
});
|
|
79
|
+
}, w = async () => {
|
|
80
|
+
let t = new AbortController(), n;
|
|
81
|
+
try {
|
|
82
|
+
n = await i.watchConversation(v, t.signal);
|
|
83
|
+
} catch {
|
|
84
|
+
await x();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let r = !1, a = window.setTimeout(() => {
|
|
88
|
+
t.abort();
|
|
89
|
+
}, s);
|
|
90
|
+
try {
|
|
91
|
+
await l(n, async (t) => {
|
|
92
|
+
if (t?.action !== "UPDATE") return !1;
|
|
93
|
+
try {
|
|
94
|
+
let t = await i.getConversation(e(g));
|
|
95
|
+
if (!o(t)) return b(t), r = !0, !0;
|
|
96
|
+
} catch {}
|
|
97
|
+
return !1;
|
|
98
|
+
});
|
|
99
|
+
} finally {
|
|
100
|
+
clearTimeout(a);
|
|
101
|
+
}
|
|
102
|
+
r || await x();
|
|
103
|
+
}, T = async () => {
|
|
104
|
+
let e = new AbortController(), t;
|
|
105
|
+
try {
|
|
106
|
+
t = await i.attachToGeneration(v, e.signal);
|
|
107
|
+
} catch {
|
|
108
|
+
return !1;
|
|
109
|
+
}
|
|
110
|
+
let n = !1;
|
|
111
|
+
return await l(t, (e) => {
|
|
112
|
+
switch (e.type) {
|
|
113
|
+
case "snapshot": return S(e.message), !1;
|
|
114
|
+
case "chunk": return C(e.chunk), !1;
|
|
115
|
+
case "done":
|
|
116
|
+
case "error":
|
|
117
|
+
case "stopped": return n = !0, !0;
|
|
118
|
+
}
|
|
119
|
+
}), n ? (await x(), !0) : !1;
|
|
120
|
+
};
|
|
121
|
+
(async () => {
|
|
122
|
+
await T() || await w();
|
|
123
|
+
})();
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
export { u as createResumeIfAwaitingGeneration, o as isAwaitingGenerationResume };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
+
import { getConversationPath as t } from "./conversation-path.js";
|
|
3
|
+
import { applyChunkToMessages as n } from "./apply-chunk.js";
|
|
4
|
+
import { restoreBufferedMessage as r } from "./buffered-generation.js";
|
|
5
|
+
import { createResumeIfAwaitingGeneration as i } from "./generation-resume.js";
|
|
6
|
+
import { generateUUID as a } from "@epam/ai-dial-chat-shared";
|
|
7
|
+
import { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
8
|
+
import { SendCompletionDtoModeEnum as d } from "@epam/ai-dial-chat-api-client";
|
|
9
|
+
//#region src/conversation/useConversationStream/useConversationStream.ts
|
|
10
|
+
var f = 2e4, p = ({ conversationId: p, state: { setConversation: m, conversationRef: h }, transport: g, generation: { startGeneration: _, completeGeneration: v }, channel: y, overlay: b, onStopError: x }) => {
|
|
11
|
+
let [S, C] = u(() => /* @__PURE__ */ new Set()), [w, T] = u(null), E = l(null), D = l(null), O = l(/* @__PURE__ */ new Set()), k = l(/* @__PURE__ */ new Map()), A = l(/* @__PURE__ */ new Set()), j = l(p);
|
|
12
|
+
s(() => {
|
|
13
|
+
j.current = p;
|
|
14
|
+
}, [p]);
|
|
15
|
+
let M = o((e) => t(j.current ?? "") === e, []), N = o((e) => {
|
|
16
|
+
C((t) => {
|
|
17
|
+
if (t.has(e)) return t;
|
|
18
|
+
let n = new Set(t);
|
|
19
|
+
return n.add(e), n;
|
|
20
|
+
});
|
|
21
|
+
}, []), P = o((e) => {
|
|
22
|
+
C((t) => {
|
|
23
|
+
if (!t.has(e)) return t;
|
|
24
|
+
let n = new Set(t);
|
|
25
|
+
return n.delete(e), n;
|
|
26
|
+
});
|
|
27
|
+
}, []), F = o((i, o, s, c, l, u, p = d.Append) => {
|
|
28
|
+
let x = u ?? a(), S = t(i);
|
|
29
|
+
E.current = x, D.current = S, T(S);
|
|
30
|
+
let C;
|
|
31
|
+
p === d.Regenerate ? C = s : p === d.Edit && (C = s - 1);
|
|
32
|
+
let w = _(S, x), O = h.current?.messages[s];
|
|
33
|
+
O ? k.current.set(S, {
|
|
34
|
+
generationId: x,
|
|
35
|
+
messageIndex: s,
|
|
36
|
+
message: O
|
|
37
|
+
}) : k.current.delete(S), N(S), b?.notifyGenerationStart?.(), y?.ensureConnected();
|
|
38
|
+
let j = {
|
|
39
|
+
signal: w.signal,
|
|
40
|
+
onChunk: (e) => {
|
|
41
|
+
if (E.current !== x) return;
|
|
42
|
+
let t = k.current.get(S);
|
|
43
|
+
if (t?.generationId === x) {
|
|
44
|
+
let r = n([t.message], 0, e);
|
|
45
|
+
r && (t.message = r[0]);
|
|
46
|
+
}
|
|
47
|
+
M(S) && m((t) => {
|
|
48
|
+
if (!t) return t;
|
|
49
|
+
let i = k.current.get(S), a;
|
|
50
|
+
if (i?.generationId === x) a = r(t, i);
|
|
51
|
+
else {
|
|
52
|
+
let r = n(t.messages, s, e);
|
|
53
|
+
if (!r) return t;
|
|
54
|
+
a = {
|
|
55
|
+
...t,
|
|
56
|
+
messages: r
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return h.current = a, a;
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
onComplete: async () => {
|
|
63
|
+
if (k.current.get(S)?.generationId === x && k.current.delete(S), P(S), E.current === x && (E.current = null, D.current = null, T(null)), v(S, x), y?.notifyGenerationSettled?.(), A.current.has(x) ? A.current.delete(x) : b?.notifyGenerationEnd?.(), M(S)) try {
|
|
64
|
+
let t = await g.getConversation(e(i));
|
|
65
|
+
if (!M(S)) return;
|
|
66
|
+
m(t), h.current = t;
|
|
67
|
+
} catch {}
|
|
68
|
+
},
|
|
69
|
+
onError: (e) => {
|
|
70
|
+
let t = k.current.get(S), n = t?.generationId === x ? t : void 0;
|
|
71
|
+
n && k.current.delete(S), P(S), E.current === x && (E.current = null, D.current = null, T(null)), v(S, x), y?.notifyGenerationSettled?.(), M(S) && m((t) => {
|
|
72
|
+
if (!t) return t;
|
|
73
|
+
let i = n?.generationId === x ? r(t, n) : t, a = {
|
|
74
|
+
...i,
|
|
75
|
+
messages: i.messages.map((t, n) => n === s ? {
|
|
76
|
+
...t,
|
|
77
|
+
streamErrorMessage: e.message
|
|
78
|
+
} : t)
|
|
79
|
+
};
|
|
80
|
+
return h.current = a, a;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
(async () => {
|
|
85
|
+
try {
|
|
86
|
+
let e = y?.channelId ?? await y?.waitForChannel(f) ?? void 0;
|
|
87
|
+
g.streamCompletion(S, o, c, j, l, x, p, C, e);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
j.onError(e instanceof Error ? e : Error(String(e)));
|
|
90
|
+
}
|
|
91
|
+
})();
|
|
92
|
+
}, [
|
|
93
|
+
_,
|
|
94
|
+
v,
|
|
95
|
+
N,
|
|
96
|
+
P,
|
|
97
|
+
M,
|
|
98
|
+
y?.channelId,
|
|
99
|
+
y?.ensureConnected,
|
|
100
|
+
y?.waitForChannel,
|
|
101
|
+
y?.notifyGenerationSettled,
|
|
102
|
+
b,
|
|
103
|
+
g
|
|
104
|
+
]), I = o((e, n) => {
|
|
105
|
+
let i = t(e), a = k.current.get(i);
|
|
106
|
+
return a ? r(n, a) : n;
|
|
107
|
+
}, []), L = o(() => {
|
|
108
|
+
let e = E.current;
|
|
109
|
+
if (!e || !p) return;
|
|
110
|
+
let n = t(p);
|
|
111
|
+
D.current === n && (A.current.add(e), b?.notifyStopGenerating?.(), g.stopCompletion({
|
|
112
|
+
generationId: e,
|
|
113
|
+
path: n
|
|
114
|
+
}).catch((e) => {
|
|
115
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
116
|
+
x?.(t);
|
|
117
|
+
}));
|
|
118
|
+
}, [
|
|
119
|
+
p,
|
|
120
|
+
x,
|
|
121
|
+
b,
|
|
122
|
+
g
|
|
123
|
+
]), R = c(() => i({
|
|
124
|
+
transport: g,
|
|
125
|
+
setConversation: m,
|
|
126
|
+
conversationRef: h,
|
|
127
|
+
resumingPathsRef: O,
|
|
128
|
+
bufferedGenerationsRef: k,
|
|
129
|
+
addStreamingPath: N,
|
|
130
|
+
removeStreamingPath: P,
|
|
131
|
+
isPathDisplayed: M
|
|
132
|
+
}), [
|
|
133
|
+
N,
|
|
134
|
+
P,
|
|
135
|
+
M,
|
|
136
|
+
g
|
|
137
|
+
]), z = p != null && S.has(t(p)), B = p == null ? null : t(p);
|
|
138
|
+
return {
|
|
139
|
+
startStream: F,
|
|
140
|
+
handleStop: L,
|
|
141
|
+
resumeIfAwaitingGeneration: R,
|
|
142
|
+
restoreBufferedGeneration: I,
|
|
143
|
+
isStreaming: z,
|
|
144
|
+
canStopStreaming: B != null && w === B
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
export { p as useConversationStream };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback as e, useLayoutEffect as t, useRef as n } from "react";
|
|
2
|
+
//#region src/conversation/useImportFilePicker/useImportFilePicker.ts
|
|
3
|
+
var r = ({ accept: r, onFileSelected: i }) => {
|
|
4
|
+
let a = n(null);
|
|
5
|
+
return t(() => {
|
|
6
|
+
let e = a.current;
|
|
7
|
+
e && (r === void 0 || r === "" ? e.removeAttribute("accept") : e.accept = r);
|
|
8
|
+
}, [r]), {
|
|
9
|
+
inputRef: a,
|
|
10
|
+
triggerImport: e(() => {
|
|
11
|
+
a.current?.click();
|
|
12
|
+
}, []),
|
|
13
|
+
handleFileChange: e((e) => {
|
|
14
|
+
let t = e.target.files?.[0];
|
|
15
|
+
e.target.value = "", t && i(t);
|
|
16
|
+
}, [i])
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { r as useImportFilePicker };
|