@epam/ai-dial-chat-hooks 1.1.0-dev.270 → 1.1.0-dev.277
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/conversation/conversation-transfer/import-conversation.d.ts.map +1 -1
- package/conversation/conversation-transfer/queue.d.ts.map +1 -1
- package/conversation/useConversationHandlers/useConversationHandlers.d.ts.map +1 -1
- package/conversation/useConversationImport/useConversationImport.d.ts.map +1 -1
- package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -1
- package/index.js +732 -732
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { AttachmentContentType as e, useAttachmentCanvas as t } from "@epam/ai-dial-attachment-canvas";
|
|
2
|
-
import { AttachmentErrorReason as n, HIDDEN_FILE as r, MIMEType as i, MessageRole as a, ResponseFormat as o, base64ToBlob as s,
|
|
3
|
-
import { isReferenceOnlyAttachment as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { isMimeTypeAllowed as
|
|
6
|
-
import { strFromU8 as
|
|
7
|
-
import { ArchiveItemDtoNodeTypeEnum as
|
|
8
|
-
import { DialFileManagerActions as
|
|
9
|
-
import { NOT_ALLOWED_SYMBOLS as te, NOT_ALLOWED_SYMBOLS_REGEXP as ne, NotificationVariant as
|
|
2
|
+
import { AttachmentErrorReason as n, HIDDEN_FILE as r, MIMEType as i, MessageRole as a, ResponseFormat as o, base64ToBlob as s, generateUUID as c, getUtf8ByteLength as l, messageAttachmentToDisplayAttachment as u, triggerAnchorDownload as d, triggerBlobDownload as f, truncateToUtf8Bytes as p } from "@epam/ai-dial-chat-shared";
|
|
3
|
+
import { isReferenceOnlyAttachment as m, normalizeRawAnnotations as h, parsePdfPageReference as g, resolveMessageAnnotations as _ } from "@epam/ai-dial-quotations";
|
|
4
|
+
import { useCallback as v, useEffect as y, useLayoutEffect as b, useMemo as x, useRef as S, useState as C } from "react";
|
|
5
|
+
import { isMimeTypeAllowed as w, mimeTypesToExtensionLabels as T } from "@epam/ai-dial-attachment-input";
|
|
6
|
+
import { strFromU8 as E, strToU8 as D, unzipSync as O, zipSync as k } from "fflate";
|
|
7
|
+
import { ArchiveItemDtoNodeTypeEnum as A, CopyItemDtoNodeTypeEnum as j, DeleteItemDtoNodeTypeEnum as M, ListFilesItemDtoNodeTypeEnum as N, MoveItemDtoNodeTypeEnum as P, RenameItemDtoNodeTypeEnum as F, SendCompletionDtoModeEnum as I, ShareLinkResponseDtoAccessEnum as L } from "@epam/ai-dial-chat-api-client";
|
|
8
|
+
import { DialFileManagerActions as R, DialFileManagerTabs as z, DialFileNodeType as B, DialFilePermission as ee, FileManagerColumnKey as V } from "@epam/ai-dial-react-file-manager";
|
|
9
|
+
import { NOT_ALLOWED_SYMBOLS as te, NOT_ALLOWED_SYMBOLS_REGEXP as ne, NotificationVariant as H } from "@epam/ai-dial-ui-kit";
|
|
10
10
|
import { ShareLinkAccess as re } from "@epam/ai-dial-share";
|
|
11
11
|
//#region src/attachment/useAttachmentAction/useAttachmentAction.ts
|
|
12
|
-
var
|
|
12
|
+
var ie = (e) => e.startsWith("files/"), ae = (e) => e.url != null && ie(e.url) || e.data != null, oe = (e, t) => {
|
|
13
13
|
let { url: n, name: r, contentType: a, data: o } = e;
|
|
14
|
-
if (n != null &&
|
|
14
|
+
if (n != null && ie(n)) {
|
|
15
15
|
let e = t(n);
|
|
16
|
-
return e == null ? !1 : (
|
|
16
|
+
return e == null ? !1 : (d(e, r), !0);
|
|
17
17
|
}
|
|
18
|
-
return o == null ? !1 : (
|
|
19
|
-
},
|
|
18
|
+
return o == null ? !1 : (f(s(o, a || i.Plain), r), !0);
|
|
19
|
+
}, se = (e, t) => {
|
|
20
20
|
let { url: n } = e;
|
|
21
21
|
if (n == null) return;
|
|
22
22
|
let r = n.split("#")[0];
|
|
23
|
-
if (
|
|
23
|
+
if (ie(r)) {
|
|
24
24
|
let n = t(r);
|
|
25
25
|
if (n == null) return;
|
|
26
|
-
|
|
26
|
+
d(n, e.title ?? r.split("/").pop() ?? "");
|
|
27
27
|
} else window.open(n, "_blank", "noopener,noreferrer");
|
|
28
|
-
},
|
|
29
|
-
let r =
|
|
28
|
+
}, ce = (t, n) => {
|
|
29
|
+
let r = g(t.url);
|
|
30
30
|
if (r == null) return null;
|
|
31
|
-
let i =
|
|
31
|
+
let i = ie(r.baseUrl) ? n(r.baseUrl) : r.baseUrl;
|
|
32
32
|
if (i == null) return null;
|
|
33
33
|
if (r.page == null) return {
|
|
34
34
|
type: e.Pdf,
|
|
@@ -54,12 +54,12 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
54
54
|
}],
|
|
55
55
|
selectedHighlightId: a
|
|
56
56
|
};
|
|
57
|
-
},
|
|
57
|
+
}, le = ({ resolveDownloadUrl: e }) => {
|
|
58
58
|
let { openCanvas: n } = t();
|
|
59
|
-
return { handleAttachmentClick:
|
|
59
|
+
return { handleAttachmentClick: v((t) => {
|
|
60
60
|
let { url: r, referenceUrl: i, data: a, name: o } = t;
|
|
61
61
|
if (r != null || a != null) {
|
|
62
|
-
|
|
62
|
+
oe(t, e);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (i == null) return;
|
|
@@ -67,34 +67,34 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
67
67
|
type: t.contentType,
|
|
68
68
|
url: i,
|
|
69
69
|
title: o
|
|
70
|
-
}, c =
|
|
70
|
+
}, c = ce(s, e);
|
|
71
71
|
if (c) {
|
|
72
72
|
n(c, o);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
se(s, e);
|
|
76
76
|
}, [n, e]) };
|
|
77
|
-
},
|
|
78
|
-
if (e != null) return e.map((e) => e === "*" ?
|
|
79
|
-
},
|
|
80
|
-
let t =
|
|
81
|
-
if (!(t == null || t.length === 0) && !t.some((e) => e ===
|
|
82
|
-
},
|
|
77
|
+
}, ue = 100, de = "*/*", fe = (e) => e.startsWith(".") || e.includes("/"), pe = (e) => {
|
|
78
|
+
if (e != null) return e.map((e) => e === "*" ? de : e).filter(fe);
|
|
79
|
+
}, me = (e) => {
|
|
80
|
+
let t = pe(e);
|
|
81
|
+
if (!(t == null || t.length === 0) && !t.some((e) => e === de)) return t.join(",");
|
|
82
|
+
}, he = /* @__PURE__ */ function(e) {
|
|
83
83
|
return e.NoTypesAllowed = "noTypesAllowed", e.UnsupportedType = "unsupportedType", e;
|
|
84
|
-
}({}),
|
|
85
|
-
let i = e.length > 0, a =
|
|
86
|
-
return
|
|
84
|
+
}({}), ge = ({ allowedMimeTypes: e, onValidationError: t, debounceMs: r = ue }) => {
|
|
85
|
+
let i = e.length > 0, a = x(() => me(e), [e]), o = S(null);
|
|
86
|
+
return y(() => () => {
|
|
87
87
|
o.current != null && clearTimeout(o.current);
|
|
88
88
|
}, []), {
|
|
89
89
|
inputAttachmentTypes: e,
|
|
90
90
|
isAttachmentsAllowed: i,
|
|
91
|
-
validateAttachment:
|
|
92
|
-
if (!
|
|
91
|
+
validateAttachment: v((i) => {
|
|
92
|
+
if (!w(i.contentType, e)) return o.current != null && clearTimeout(o.current), o.current = setTimeout(() => {
|
|
93
93
|
let n = e.length === 0;
|
|
94
94
|
t?.({
|
|
95
95
|
reason: n ? "noTypesAllowed" : "unsupportedType",
|
|
96
96
|
allowedMimeTypes: e,
|
|
97
|
-
...n ? {} : { formats:
|
|
97
|
+
...n ? {} : { formats: T(e) }
|
|
98
98
|
}), o.current = null;
|
|
99
99
|
}, r), n.UnsupportedType;
|
|
100
100
|
}, [
|
|
@@ -104,35 +104,35 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
104
104
|
]),
|
|
105
105
|
fileAccept: a
|
|
106
106
|
};
|
|
107
|
-
},
|
|
107
|
+
}, _e = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, ve = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, ye = /* @__PURE__ */ function(e) {
|
|
108
108
|
return e.WithAttachments = "withAttachments", e.WithoutAttachments = "withoutAttachments", e;
|
|
109
109
|
}({}), U = /* @__PURE__ */ function(e) {
|
|
110
110
|
return e.SingleConversation = "chat_conversation", e.SingleConversationWithAttachments = "chat_with_attachments", e.AllConversationsHistory = "chat_conversations_history", e;
|
|
111
111
|
}({}), W = /* @__PURE__ */ function(e) {
|
|
112
112
|
return e.InProgress = "inProgress", e.Success = "success", e.Failed = "failed", e;
|
|
113
|
-
}({}),
|
|
113
|
+
}({}), be = /* @__PURE__ */ function(e) {
|
|
114
114
|
return e.Single = "single", e.All = "all", e;
|
|
115
115
|
}({}), G = /* @__PURE__ */ function(e) {
|
|
116
116
|
return e.Unauthorized = "unauthorized", e.NotFound = "notFound", e.UnsupportedFormat = "unsupportedFormat", e.MissingBucket = "missingBucket", e.Unknown = "unknown", e;
|
|
117
|
-
}({}),
|
|
117
|
+
}({}), xe = /* @__PURE__ */ function(e) {
|
|
118
118
|
return e.AttachmentSkipped = "attachmentSkipped", e;
|
|
119
|
-
}({}),
|
|
119
|
+
}({}), Se = "ai_dial", Ce = (e, t = []) => ({
|
|
120
120
|
version: 5,
|
|
121
121
|
history: e,
|
|
122
122
|
folders: t
|
|
123
|
-
}),
|
|
123
|
+
}), we = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), Te = {
|
|
124
124
|
[U.SingleConversation]: "json",
|
|
125
125
|
[U.SingleConversationWithAttachments]: "dial",
|
|
126
126
|
[U.AllConversationsHistory]: "json"
|
|
127
|
-
},
|
|
127
|
+
}, Ee = (e, t, n = /* @__PURE__ */ new Date()) => `${_e(n)}_${t}_${e}.${Te[e]}`, De = (e) => e.startsWith("files/"), Oe = (e) => {
|
|
128
128
|
let t = /* @__PURE__ */ new Set();
|
|
129
129
|
for (let n of e.messages) for (let e of n.custom_content?.attachments ?? []) {
|
|
130
130
|
let n = e.url ?? e.reference_url;
|
|
131
|
-
n != null &&
|
|
131
|
+
n != null && De(n) && t.add(n);
|
|
132
132
|
}
|
|
133
133
|
return Array.from(t, (e) => ({ fileId: e }));
|
|
134
|
-
},
|
|
135
|
-
if (!
|
|
134
|
+
}, ke = (e) => e.startsWith("files/"), Ae = (e) => {
|
|
135
|
+
if (!ke(e)) return;
|
|
136
136
|
let t = e.slice(6), n = t.indexOf("/");
|
|
137
137
|
if (n < 0) return;
|
|
138
138
|
let r = t.slice(0, n), i = t.slice(n + 1), a;
|
|
@@ -145,47 +145,47 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
145
145
|
bucket: r,
|
|
146
146
|
path: a
|
|
147
147
|
};
|
|
148
|
-
},
|
|
148
|
+
}, je = class extends Error {
|
|
149
149
|
constructor(e) {
|
|
150
150
|
super(e), this.name = "UnsupportedImportFormatError";
|
|
151
151
|
}
|
|
152
|
-
},
|
|
152
|
+
}, Me = (e) => typeof e == "object" && !!e, Ne = 5, Pe = (e) => {
|
|
153
153
|
let t;
|
|
154
154
|
try {
|
|
155
155
|
t = JSON.parse(e);
|
|
156
156
|
} catch {
|
|
157
|
-
throw new
|
|
157
|
+
throw new je("Import file is not valid JSON");
|
|
158
158
|
}
|
|
159
|
-
if (!
|
|
159
|
+
if (!Me(t) || t.version !== Ne || !Array.isArray(t.history)) throw new je("Import file is not a supported export format");
|
|
160
160
|
let n = Array.isArray(t.folders) ? t.folders : [];
|
|
161
161
|
return {
|
|
162
|
-
version:
|
|
162
|
+
version: Ne,
|
|
163
163
|
history: t.history,
|
|
164
164
|
folders: n
|
|
165
165
|
};
|
|
166
|
-
},
|
|
166
|
+
}, Fe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, Ie = (e) => {
|
|
167
167
|
let t = e.lastIndexOf("__");
|
|
168
168
|
if (t < 0) return e;
|
|
169
169
|
let n = e.slice(t + 2);
|
|
170
|
-
return
|
|
171
|
-
},
|
|
172
|
-
let n =
|
|
170
|
+
return Fe.test(n) ? e.slice(0, t) : e;
|
|
171
|
+
}, Le = "conversations/", Re = (e) => e.startsWith(Le) ? e.slice(14) : e, ze = (e, t) => {
|
|
172
|
+
let n = Re(e.id), r = n.split("/"), i = Re(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), l = s.slice(0, -1), u = `${Ie(s.at(-1) ?? r.at(-1) ?? n)}__${c()}`, d = [
|
|
173
173
|
...o,
|
|
174
|
-
...
|
|
175
|
-
|
|
176
|
-
].join("/"),
|
|
174
|
+
...l,
|
|
175
|
+
u
|
|
176
|
+
].join("/"), f = o.length ? `${t}/${o.join("/")}` : t;
|
|
177
177
|
return {
|
|
178
178
|
conversation: {
|
|
179
179
|
...e,
|
|
180
|
-
id: `${t}/${
|
|
181
|
-
folderId:
|
|
180
|
+
id: `${t}/${d}`,
|
|
181
|
+
folderId: f
|
|
182
182
|
},
|
|
183
|
-
subPath:
|
|
183
|
+
subPath: d
|
|
184
184
|
};
|
|
185
|
-
},
|
|
186
|
-
let t =
|
|
185
|
+
}, Be = (e) => {
|
|
186
|
+
let t = Re(e.folderId).split("/").filter(Boolean).slice(1);
|
|
187
187
|
return t.length ? t.join(" / ") : void 0;
|
|
188
|
-
},
|
|
188
|
+
}, Ve = (e) => e.map((e) => `"${e}"`).join(", "), He = (e, t) => ({
|
|
189
189
|
...e,
|
|
190
190
|
messages: e.messages.map((e) => {
|
|
191
191
|
let n = e.custom_content?.attachments;
|
|
@@ -207,12 +207,12 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
207
207
|
}
|
|
208
208
|
} : e;
|
|
209
209
|
})
|
|
210
|
-
}),
|
|
210
|
+
}), Ue = (e) => e.split("/").pop() || e, We = (e, t, n) => {
|
|
211
211
|
let r = [], i = [];
|
|
212
|
-
for (let a of
|
|
213
|
-
let e =
|
|
212
|
+
for (let a of Oe(e)) {
|
|
213
|
+
let e = Ae(a.fileId);
|
|
214
214
|
if (!e) {
|
|
215
|
-
i.push(
|
|
215
|
+
i.push(Ue(a.fileId));
|
|
216
216
|
continue;
|
|
217
217
|
}
|
|
218
218
|
let o = e.path.split("/").pop() ?? e.path, s = t.get(e.path);
|
|
@@ -231,14 +231,14 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
231
231
|
plan: r,
|
|
232
232
|
skippedNames: i
|
|
233
233
|
};
|
|
234
|
-
},
|
|
235
|
-
let a =
|
|
236
|
-
return { handleUploadAttachment:
|
|
234
|
+
}, Ge = 700, Ke = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", qe = (e, t = /* @__PURE__ */ new Date()) => `uploads/${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}/${encodeURIComponent(Ke(e))}`, Je = ({ filesApi: e, bucket: t, onNetworkError: r, debounceMs: i = Ge }) => {
|
|
235
|
+
let a = S([]), o = S(null);
|
|
236
|
+
return { handleUploadAttachment: v(async (s) => {
|
|
237
237
|
if (!t) throw Error("User bucket is not available");
|
|
238
238
|
try {
|
|
239
239
|
return (await e.uploadFile({
|
|
240
240
|
bucket: t,
|
|
241
|
-
path:
|
|
241
|
+
path: qe(s.name),
|
|
242
242
|
file: s.file
|
|
243
243
|
})).url;
|
|
244
244
|
} catch (e) {
|
|
@@ -258,7 +258,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
258
258
|
e,
|
|
259
259
|
r
|
|
260
260
|
]) };
|
|
261
|
-
},
|
|
261
|
+
}, Ye = async (e, t, n) => {
|
|
262
262
|
let r = [], i = 0, a = async () => {
|
|
263
263
|
let t = i;
|
|
264
264
|
if (i += 1, !(t >= e.length)) {
|
|
@@ -272,34 +272,34 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
274
|
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
275
|
-
},
|
|
276
|
-
let [e, t] =
|
|
275
|
+
}, Xe = () => {
|
|
276
|
+
let [e, t] = C([]), n = S(/* @__PURE__ */ new Map()), r = S(/* @__PURE__ */ new Map()), i = v((e, n) => {
|
|
277
277
|
t((t) => t.map((t) => t.id === e ? {
|
|
278
278
|
...t,
|
|
279
279
|
...n
|
|
280
280
|
} : t));
|
|
281
|
-
}, []), a =
|
|
282
|
-
let n =
|
|
281
|
+
}, []), a = v((e) => {
|
|
282
|
+
let n = c();
|
|
283
283
|
return t((t) => [...t, {
|
|
284
284
|
id: n,
|
|
285
285
|
subject: e,
|
|
286
286
|
status: W.InProgress
|
|
287
287
|
}]), n;
|
|
288
|
-
}, []), o =
|
|
288
|
+
}, []), o = v((e) => {
|
|
289
289
|
n.current.get(e)?.abort(), n.current.delete(e), r.current.delete(e), t((t) => t.filter((t) => t.id !== e));
|
|
290
|
-
}, []), s =
|
|
290
|
+
}, []), s = v((e) => {
|
|
291
291
|
r.current.get(e)?.();
|
|
292
|
-
}, []),
|
|
292
|
+
}, []), l = v(() => {
|
|
293
293
|
for (let e of n.current.values()) e.abort();
|
|
294
294
|
n.current.clear(), r.current.clear(), t([]);
|
|
295
|
-
}, []),
|
|
295
|
+
}, []), u = v((e, t) => {
|
|
296
296
|
let a = () => {
|
|
297
297
|
let r = new AbortController();
|
|
298
298
|
return n.current.set(e, r), t(r.signal);
|
|
299
299
|
};
|
|
300
300
|
return r.current.set(e, () => (i(e, { status: W.InProgress }), a())), a();
|
|
301
301
|
}, [i]);
|
|
302
|
-
return
|
|
302
|
+
return y(() => {
|
|
303
303
|
let e = n.current;
|
|
304
304
|
return () => {
|
|
305
305
|
for (let t of e.values()) t.abort();
|
|
@@ -310,30 +310,30 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
310
310
|
updateJob: i,
|
|
311
311
|
dismissJob: o,
|
|
312
312
|
retryJob: s,
|
|
313
|
-
dismissAll:
|
|
314
|
-
startJob:
|
|
313
|
+
dismissAll: l,
|
|
314
|
+
startJob: u
|
|
315
315
|
};
|
|
316
|
-
},
|
|
317
|
-
let n = [], r = { "conversation.json":
|
|
316
|
+
}, Ze = D("", !0).constructor, Qe = (e) => e instanceof Ze ? e : new Ze(e), $e = (e) => e.length > 0 && e.split("/").every((e) => e !== "" && e !== "." && e !== ".."), et = (e, t) => {
|
|
317
|
+
let n = [], r = { "conversation.json": Qe(D(JSON.stringify(e, null, 2))) };
|
|
318
318
|
for (let e of t) {
|
|
319
|
-
if (
|
|
319
|
+
if (!$e(e.path)) {
|
|
320
320
|
n.push(e.path);
|
|
321
321
|
continue;
|
|
322
322
|
}
|
|
323
|
-
r[`res/${e.path}`] =
|
|
323
|
+
r[`res/${e.path}`] = Qe(e.data);
|
|
324
324
|
}
|
|
325
|
-
let i =
|
|
325
|
+
let i = k(r);
|
|
326
326
|
return {
|
|
327
327
|
blob: new Blob([new Uint8Array(i)], { type: "application/zip" }),
|
|
328
328
|
skippedPaths: n
|
|
329
329
|
};
|
|
330
|
-
},
|
|
331
|
-
let c =
|
|
330
|
+
}, tt = 5, nt = (e) => !e.sharedWithMe && !e.publishedWithMe, rt = ({ conversationsApi: e, filesApi: t, normalizeConversationPath: n, classifyTransferError: r = () => ({}), resolveErrorTraceId: i = async () => void 0, onSuccess: a, onWarning: o, onError: s }) => {
|
|
331
|
+
let c = Xe(), l = v(async (e, n) => {
|
|
332
332
|
let i = !1, a = !1;
|
|
333
333
|
return {
|
|
334
|
-
entries: await
|
|
334
|
+
entries: await Ye(e, tt, async (e) => {
|
|
335
335
|
if (n.aborted || a) return;
|
|
336
|
-
let o =
|
|
336
|
+
let o = Ae(e.fileId);
|
|
337
337
|
if (!o) {
|
|
338
338
|
i = !0;
|
|
339
339
|
return;
|
|
@@ -360,7 +360,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
360
360
|
anySkipped: !n.aborted && !a && i,
|
|
361
361
|
isUnauthorized: !n.aborted && a
|
|
362
362
|
};
|
|
363
|
-
}, [r, t]), u =
|
|
363
|
+
}, [r, t]), u = v(async (t, u, d, p, m) => {
|
|
364
364
|
let h;
|
|
365
365
|
try {
|
|
366
366
|
h = await e.getConversation({ path: n(u) }, { signal: m });
|
|
@@ -375,7 +375,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
375
375
|
s?.({
|
|
376
376
|
jobId: t,
|
|
377
377
|
code: G.Unknown,
|
|
378
|
-
titles: [
|
|
378
|
+
titles: [d],
|
|
379
379
|
traceId: n
|
|
380
380
|
});
|
|
381
381
|
}
|
|
@@ -383,14 +383,14 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
385
|
if (!m.aborted) try {
|
|
386
|
-
if (p ===
|
|
387
|
-
|
|
386
|
+
if (p === ye.WithoutAttachments) {
|
|
387
|
+
f(we(Ce([h], [])), Ee(U.SingleConversation, Se)), a?.({
|
|
388
388
|
jobId: t,
|
|
389
|
-
titles: [
|
|
389
|
+
titles: [d]
|
|
390
390
|
}), c.updateJob(t, { status: W.Success });
|
|
391
391
|
return;
|
|
392
392
|
}
|
|
393
|
-
let { entries: e, anySkipped: n, isUnauthorized: r } = await l(
|
|
393
|
+
let { entries: e, anySkipped: n, isUnauthorized: r } = await l(Oe(h), m);
|
|
394
394
|
if (m.aborted) return;
|
|
395
395
|
if (r) {
|
|
396
396
|
s?.({
|
|
@@ -399,13 +399,13 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
399
399
|
}), c.updateJob(t, { status: W.Failed });
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
|
-
let { blob: i, skippedPaths: u } =
|
|
402
|
+
let { blob: i, skippedPaths: u } = et(Ce([h], []), e);
|
|
403
403
|
(n || u.length > 0) && o?.({
|
|
404
404
|
jobId: t,
|
|
405
|
-
code:
|
|
406
|
-
}),
|
|
405
|
+
code: xe.AttachmentSkipped
|
|
406
|
+
}), f(i, Ee(U.SingleConversationWithAttachments, Se)), a?.({
|
|
407
407
|
jobId: t,
|
|
408
|
-
titles: [
|
|
408
|
+
titles: [d]
|
|
409
409
|
}), c.updateJob(t, { status: W.Success });
|
|
410
410
|
} catch (e) {
|
|
411
411
|
if (m.aborted) return;
|
|
@@ -413,7 +413,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
413
413
|
s?.({
|
|
414
414
|
jobId: t,
|
|
415
415
|
code: G.Unknown,
|
|
416
|
-
titles: [
|
|
416
|
+
titles: [d],
|
|
417
417
|
traceId: n
|
|
418
418
|
}), c.updateJob(t, { status: W.Failed }), console.error("Failed to build conversation export archive", e);
|
|
419
419
|
}
|
|
@@ -427,13 +427,13 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
427
427
|
o,
|
|
428
428
|
c,
|
|
429
429
|
i
|
|
430
|
-
]),
|
|
430
|
+
]), d = v((e, t, n) => {
|
|
431
431
|
let r = c.addJob({
|
|
432
|
-
kind:
|
|
432
|
+
kind: be.Single,
|
|
433
433
|
title: t
|
|
434
434
|
});
|
|
435
435
|
return c.startJob(r, (i) => u(r, e, t, n, i));
|
|
436
|
-
}, [c, u]), p =
|
|
436
|
+
}, [c, u]), p = v(async (t, o) => {
|
|
437
437
|
let l = [], u;
|
|
438
438
|
do {
|
|
439
439
|
if (o.aborted) return;
|
|
@@ -457,17 +457,17 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
457
457
|
c.updateJob(t, { status: W.Failed }), console.error("Failed to list conversations for export", e);
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
460
|
-
l.push(...n.items.filter(
|
|
460
|
+
l.push(...n.items.filter(nt).map((e) => ({
|
|
461
461
|
id: e.id,
|
|
462
462
|
title: e.title
|
|
463
463
|
}))), u = n.nextToken;
|
|
464
464
|
} while (u);
|
|
465
|
-
let
|
|
465
|
+
let d = [];
|
|
466
466
|
for (let a of l) {
|
|
467
467
|
if (o.aborted) return;
|
|
468
468
|
try {
|
|
469
469
|
let t = await e.getConversation({ path: n(a.id) }, { signal: o });
|
|
470
|
-
|
|
470
|
+
d.push(t);
|
|
471
471
|
} catch (e) {
|
|
472
472
|
if (o.aborted) return;
|
|
473
473
|
let n = r(e);
|
|
@@ -498,7 +498,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
if (!o.aborted) try {
|
|
501
|
-
|
|
501
|
+
f(we(Ce(d, [])), Ee(U.AllConversationsHistory, Se)), a?.({ jobId: t }), c.updateJob(t, { status: W.Success });
|
|
502
502
|
} catch (e) {
|
|
503
503
|
let n = await i(e);
|
|
504
504
|
s?.({
|
|
@@ -515,28 +515,28 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
515
515
|
a,
|
|
516
516
|
c,
|
|
517
517
|
i
|
|
518
|
-
]), m =
|
|
519
|
-
let e = c.addJob({ kind:
|
|
518
|
+
]), m = v(() => {
|
|
519
|
+
let e = c.addJob({ kind: be.All });
|
|
520
520
|
return c.startJob(e, (t) => p(e, t));
|
|
521
521
|
}, [c, p]);
|
|
522
522
|
return {
|
|
523
523
|
jobs: c.jobs,
|
|
524
|
-
exportSingle:
|
|
524
|
+
exportSingle: d,
|
|
525
525
|
exportAll: m,
|
|
526
526
|
dismissJob: c.dismissJob,
|
|
527
527
|
retryJob: c.retryJob,
|
|
528
528
|
dismissAll: c.dismissAll
|
|
529
529
|
};
|
|
530
|
-
},
|
|
530
|
+
}, it = (e) => {
|
|
531
531
|
if (!e.url) throw Error(`Attachment "${e.name}" has not been uploaded`);
|
|
532
532
|
return {
|
|
533
533
|
type: e.contentType,
|
|
534
534
|
title: e.name,
|
|
535
535
|
url: e.url
|
|
536
536
|
};
|
|
537
|
-
},
|
|
538
|
-
if (e.length) return e.map(
|
|
539
|
-
},
|
|
537
|
+
}, at = (e) => {
|
|
538
|
+
if (e.length) return e.map(it);
|
|
539
|
+
}, ot = (e, t, n) => {
|
|
540
540
|
let r = new Date(Date.now()).toISOString();
|
|
541
541
|
return {
|
|
542
542
|
userMessage: {
|
|
@@ -552,17 +552,17 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
552
552
|
...n ? { deploymentId: n } : {}
|
|
553
553
|
}
|
|
554
554
|
};
|
|
555
|
-
},
|
|
555
|
+
}, st = (e) => e != null && Object.keys(e).length > 0, ct = (e, t, n, r) => {
|
|
556
556
|
if (t !== e.content || r.length > 0) return !0;
|
|
557
557
|
let i = e.custom_content?.attachments?.length ?? 0;
|
|
558
558
|
return n.length !== i;
|
|
559
|
-
},
|
|
559
|
+
}, lt = (e) => e["dial:widgetOptions"].populateText || e.title, ut = (e, t) => {
|
|
560
560
|
let { populateText: n } = e["dial:widgetOptions"];
|
|
561
|
-
return n == null && t ? t :
|
|
562
|
-
},
|
|
561
|
+
return n == null && t ? t : lt(e);
|
|
562
|
+
}, dt = (e, t) => {
|
|
563
563
|
let { populateText: n, submit: r } = e["dial:widgetOptions"];
|
|
564
|
-
return r && n == null ? "" : t ??
|
|
565
|
-
},
|
|
564
|
+
return r && n == null ? "" : t ?? lt(e);
|
|
565
|
+
}, ft = (e) => {
|
|
566
566
|
try {
|
|
567
567
|
return decodeURIComponent(e);
|
|
568
568
|
} catch {
|
|
@@ -570,43 +570,43 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
570
570
|
}
|
|
571
571
|
}, K = (e) => {
|
|
572
572
|
let t = e.indexOf("/");
|
|
573
|
-
return
|
|
574
|
-
},
|
|
575
|
-
let [
|
|
576
|
-
filesApi:
|
|
573
|
+
return ft(t === -1 ? e : e.substring(t + 1));
|
|
574
|
+
}, pt = ({ conversation: e, conversationId: t, bucket: n, isStreaming: r, startStream: i, state: { setConversation: o, conversationRef: s }, filesApi: l, conversationsApi: u, rateApi: d, resolveModelId: f, onConversationDeleted: p, showNetworkError: m, toolConfigurationValue: h }) => {
|
|
575
|
+
let [g, _] = C(null), [y, b] = C(/* @__PURE__ */ new Set()), [x, S] = C(null), { handleUploadAttachment: w } = Je({
|
|
576
|
+
filesApi: l,
|
|
577
577
|
bucket: n,
|
|
578
|
-
onNetworkError:
|
|
579
|
-
}),
|
|
578
|
+
onNetworkError: m
|
|
579
|
+
}), T = v(async (n, r) => {
|
|
580
580
|
if (!t || !e) return;
|
|
581
|
-
let a =
|
|
581
|
+
let a = at(r), l = st(h), u = a?.length || l ? {
|
|
582
582
|
...a?.length ? { attachments: a } : {},
|
|
583
|
-
...
|
|
584
|
-
} : void 0,
|
|
583
|
+
...l ? { configuration_value: h } : {}
|
|
584
|
+
} : void 0, d = f(), { userMessage: p, assistantMessage: m } = ot(n, u, d);
|
|
585
585
|
o((e) => {
|
|
586
586
|
if (!e) return e;
|
|
587
587
|
let t = {
|
|
588
588
|
...e,
|
|
589
589
|
messages: [
|
|
590
590
|
...e.messages,
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
p,
|
|
592
|
+
m
|
|
593
593
|
]
|
|
594
594
|
};
|
|
595
595
|
return s.current = t, t;
|
|
596
|
-
}), i(t, n, e.messages.length + 1,
|
|
596
|
+
}), i(t, n, e.messages.length + 1, d, u, c(), I.Append);
|
|
597
597
|
}, [
|
|
598
598
|
e,
|
|
599
599
|
t,
|
|
600
600
|
s,
|
|
601
|
-
|
|
601
|
+
f,
|
|
602
602
|
o,
|
|
603
603
|
i,
|
|
604
|
-
|
|
605
|
-
]),
|
|
604
|
+
h
|
|
605
|
+
]), E = v((n) => {
|
|
606
606
|
if (r || !t || !e || n === -1 || e.messages[n]?.role !== a.Assistant) return;
|
|
607
|
-
let
|
|
608
|
-
if (!
|
|
609
|
-
let
|
|
607
|
+
let l = e.messages[n - 1];
|
|
608
|
+
if (!l || l.role !== a.User) return;
|
|
609
|
+
let u = f();
|
|
610
610
|
o((e) => {
|
|
611
611
|
if (!e) return e;
|
|
612
612
|
let t = {
|
|
@@ -616,38 +616,38 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
616
616
|
wasStoppedByUser: void 0,
|
|
617
617
|
stoppedWithoutContent: void 0,
|
|
618
618
|
streamErrorMessage: void 0,
|
|
619
|
-
deploymentId:
|
|
619
|
+
deploymentId: u
|
|
620
620
|
}, r = {
|
|
621
621
|
...e,
|
|
622
622
|
messages: [...e.messages.slice(0, n), t]
|
|
623
623
|
};
|
|
624
624
|
return s.current = r, r;
|
|
625
|
-
}),
|
|
625
|
+
}), b((e) => new Set([...e].filter((e) => e < n))), i(t, l.content, n, u, l.custom_content, c(), I.Regenerate);
|
|
626
626
|
}, [
|
|
627
627
|
e,
|
|
628
628
|
t,
|
|
629
629
|
s,
|
|
630
630
|
r,
|
|
631
|
-
|
|
631
|
+
f,
|
|
632
632
|
o,
|
|
633
633
|
i
|
|
634
|
-
]),
|
|
635
|
-
r ||
|
|
636
|
-
}, [r]),
|
|
637
|
-
if (!t ||
|
|
638
|
-
|
|
634
|
+
]), D = v((e) => {
|
|
635
|
+
r || _(e);
|
|
636
|
+
}, [r]), O = v(() => {
|
|
637
|
+
if (!t || g == null) return;
|
|
638
|
+
_(null);
|
|
639
639
|
let e = K(t);
|
|
640
640
|
o((t) => {
|
|
641
641
|
if (!t) return t;
|
|
642
|
-
let n =
|
|
642
|
+
let n = g;
|
|
643
643
|
if (n === -1) return t;
|
|
644
644
|
let r = t.messages[n + 1]?.role === a.Assistant ? t.messages.filter((e, t) => t !== n && t !== n + 1) : t.messages.filter((e, t) => t !== n);
|
|
645
|
-
if (r.length === 0 || r.length === 1 && r[0].role === a.Status) return
|
|
645
|
+
if (r.length === 0 || r.length === 1 && r[0].role === a.Status) return u.deleteConversation({ path: e }), p?.(), t;
|
|
646
646
|
let i = {
|
|
647
647
|
...t,
|
|
648
648
|
messages: r
|
|
649
649
|
};
|
|
650
|
-
return s.current = i,
|
|
650
|
+
return s.current = i, u.saveConversation({
|
|
651
651
|
path: e,
|
|
652
652
|
saveConversationBodyDto: { conversation: i }
|
|
653
653
|
}), i;
|
|
@@ -655,22 +655,22 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
655
655
|
}, [
|
|
656
656
|
t,
|
|
657
657
|
s,
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
658
|
+
u,
|
|
659
|
+
p,
|
|
660
|
+
g,
|
|
661
661
|
o
|
|
662
|
-
]),
|
|
662
|
+
]), k = v(async (n, r, i) => {
|
|
663
663
|
if (!t || !e) return !1;
|
|
664
664
|
let a = e.messages[n];
|
|
665
665
|
if (!a) return !1;
|
|
666
|
-
let c = a.rating,
|
|
666
|
+
let c = a.rating, l = {
|
|
667
667
|
...e,
|
|
668
668
|
messages: e.messages.map((e, t) => t === n ? {
|
|
669
669
|
...e,
|
|
670
670
|
rating: r ?? void 0
|
|
671
671
|
} : e)
|
|
672
672
|
};
|
|
673
|
-
o(() => (s.current =
|
|
673
|
+
o(() => (s.current = l, l));
|
|
674
674
|
let f = K(t), p = () => {
|
|
675
675
|
o((e) => e && {
|
|
676
676
|
...e,
|
|
@@ -679,15 +679,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
679
679
|
rating: c
|
|
680
680
|
} : e)
|
|
681
681
|
});
|
|
682
|
-
}, m = () =>
|
|
682
|
+
}, m = () => u.saveConversation({
|
|
683
683
|
path: f,
|
|
684
|
-
saveConversationBodyDto: { conversation:
|
|
684
|
+
saveConversationBodyDto: { conversation: l }
|
|
685
685
|
});
|
|
686
686
|
if (r != null) {
|
|
687
687
|
let t = a.responseId;
|
|
688
688
|
if (!t) return p(), !1;
|
|
689
689
|
try {
|
|
690
|
-
return await
|
|
690
|
+
return await d.rateMessage({ rateMessageDto: {
|
|
691
691
|
conversationId: e.id,
|
|
692
692
|
responseId: t,
|
|
693
693
|
modelId: e.model.id,
|
|
@@ -706,135 +706,135 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
706
706
|
e,
|
|
707
707
|
t,
|
|
708
708
|
s,
|
|
709
|
-
l,
|
|
710
709
|
u,
|
|
710
|
+
d,
|
|
711
711
|
o
|
|
712
|
-
]),
|
|
712
|
+
]), A = v((n, r, a) => {
|
|
713
713
|
if (!t || !e) return;
|
|
714
|
-
let
|
|
715
|
-
...
|
|
716
|
-
...
|
|
717
|
-
} : void 0,
|
|
714
|
+
let l = a ?? n.title, u = dt(n, a), d = r ? { [r]: n.const } : void 0, p = st(h), m = d || p ? {
|
|
715
|
+
...d ? { form_value: d } : {},
|
|
716
|
+
...p ? { configuration_value: h } : {}
|
|
717
|
+
} : void 0, g = f(), { userMessage: _, assistantMessage: v } = ot(l, m, g);
|
|
718
718
|
o((e) => {
|
|
719
719
|
if (!e) return e;
|
|
720
720
|
let t = {
|
|
721
721
|
...e,
|
|
722
722
|
messages: [
|
|
723
723
|
...e.messages,
|
|
724
|
-
|
|
725
|
-
|
|
724
|
+
_,
|
|
725
|
+
v
|
|
726
726
|
]
|
|
727
727
|
};
|
|
728
728
|
return s.current = t, t;
|
|
729
|
-
}), i(t,
|
|
729
|
+
}), i(t, u, e.messages.length + 1, g, m, c(), I.Append);
|
|
730
730
|
}, [
|
|
731
731
|
e,
|
|
732
732
|
t,
|
|
733
733
|
s,
|
|
734
|
-
|
|
734
|
+
f,
|
|
735
735
|
o,
|
|
736
736
|
i,
|
|
737
|
-
|
|
737
|
+
h
|
|
738
738
|
]);
|
|
739
739
|
return {
|
|
740
|
-
handleSend:
|
|
741
|
-
handleUploadAttachment:
|
|
742
|
-
handleRegenerateMessage:
|
|
743
|
-
handleDeleteMessage:
|
|
744
|
-
handleConfirmDelete:
|
|
745
|
-
handleRateMessage:
|
|
746
|
-
handleButtonSelect:
|
|
747
|
-
!t || !e || r || (n["dial:widgetOptions"].confirmationMessage ?
|
|
740
|
+
handleSend: T,
|
|
741
|
+
handleUploadAttachment: w,
|
|
742
|
+
handleRegenerateMessage: E,
|
|
743
|
+
handleDeleteMessage: D,
|
|
744
|
+
handleConfirmDelete: O,
|
|
745
|
+
handleRateMessage: k,
|
|
746
|
+
handleButtonSelect: v((n, i, a) => {
|
|
747
|
+
!t || !e || r || (n["dial:widgetOptions"].confirmationMessage ? S({
|
|
748
748
|
starter: n,
|
|
749
749
|
propertyKey: i,
|
|
750
750
|
description: a
|
|
751
|
-
}) :
|
|
751
|
+
}) : A(n, i, a));
|
|
752
752
|
}, [
|
|
753
753
|
e,
|
|
754
754
|
t,
|
|
755
755
|
r,
|
|
756
|
-
|
|
756
|
+
A
|
|
757
757
|
]),
|
|
758
|
-
handleConfirmStarter:
|
|
759
|
-
if (!
|
|
760
|
-
let { starter: e, propertyKey: t, description: n } =
|
|
761
|
-
|
|
762
|
-
}, [
|
|
763
|
-
handleStartEdit:
|
|
764
|
-
|
|
758
|
+
handleConfirmStarter: v(() => {
|
|
759
|
+
if (!x) return;
|
|
760
|
+
let { starter: e, propertyKey: t, description: n } = x;
|
|
761
|
+
S(null), A(e, t, n);
|
|
762
|
+
}, [x, A]),
|
|
763
|
+
handleStartEdit: v((e) => {
|
|
764
|
+
b((t) => new Set([...t, e]));
|
|
765
765
|
}, []),
|
|
766
|
-
handleCancelEdit:
|
|
767
|
-
|
|
766
|
+
handleCancelEdit: v((e) => {
|
|
767
|
+
b((t) => {
|
|
768
768
|
let n = new Set(t);
|
|
769
769
|
return n.delete(e), n;
|
|
770
770
|
});
|
|
771
771
|
}, []),
|
|
772
|
-
handleEditMessage:
|
|
772
|
+
handleEditMessage: v(async (n, l, u, d) => {
|
|
773
773
|
if (r || !t || !e) return;
|
|
774
|
-
let
|
|
775
|
-
if (
|
|
776
|
-
let
|
|
777
|
-
if (!
|
|
778
|
-
|
|
774
|
+
let p = n;
|
|
775
|
+
if (p === -1 || e.messages[p].role !== a.User) return;
|
|
776
|
+
let m = e.messages[p];
|
|
777
|
+
if (!ct(m, l, u, d)) {
|
|
778
|
+
b((e) => {
|
|
779
779
|
let t = new Set(e);
|
|
780
|
-
return t.delete(
|
|
780
|
+
return t.delete(p), t;
|
|
781
781
|
});
|
|
782
782
|
return;
|
|
783
783
|
}
|
|
784
|
-
let
|
|
784
|
+
let h = at(d), g = new Set(u.map((e) => e.id)), _ = [...(m.custom_content?.attachments ?? []).filter((e) => {
|
|
785
785
|
let t = e.url ?? e.data ?? e.title;
|
|
786
|
-
return
|
|
787
|
-
}), ...
|
|
788
|
-
...
|
|
789
|
-
attachments:
|
|
790
|
-
} : Object.keys(
|
|
791
|
-
...
|
|
792
|
-
content:
|
|
793
|
-
custom_content:
|
|
794
|
-
},
|
|
786
|
+
return g.has(t);
|
|
787
|
+
}), ...h ?? []], { attachments: v, ...y } = m.custom_content ?? {}, x = _.length > 0 ? {
|
|
788
|
+
...y,
|
|
789
|
+
attachments: _
|
|
790
|
+
} : Object.keys(y).length > 0 ? y : void 0, S = {
|
|
791
|
+
...m,
|
|
792
|
+
content: l,
|
|
793
|
+
custom_content: x
|
|
794
|
+
}, C = Date.now(), w = {
|
|
795
795
|
role: a.Assistant,
|
|
796
796
|
content: "",
|
|
797
|
-
timestamp: new Date(
|
|
798
|
-
},
|
|
799
|
-
...e.messages.slice(0,
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
],
|
|
797
|
+
timestamp: new Date(C).toISOString()
|
|
798
|
+
}, T = [
|
|
799
|
+
...e.messages.slice(0, p),
|
|
800
|
+
S,
|
|
801
|
+
w
|
|
802
|
+
], E = {
|
|
803
803
|
...e,
|
|
804
|
-
messages:
|
|
804
|
+
messages: T
|
|
805
805
|
};
|
|
806
|
-
o(() => (s.current =
|
|
807
|
-
let
|
|
808
|
-
i(t,
|
|
806
|
+
o(() => (s.current = E, E));
|
|
807
|
+
let D = f();
|
|
808
|
+
i(t, l, T.length - 1, D, x, c(), I.Edit), b(/* @__PURE__ */ new Set());
|
|
809
809
|
}, [
|
|
810
810
|
e,
|
|
811
811
|
t,
|
|
812
812
|
s,
|
|
813
813
|
r,
|
|
814
|
-
|
|
814
|
+
f,
|
|
815
815
|
o,
|
|
816
816
|
i
|
|
817
817
|
]),
|
|
818
|
-
editingMessageIndexes:
|
|
819
|
-
pendingDeleteIndex:
|
|
820
|
-
setPendingDeleteIndex:
|
|
821
|
-
pendingStarterContext:
|
|
822
|
-
setPendingStarterContext:
|
|
818
|
+
editingMessageIndexes: y,
|
|
819
|
+
pendingDeleteIndex: g,
|
|
820
|
+
setPendingDeleteIndex: _,
|
|
821
|
+
pendingStarterContext: x,
|
|
822
|
+
setPendingStarterContext: S
|
|
823
823
|
};
|
|
824
|
-
},
|
|
824
|
+
}, mt = (e) => {
|
|
825
825
|
let t = e.lastIndexOf("."), n = t > 0;
|
|
826
826
|
return {
|
|
827
827
|
base: n ? e.slice(0, t) : e,
|
|
828
828
|
extension: n ? e.slice(t) : ""
|
|
829
829
|
};
|
|
830
|
-
},
|
|
830
|
+
}, ht = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", gt = (e, t, n) => n === 0 ? `${e}${t}` : `${e} (${n})${t}`, _t = (e) => {
|
|
831
831
|
let t = e?.date ?? /* @__PURE__ */ new Date(), n = new Set(e?.existingNames);
|
|
832
832
|
return {
|
|
833
833
|
allocate: (e) => {
|
|
834
|
-
let { base: r, extension: i } =
|
|
835
|
-
for (; n.has(o);) a += 1, o =
|
|
834
|
+
let { base: r, extension: i } = mt(ht(e)), a = 0, o = gt(r, i, a);
|
|
835
|
+
for (; n.has(o);) a += 1, o = gt(r, i, a);
|
|
836
836
|
return n.add(o), {
|
|
837
|
-
path: `uploads/${
|
|
837
|
+
path: `uploads/${ve(t)}/${encodeURIComponent(o)}`,
|
|
838
838
|
fileName: o,
|
|
839
839
|
isRenamed: a > 0
|
|
840
840
|
};
|
|
@@ -843,34 +843,34 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
843
843
|
n.add(e);
|
|
844
844
|
}
|
|
845
845
|
};
|
|
846
|
-
},
|
|
846
|
+
}, vt = "conversation.json", yt = /^conversations\/.*\.json$/, bt = "res/", xt = (e) => e.find((e) => e === vt) ?? e.find((e) => yt.test(e)) ?? e.find((e) => !e.includes("/") && e.toLowerCase().endsWith(".json")), St = (e) => new Promise((t, n) => {
|
|
847
847
|
let r = new FileReader();
|
|
848
848
|
r.onload = () => t(new Uint8Array(r.result)), r.onerror = () => n(r.error), r.readAsArrayBuffer(e);
|
|
849
|
-
}),
|
|
850
|
-
let t = await
|
|
849
|
+
}), Ct = async (e) => {
|
|
850
|
+
let t = await St(e), n;
|
|
851
851
|
try {
|
|
852
|
-
n =
|
|
852
|
+
n = O(t);
|
|
853
853
|
} catch {
|
|
854
|
-
throw new
|
|
854
|
+
throw new je("Import file is not a valid archive");
|
|
855
855
|
}
|
|
856
|
-
let r = Object.keys(n), i =
|
|
857
|
-
if (!i) throw new
|
|
858
|
-
let a =
|
|
856
|
+
let r = Object.keys(n), i = xt(r);
|
|
857
|
+
if (!i) throw new je("Archive does not contain a readable conversation-JSON entry");
|
|
858
|
+
let a = Pe(E(n[i])), o = /* @__PURE__ */ new Map();
|
|
859
859
|
for (let e of r) {
|
|
860
|
-
if (e.endsWith("/") || !e.startsWith(
|
|
860
|
+
if (e.endsWith("/") || !e.startsWith(bt)) continue;
|
|
861
861
|
let t = e.slice(4);
|
|
862
|
-
!t ||
|
|
862
|
+
!t || !$e(t) || o.set(t, n[e]);
|
|
863
863
|
}
|
|
864
864
|
return {
|
|
865
865
|
envelope: a,
|
|
866
866
|
attachments: o
|
|
867
867
|
};
|
|
868
|
-
},
|
|
868
|
+
}, wt = 5, Tt = 5, Et = (e) => /\.(dial|zip)$/i.test(e.name), Dt = (e) => new Promise((t, n) => {
|
|
869
869
|
let r = new FileReader();
|
|
870
870
|
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsText(e);
|
|
871
|
-
}),
|
|
872
|
-
if (
|
|
873
|
-
let { envelope: t, attachments: n } = await
|
|
871
|
+
}), Ot = async (e) => {
|
|
872
|
+
if (Et(e)) {
|
|
873
|
+
let { envelope: t, attachments: n } = await Ct(e);
|
|
874
874
|
return {
|
|
875
875
|
history: t.history,
|
|
876
876
|
attachments: n,
|
|
@@ -878,15 +878,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
878
878
|
};
|
|
879
879
|
}
|
|
880
880
|
return {
|
|
881
|
-
history:
|
|
881
|
+
history: Pe(await Dt(e)).history,
|
|
882
882
|
attachments: /* @__PURE__ */ new Map(),
|
|
883
883
|
isArchive: !1
|
|
884
884
|
};
|
|
885
|
-
},
|
|
886
|
-
let { plan: s, skippedNames: c } =
|
|
885
|
+
}, kt = async (e, t, n, r, i, a, o) => {
|
|
886
|
+
let { plan: s, skippedNames: c } = We(e, t, r), l = !1, u = await Ye(s, wt, async (e) => {
|
|
887
887
|
if (o.aborted || l) return;
|
|
888
888
|
let t = e.allocated;
|
|
889
|
-
for (let s = 0; s <=
|
|
889
|
+
for (let s = 0; s <= Tt; s += 1) try {
|
|
890
890
|
let r = new File([new Uint8Array(e.bytes)], t.fileName), a = await i.uploadFile({
|
|
891
891
|
bucket: n,
|
|
892
892
|
path: t.path,
|
|
@@ -905,7 +905,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
905
905
|
l = !0;
|
|
906
906
|
return;
|
|
907
907
|
}
|
|
908
|
-
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || s ===
|
|
908
|
+
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || s === Tt) return {
|
|
909
909
|
kind: "skipped",
|
|
910
910
|
name: e.originalFileName
|
|
911
911
|
};
|
|
@@ -925,18 +925,18 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
925
925
|
skippedNames: o.aborted || l ? [] : f,
|
|
926
926
|
isUnauthorized: !o.aborted && l
|
|
927
927
|
};
|
|
928
|
-
},
|
|
929
|
-
let
|
|
928
|
+
}, At = ({ conversationsApi: e, filesApi: t, bucket: n, onImported: r, classifyTransferError: i = () => ({}), resolveErrorTraceId: a = async () => void 0, onSuccess: o, onWarning: s, onError: l }) => {
|
|
929
|
+
let u = Xe(), d = v(async (c, d, f) => {
|
|
930
930
|
if (!n) {
|
|
931
|
-
|
|
932
|
-
jobId:
|
|
931
|
+
l?.({
|
|
932
|
+
jobId: c,
|
|
933
933
|
code: G.MissingBucket
|
|
934
|
-
}),
|
|
934
|
+
}), u.updateJob(c, { status: W.Failed });
|
|
935
935
|
return;
|
|
936
936
|
}
|
|
937
937
|
let p = [], m = [], h = [], g = !1, _, v = /* @__PURE__ */ new Date(), y = (e) => !!i(e).isUnauthorized, b;
|
|
938
938
|
if (d.isArchive) {
|
|
939
|
-
let e = `uploads/${
|
|
939
|
+
let e = `uploads/${ve(v)}`, r = [];
|
|
940
940
|
try {
|
|
941
941
|
r = (await t.listFiles({
|
|
942
942
|
bucket: n,
|
|
@@ -945,15 +945,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
945
945
|
} catch (e) {
|
|
946
946
|
if (f.aborted) return;
|
|
947
947
|
if (y(e)) {
|
|
948
|
-
|
|
949
|
-
jobId:
|
|
948
|
+
l?.({
|
|
949
|
+
jobId: c,
|
|
950
950
|
code: G.Unauthorized
|
|
951
|
-
}),
|
|
951
|
+
}), u.updateJob(c, { status: W.Failed });
|
|
952
952
|
return;
|
|
953
953
|
}
|
|
954
954
|
console.error("Failed to list the upload folder for attachment name disambiguation", e);
|
|
955
955
|
}
|
|
956
|
-
b =
|
|
956
|
+
b = _t({
|
|
957
957
|
date: v,
|
|
958
958
|
existingNames: r
|
|
959
959
|
});
|
|
@@ -964,7 +964,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
964
964
|
try {
|
|
965
965
|
let i = /* @__PURE__ */ new Map();
|
|
966
966
|
if (d.isArchive && b) {
|
|
967
|
-
let e = await
|
|
967
|
+
let e = await kt(r, d.attachments, n, b, t, y, f);
|
|
968
968
|
if (f.aborted) return;
|
|
969
969
|
if (e.isUnauthorized) {
|
|
970
970
|
g = !0;
|
|
@@ -972,7 +972,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
972
972
|
}
|
|
973
973
|
e.skippedNames.length > 0 && h.push(...e.skippedNames), i = e.targetMap;
|
|
974
974
|
}
|
|
975
|
-
let { conversation: a, subPath: o } =
|
|
975
|
+
let { conversation: a, subPath: o } = ze(He(r, i), n);
|
|
976
976
|
if (await e.saveConversation({
|
|
977
977
|
path: o,
|
|
978
978
|
saveConversationBodyDto: { conversation: {
|
|
@@ -992,10 +992,10 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
992
992
|
}
|
|
993
993
|
if (!f.aborted) {
|
|
994
994
|
if (g) {
|
|
995
|
-
|
|
996
|
-
jobId:
|
|
995
|
+
l?.({
|
|
996
|
+
jobId: c,
|
|
997
997
|
code: G.Unauthorized
|
|
998
|
-
}),
|
|
998
|
+
}), u.updateJob(c, { status: W.Failed });
|
|
999
999
|
return;
|
|
1000
1000
|
}
|
|
1001
1001
|
if (p.length > 0) {
|
|
@@ -1003,126 +1003,126 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1003
1003
|
await r?.();
|
|
1004
1004
|
} catch {}
|
|
1005
1005
|
o?.({
|
|
1006
|
-
jobId:
|
|
1006
|
+
jobId: c,
|
|
1007
1007
|
titles: p
|
|
1008
1008
|
});
|
|
1009
1009
|
}
|
|
1010
|
-
m.length > 0 &&
|
|
1011
|
-
jobId:
|
|
1010
|
+
m.length > 0 && l?.({
|
|
1011
|
+
jobId: c,
|
|
1012
1012
|
code: G.Unknown,
|
|
1013
1013
|
titles: m,
|
|
1014
1014
|
traceId: _
|
|
1015
1015
|
}), h.length > 0 && s?.({
|
|
1016
|
-
jobId:
|
|
1017
|
-
code:
|
|
1016
|
+
jobId: c,
|
|
1017
|
+
code: xe.AttachmentSkipped,
|
|
1018
1018
|
names: h
|
|
1019
|
-
}),
|
|
1019
|
+
}), u.updateJob(c, { status: m.length > 0 ? W.Failed : W.Success });
|
|
1020
1020
|
}
|
|
1021
1021
|
}, [
|
|
1022
1022
|
n,
|
|
1023
1023
|
i,
|
|
1024
1024
|
e,
|
|
1025
1025
|
t,
|
|
1026
|
-
|
|
1026
|
+
l,
|
|
1027
1027
|
r,
|
|
1028
1028
|
o,
|
|
1029
1029
|
s,
|
|
1030
|
-
|
|
1030
|
+
u,
|
|
1031
1031
|
a
|
|
1032
|
-
]),
|
|
1032
|
+
]), f = v(async (e) => {
|
|
1033
1033
|
let t;
|
|
1034
1034
|
try {
|
|
1035
|
-
t = await
|
|
1035
|
+
t = await Ot(e);
|
|
1036
1036
|
} catch (e) {
|
|
1037
|
-
|
|
1038
|
-
jobId:
|
|
1037
|
+
l?.({
|
|
1038
|
+
jobId: c(),
|
|
1039
1039
|
code: G.UnsupportedFormat
|
|
1040
|
-
}), e instanceof
|
|
1040
|
+
}), e instanceof je || console.error("Failed to parse import file", e);
|
|
1041
1041
|
return;
|
|
1042
1042
|
}
|
|
1043
|
-
let n = t.history.length > 1, r = t.history[0], i = n ? { kind:
|
|
1044
|
-
kind:
|
|
1043
|
+
let n = t.history.length > 1, r = t.history[0], i = n ? { kind: be.All } : {
|
|
1044
|
+
kind: be.Single,
|
|
1045
1045
|
title: r?.name ?? e.name,
|
|
1046
|
-
sourceBreadcrumb: r ?
|
|
1047
|
-
}, a =
|
|
1048
|
-
return
|
|
1046
|
+
sourceBreadcrumb: r ? Be(r) : void 0
|
|
1047
|
+
}, a = u.addJob(i);
|
|
1048
|
+
return u.startJob(a, (e) => d(a, t, e));
|
|
1049
1049
|
}, [
|
|
1050
|
-
c,
|
|
1051
1050
|
l,
|
|
1052
|
-
u
|
|
1051
|
+
u,
|
|
1052
|
+
d
|
|
1053
1053
|
]);
|
|
1054
1054
|
return {
|
|
1055
|
-
jobs:
|
|
1056
|
-
importConversations:
|
|
1057
|
-
dismissJob:
|
|
1058
|
-
retryJob:
|
|
1059
|
-
dismissAll:
|
|
1055
|
+
jobs: u.jobs,
|
|
1056
|
+
importConversations: f,
|
|
1057
|
+
dismissJob: u.dismissJob,
|
|
1058
|
+
retryJob: u.retryJob,
|
|
1059
|
+
dismissAll: u.dismissAll
|
|
1060
1060
|
};
|
|
1061
|
-
},
|
|
1062
|
-
let [r, i] =
|
|
1061
|
+
}, jt = 80, Mt = 1, Nt = ({ messages: e, isAssistantTyping: t, conversationId: n }) => {
|
|
1062
|
+
let [r, i] = C(!1), a = S(null), o = S(null), s = S(null), c = S(!1), l = S(!1), u = S(null), d = S(/* @__PURE__ */ new Map()), f = v((e, t) => {
|
|
1063
1063
|
t ? d.current.set(e, t) : d.current.delete(e);
|
|
1064
|
-
}, []), p =
|
|
1064
|
+
}, []), p = S(null), m = v((e) => {
|
|
1065
1065
|
p.current = e;
|
|
1066
|
-
}, []), h =
|
|
1066
|
+
}, []), h = v((e, t) => {
|
|
1067
1067
|
let n = a.current;
|
|
1068
1068
|
n && n.scrollTo({
|
|
1069
1069
|
top: e,
|
|
1070
1070
|
behavior: t ? "instant" : "smooth"
|
|
1071
1071
|
});
|
|
1072
|
-
}, []), g =
|
|
1072
|
+
}, []), g = v(() => {
|
|
1073
1073
|
s.current && (s.current.style.height = "0px"), c.current = !1, l.current = !1, u.current = null;
|
|
1074
|
-
}, []),
|
|
1074
|
+
}, []), _ = v(() => {
|
|
1075
1075
|
let e = a.current, t = o.current;
|
|
1076
1076
|
if (!e || !t) return null;
|
|
1077
1077
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1078
1078
|
return e.scrollTop + (r.bottom - n.top) - e.clientHeight;
|
|
1079
|
-
}, []),
|
|
1080
|
-
let t =
|
|
1079
|
+
}, []), x = v((e = !1) => {
|
|
1080
|
+
let t = _();
|
|
1081
1081
|
t != null && h(Math.max(t, 0), e);
|
|
1082
|
-
}, [h,
|
|
1082
|
+
}, [h, _]), w = v(() => {
|
|
1083
1083
|
let e = a.current, t = o.current;
|
|
1084
1084
|
if (!e || !t) return null;
|
|
1085
1085
|
let n = e.getBoundingClientRect();
|
|
1086
1086
|
return t.getBoundingClientRect().bottom - n.top - e.clientHeight;
|
|
1087
|
-
}, []), T =
|
|
1087
|
+
}, []), T = v(() => {
|
|
1088
1088
|
if (!l.current) return;
|
|
1089
1089
|
let e = w();
|
|
1090
1090
|
e == null || e < -1 || g();
|
|
1091
|
-
}, [g, w]), E =
|
|
1091
|
+
}, [g, w]), E = v((e) => {
|
|
1092
1092
|
let t = a.current, n = d.current.get(e);
|
|
1093
1093
|
if (!t || !n) return null;
|
|
1094
1094
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), o = t.scrollTop + (i.top - r.top);
|
|
1095
1095
|
return Math.max(o, 0);
|
|
1096
|
-
}, []), D =
|
|
1096
|
+
}, []), D = v((e, t = !1) => {
|
|
1097
1097
|
let n = E(e);
|
|
1098
1098
|
n != null && h(n, t);
|
|
1099
|
-
}, [E, h]), O =
|
|
1100
|
-
let e =
|
|
1099
|
+
}, [E, h]), O = v(() => {
|
|
1100
|
+
let e = _();
|
|
1101
1101
|
return e == null ? null : Math.max(e, 0);
|
|
1102
|
-
}, [
|
|
1102
|
+
}, [_]), k = v(() => {
|
|
1103
1103
|
if (!c.current) return null;
|
|
1104
1104
|
let e = u.current, t = O();
|
|
1105
1105
|
return e == null || t == null ? null : Math.max(e, t);
|
|
1106
|
-
}, [O]), A =
|
|
1106
|
+
}, [O]), A = v(() => {
|
|
1107
1107
|
let e = a.current, t = k();
|
|
1108
|
-
!e || t == null || e.scrollTop > t +
|
|
1109
|
-
}, [k]), j =
|
|
1108
|
+
!e || t == null || e.scrollTop > t + Mt && (e.scrollTop = t);
|
|
1109
|
+
}, [k]), j = v((e) => {
|
|
1110
1110
|
let t = s.current, n = O();
|
|
1111
1111
|
if (!t || n == null) return;
|
|
1112
1112
|
let r = Math.max(e - n, 0);
|
|
1113
1113
|
t.style.height = `${r}px`, c.current = r > 0, l.current = !1, u.current = r > 0 ? e : null;
|
|
1114
|
-
}, [O]), M =
|
|
1114
|
+
}, [O]), M = v((e) => {
|
|
1115
1115
|
let t = E(e);
|
|
1116
1116
|
t != null && (j(t), D(e, !1));
|
|
1117
1117
|
}, [
|
|
1118
1118
|
j,
|
|
1119
1119
|
E,
|
|
1120
1120
|
D
|
|
1121
|
-
]), N =
|
|
1121
|
+
]), N = v(() => {
|
|
1122
1122
|
let e = w();
|
|
1123
|
-
e != null && i(e >=
|
|
1124
|
-
}, [w]), P =
|
|
1125
|
-
|
|
1123
|
+
e != null && i(e >= jt);
|
|
1124
|
+
}, [w]), P = S(e.length), F = S(null);
|
|
1125
|
+
b(() => {
|
|
1126
1126
|
let r = e.length !== P.current, i = n !== F.current, a = () => {
|
|
1127
1127
|
P.current = e.length, F.current = n;
|
|
1128
1128
|
};
|
|
@@ -1132,28 +1132,28 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1132
1132
|
p.current = null, M(o), a();
|
|
1133
1133
|
return;
|
|
1134
1134
|
}
|
|
1135
|
-
t || ((r || i) &&
|
|
1135
|
+
t || ((r || i) && x(!1), a());
|
|
1136
1136
|
}, [
|
|
1137
1137
|
e,
|
|
1138
1138
|
t,
|
|
1139
1139
|
n,
|
|
1140
|
-
|
|
1140
|
+
x,
|
|
1141
1141
|
M,
|
|
1142
1142
|
g
|
|
1143
|
-
]),
|
|
1143
|
+
]), b(() => {
|
|
1144
1144
|
!t && c.current && (l.current = !0, T());
|
|
1145
1145
|
}, [t, T]);
|
|
1146
|
-
let I =
|
|
1146
|
+
let I = v(() => {
|
|
1147
1147
|
A(), T(), N();
|
|
1148
1148
|
}, [
|
|
1149
1149
|
A,
|
|
1150
1150
|
T,
|
|
1151
1151
|
N
|
|
1152
1152
|
]);
|
|
1153
|
-
return
|
|
1153
|
+
return y(() => {
|
|
1154
1154
|
let e = a.current;
|
|
1155
1155
|
if (e) return e.addEventListener("scroll", I, { passive: !0 }), () => e.removeEventListener("scroll", I);
|
|
1156
|
-
}, [I]),
|
|
1156
|
+
}, [I]), y(() => {
|
|
1157
1157
|
let e = o.current;
|
|
1158
1158
|
if (!e) return;
|
|
1159
1159
|
let t = new ResizeObserver(() => {
|
|
@@ -1170,15 +1170,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1170
1170
|
spacerRef: s,
|
|
1171
1171
|
setMessageRef: f,
|
|
1172
1172
|
isScrollButtonVisible: r,
|
|
1173
|
-
scrollToBottom:
|
|
1174
|
-
|
|
1175
|
-
}, [
|
|
1173
|
+
scrollToBottom: v(() => {
|
|
1174
|
+
x(!1);
|
|
1175
|
+
}, [x]),
|
|
1176
1176
|
armAnchor: m
|
|
1177
1177
|
};
|
|
1178
|
-
},
|
|
1178
|
+
}, Pt = (e) => {
|
|
1179
1179
|
let t = e.messages[e.messages.length - 1];
|
|
1180
1180
|
return !!t && t.role === a.Assistant && !t.content && t.streamErrorMessage == null && !t.wasStoppedByUser;
|
|
1181
|
-
},
|
|
1181
|
+
}, Ft = (e, t) => {
|
|
1182
1182
|
let n = [...e];
|
|
1183
1183
|
for (let e of t) {
|
|
1184
1184
|
let t = n.findIndex((t) => t.index === e.index);
|
|
@@ -1197,7 +1197,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1197
1197
|
} else n.push(e);
|
|
1198
1198
|
}
|
|
1199
1199
|
return n;
|
|
1200
|
-
},
|
|
1200
|
+
}, It = (e, t) => {
|
|
1201
1201
|
let n = [...e];
|
|
1202
1202
|
for (let e of t) {
|
|
1203
1203
|
let t = e.index == null ? -1 : n.findIndex((t) => t.index === e.index);
|
|
@@ -1209,7 +1209,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1209
1209
|
} : n.push(e);
|
|
1210
1210
|
}
|
|
1211
1211
|
return n;
|
|
1212
|
-
},
|
|
1212
|
+
}, Lt = (e, t) => {
|
|
1213
1213
|
let n = [...e];
|
|
1214
1214
|
for (let e of t) {
|
|
1215
1215
|
let t = n.findIndex((t) => t.index === e.index);
|
|
@@ -1218,61 +1218,61 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1218
1218
|
...e,
|
|
1219
1219
|
name: (n[t].name ?? "") + (e.name ?? ""),
|
|
1220
1220
|
content: (n[t].content ?? "") + (e.content ?? "") || void 0,
|
|
1221
|
-
attachments: e.attachments?.length ?
|
|
1221
|
+
attachments: e.attachments?.length ? It(n[t].attachments ?? [], e.attachments) : n[t].attachments
|
|
1222
1222
|
} : n.push({
|
|
1223
1223
|
...e,
|
|
1224
1224
|
name: e.name ?? ""
|
|
1225
1225
|
});
|
|
1226
1226
|
}
|
|
1227
1227
|
return n;
|
|
1228
|
-
},
|
|
1228
|
+
}, Rt = (e, t, n) => {
|
|
1229
1229
|
let r = n.choices[0]?.delta, i = r?.content ?? "", a = r?.custom_content?.form_schema, o = r?.custom_content?.attachments, s = r?.custom_content?.stages, c = r?.custom_content?.annotations, l = r?.custom_fields?.annotations, u = r?.custom_content?.state, d = !!i || !!a || !!o?.length || !!s?.length || !!c?.length || !!l?.length || !!u, f = r?.responseId ?? (d ? n.id : void 0);
|
|
1230
1230
|
return !d && !f ? null : e.map((e, n) => {
|
|
1231
1231
|
if (n !== t) return e;
|
|
1232
|
-
let r = [...e.custom_content?.attachments ?? [], ...o ?? []], d = l?.length ?
|
|
1232
|
+
let r = [...e.custom_content?.attachments ?? [], ...o ?? []], d = l?.length ? h(l, r) : [], p = [...c ?? [], ...d], m = a || o?.length || s?.length || p.length || u;
|
|
1233
1233
|
return {
|
|
1234
1234
|
...e,
|
|
1235
1235
|
content: i ? e.content + i : e.content,
|
|
1236
1236
|
...f && { responseId: f },
|
|
1237
|
-
...
|
|
1237
|
+
...m && { custom_content: {
|
|
1238
1238
|
...e.custom_content,
|
|
1239
1239
|
...a && { form_schema: a },
|
|
1240
1240
|
...o?.length && { attachments: r },
|
|
1241
|
-
...s?.length && { stages:
|
|
1242
|
-
...p.length && { annotations:
|
|
1241
|
+
...s?.length && { stages: Lt(e.custom_content?.stages ?? [], s) },
|
|
1242
|
+
...p.length && { annotations: Ft(e.custom_content?.annotations ?? [], p) },
|
|
1243
1243
|
...u && { state: u }
|
|
1244
1244
|
} }
|
|
1245
1245
|
};
|
|
1246
1246
|
});
|
|
1247
|
-
},
|
|
1248
|
-
let [
|
|
1249
|
-
|
|
1250
|
-
|
|
1247
|
+
}, zt = 300 * 1e3, Bt = ({ conversationId: e, state: { setConversation: t, conversationRef: n }, transport: r, generation: { startGeneration: i, completeGeneration: a }, channel: o, overlay: s, onStopError: l }) => {
|
|
1248
|
+
let [u, d] = C(() => /* @__PURE__ */ new Set()), [f, p] = C(null), m = S(null), h = S(null), g = S(/* @__PURE__ */ new Set()), _ = S(/* @__PURE__ */ new Set()), b = S(e);
|
|
1249
|
+
y(() => {
|
|
1250
|
+
b.current = e;
|
|
1251
1251
|
}, [e]);
|
|
1252
|
-
let
|
|
1253
|
-
|
|
1252
|
+
let x = v((e) => K(b.current ?? "") === e, []), w = v((e) => {
|
|
1253
|
+
d((t) => {
|
|
1254
1254
|
if (t.has(e)) return t;
|
|
1255
1255
|
let n = new Set(t);
|
|
1256
1256
|
return n.add(e), n;
|
|
1257
1257
|
});
|
|
1258
|
-
}, []),
|
|
1259
|
-
|
|
1258
|
+
}, []), T = v((e) => {
|
|
1259
|
+
d((t) => {
|
|
1260
1260
|
if (!t.has(e)) return t;
|
|
1261
1261
|
let n = new Set(t);
|
|
1262
1262
|
return n.delete(e), n;
|
|
1263
1263
|
});
|
|
1264
|
-
}, []),
|
|
1265
|
-
let
|
|
1266
|
-
|
|
1267
|
-
let
|
|
1268
|
-
|
|
1269
|
-
let
|
|
1270
|
-
|
|
1271
|
-
signal:
|
|
1264
|
+
}, []), E = v((e, l, u, d, f, g, v = I.Append) => {
|
|
1265
|
+
let y = g ?? c(), b = K(e);
|
|
1266
|
+
m.current = y, h.current = b, p(b);
|
|
1267
|
+
let S;
|
|
1268
|
+
v === I.Regenerate ? S = u : v === I.Edit && (S = u - 1);
|
|
1269
|
+
let C = i(b, y);
|
|
1270
|
+
w(b), s?.notifyGenerationStart?.(), o?.ensureConnected(), r.streamCompletion(b, l, d, {
|
|
1271
|
+
signal: C.signal,
|
|
1272
1272
|
onChunk: (e) => {
|
|
1273
|
-
|
|
1273
|
+
m.current === y && x(b) && t((t) => {
|
|
1274
1274
|
if (!t) return t;
|
|
1275
|
-
let r =
|
|
1275
|
+
let r = Rt(t.messages, u, e);
|
|
1276
1276
|
if (!r) return t;
|
|
1277
1277
|
let i = {
|
|
1278
1278
|
...t,
|
|
@@ -1282,18 +1282,18 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1282
1282
|
});
|
|
1283
1283
|
},
|
|
1284
1284
|
onComplete: async () => {
|
|
1285
|
-
if (
|
|
1286
|
-
let i = await r.getConversation(
|
|
1287
|
-
if (!b
|
|
1285
|
+
if (T(b), m.current === y && (m.current = null, h.current = null, p(null)), a(b, y), _.current.has(y) ? _.current.delete(y) : s?.notifyGenerationEnd?.(), x(b)) try {
|
|
1286
|
+
let i = await r.getConversation(ft(e));
|
|
1287
|
+
if (!x(b)) return;
|
|
1288
1288
|
t(i), n.current = i;
|
|
1289
1289
|
} catch {}
|
|
1290
1290
|
},
|
|
1291
1291
|
onError: (e) => {
|
|
1292
|
-
|
|
1292
|
+
T(b), m.current === y && (m.current = null, h.current = null, p(null)), x(b) && t((t) => {
|
|
1293
1293
|
if (!t) return t;
|
|
1294
1294
|
let r = {
|
|
1295
1295
|
...t,
|
|
1296
|
-
messages: t.messages.map((t, n) => n ===
|
|
1296
|
+
messages: t.messages.map((t, n) => n === u ? {
|
|
1297
1297
|
...t,
|
|
1298
1298
|
streamErrorMessage: e.message
|
|
1299
1299
|
} : t)
|
|
@@ -1301,43 +1301,43 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1301
1301
|
return n.current = r, r;
|
|
1302
1302
|
});
|
|
1303
1303
|
}
|
|
1304
|
-
},
|
|
1304
|
+
}, f, y, v, S, o?.channelId ?? void 0);
|
|
1305
1305
|
}, [
|
|
1306
1306
|
i,
|
|
1307
1307
|
a,
|
|
1308
|
-
C,
|
|
1309
1308
|
w,
|
|
1310
|
-
|
|
1309
|
+
T,
|
|
1310
|
+
x,
|
|
1311
1311
|
o?.channelId,
|
|
1312
1312
|
o?.ensureConnected,
|
|
1313
1313
|
s,
|
|
1314
1314
|
r
|
|
1315
|
-
]),
|
|
1316
|
-
let t =
|
|
1315
|
+
]), D = v(() => {
|
|
1316
|
+
let t = m.current;
|
|
1317
1317
|
if (!t || !e) return;
|
|
1318
1318
|
let n = K(e);
|
|
1319
|
-
|
|
1319
|
+
h.current === n && (_.current.add(t), s?.notifyStopGenerating?.(), r.stopCompletion({
|
|
1320
1320
|
generationId: t,
|
|
1321
1321
|
path: n
|
|
1322
1322
|
}).catch((e) => {
|
|
1323
1323
|
let t = e instanceof Error ? e : Error(String(e));
|
|
1324
|
-
|
|
1324
|
+
l?.(t);
|
|
1325
1325
|
}));
|
|
1326
1326
|
}, [
|
|
1327
1327
|
e,
|
|
1328
|
-
|
|
1328
|
+
l,
|
|
1329
1329
|
s,
|
|
1330
1330
|
r
|
|
1331
|
-
]),
|
|
1332
|
-
if (!
|
|
1331
|
+
]), O = v((e, i) => {
|
|
1332
|
+
if (!Pt(i)) return;
|
|
1333
1333
|
let a = K(e);
|
|
1334
|
-
if (
|
|
1335
|
-
|
|
1334
|
+
if (g.current.has(a)) return;
|
|
1335
|
+
g.current.add(a), w(a);
|
|
1336
1336
|
let o = new AbortController(), s = (e) => {
|
|
1337
|
-
|
|
1337
|
+
g.current.delete(a), T(a), e && x(a) && (t(e), n.current = e);
|
|
1338
1338
|
}, c = async () => {
|
|
1339
1339
|
try {
|
|
1340
|
-
s(await r.getConversation(
|
|
1340
|
+
s(await r.getConversation(ft(e)));
|
|
1341
1341
|
} catch {
|
|
1342
1342
|
s();
|
|
1343
1343
|
}
|
|
@@ -1352,7 +1352,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1352
1352
|
}
|
|
1353
1353
|
let n = t.getReader(), i = new TextDecoder(), l = "", u = window.setTimeout(() => {
|
|
1354
1354
|
o.abort();
|
|
1355
|
-
},
|
|
1355
|
+
}, zt);
|
|
1356
1356
|
try {
|
|
1357
1357
|
for (;;) {
|
|
1358
1358
|
let { done: t, value: a } = await n.read();
|
|
@@ -1370,8 +1370,8 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1370
1370
|
continue;
|
|
1371
1371
|
}
|
|
1372
1372
|
if (a?.action === "UPDATE") try {
|
|
1373
|
-
let t = await r.getConversation(
|
|
1374
|
-
if (!
|
|
1373
|
+
let t = await r.getConversation(ft(e));
|
|
1374
|
+
if (!Pt(t)) {
|
|
1375
1375
|
s(t);
|
|
1376
1376
|
return;
|
|
1377
1377
|
}
|
|
@@ -1384,34 +1384,34 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1384
1384
|
await c();
|
|
1385
1385
|
})();
|
|
1386
1386
|
}, [
|
|
1387
|
-
C,
|
|
1388
1387
|
w,
|
|
1389
|
-
|
|
1388
|
+
T,
|
|
1389
|
+
x,
|
|
1390
1390
|
r
|
|
1391
|
-
]),
|
|
1391
|
+
]), k = e != null && u.has(K(e)), A = e == null ? null : K(e);
|
|
1392
1392
|
return {
|
|
1393
|
-
startStream:
|
|
1394
|
-
handleStop:
|
|
1395
|
-
resumeIfAwaitingGeneration:
|
|
1396
|
-
isStreaming:
|
|
1397
|
-
canStopStreaming:
|
|
1393
|
+
startStream: E,
|
|
1394
|
+
handleStop: D,
|
|
1395
|
+
resumeIfAwaitingGeneration: O,
|
|
1396
|
+
isStreaming: k,
|
|
1397
|
+
canStopStreaming: A != null && f === A
|
|
1398
1398
|
};
|
|
1399
|
-
},
|
|
1399
|
+
}, Vt = {}, Ht = (e, t = Vt) => x(() => {
|
|
1400
1400
|
let n = [], r = [], i = [], o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
|
|
1401
|
-
for (let
|
|
1402
|
-
let e =
|
|
1403
|
-
if (
|
|
1404
|
-
let e =
|
|
1401
|
+
for (let l of e) {
|
|
1402
|
+
let e = l.custom_content?.attachments;
|
|
1403
|
+
if (l.role === a.User) for (let r of e ?? []) {
|
|
1404
|
+
let e = u(r, t);
|
|
1405
1405
|
s.has(e.id) || (s.add(e.id), n.push(e));
|
|
1406
1406
|
}
|
|
1407
|
-
else if (
|
|
1408
|
-
let n = e?.filter((e) => !
|
|
1407
|
+
else if (l.role === a.Assistant) {
|
|
1408
|
+
let n = e?.filter((e) => !m(e));
|
|
1409
1409
|
for (let e of n ?? []) {
|
|
1410
|
-
let n =
|
|
1410
|
+
let n = u(e, t);
|
|
1411
1411
|
c.has(n.id) || (c.add(n.id), r.push(n));
|
|
1412
1412
|
}
|
|
1413
1413
|
for (let t of e ?? []) {
|
|
1414
|
-
if (!
|
|
1414
|
+
if (!m(t)) continue;
|
|
1415
1415
|
let e = t.reference_url;
|
|
1416
1416
|
o.has(e) || (o.add(e), i.push({
|
|
1417
1417
|
url: e,
|
|
@@ -1420,7 +1420,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1420
1420
|
quote: t.data
|
|
1421
1421
|
}));
|
|
1422
1422
|
}
|
|
1423
|
-
for (let e of
|
|
1423
|
+
for (let e of _(l)) {
|
|
1424
1424
|
let t = e?.body?.source?.attachment, n = t?.url;
|
|
1425
1425
|
!n || o.has(n) || (o.add(n), i.push({
|
|
1426
1426
|
url: n,
|
|
@@ -1436,7 +1436,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1436
1436
|
generated: r,
|
|
1437
1437
|
sources: i
|
|
1438
1438
|
};
|
|
1439
|
-
}, [e, t]),
|
|
1439
|
+
}, [e, t]), Ut = /* @__PURE__ */ function(e) {
|
|
1440
1440
|
return e.Overwrite = "overwrite", e.CreateOnly = "create-only", e;
|
|
1441
1441
|
}({}), q = /* @__PURE__ */ function(e) {
|
|
1442
1442
|
return e.FolderLoadFailed = "folderLoadFailed", e.MetadataLoadFailed = "metadataLoadFailed", e.FolderCreateFailed = "folderCreateFailed", e.DownloadFileFailed = "downloadFileFailed", e.DownloadFilesFailed = "downloadFilesFailed", e.FilesDeleted = "filesDeleted", e.FilesDeletePartiallyFailed = "filesDeletePartiallyFailed", e.DeleteFailed = "deleteFailed", e.RenameFailed = "renameFailed", e.RenamePartiallyFailed = "renamePartiallyFailed", e.MoveFailed = "moveFailed", e.MovePartiallyFailed = "movePartiallyFailed", e.CopyFailed = "copyFailed", e.CopyPartiallyFailed = "copyPartiallyFailed", e.UnshareFailed = "unshareFailed", e.RemoveAccessFailed = "removeAccessFailed", e.UploadFailed = "uploadFailed", e.UploadCompleted = "uploadCompleted", e.UploadArchiveFailed = "uploadArchiveFailed", e.UploadArchivePartiallyFailed = "uploadArchivePartiallyFailed", e.UploadArchiveRequestFailed = "uploadArchiveRequestFailed", e;
|
|
@@ -1444,30 +1444,30 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1444
1444
|
return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e.LeadingDot = "leadingDot", e;
|
|
1445
1445
|
}({}), Y = /* @__PURE__ */ function(e) {
|
|
1446
1446
|
return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e;
|
|
1447
|
-
}({}),
|
|
1447
|
+
}({}), Wt = 3, Gt = r, Kt = /[/\\]/, qt = {
|
|
1448
1448
|
year: "numeric",
|
|
1449
1449
|
month: "short",
|
|
1450
1450
|
day: "2-digit"
|
|
1451
|
-
},
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
],
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
],
|
|
1451
|
+
}, Jt = [
|
|
1452
|
+
V.Name,
|
|
1453
|
+
V.UpdatedAt,
|
|
1454
|
+
V.Size,
|
|
1455
|
+
V.Actions
|
|
1456
|
+
], Yt = [
|
|
1457
|
+
V.Name,
|
|
1458
|
+
V.UpdatedAt,
|
|
1459
|
+
V.Size,
|
|
1460
|
+
V.Author,
|
|
1461
|
+
V.Actions
|
|
1462
|
+
], Xt = {
|
|
1463
1463
|
READ: ee.READ,
|
|
1464
1464
|
WRITE: ee.WRITE,
|
|
1465
1465
|
SHARE: ee.SHARE
|
|
1466
|
-
},
|
|
1466
|
+
}, Zt = /* @__PURE__ */ function(e) {
|
|
1467
1467
|
return e.Attach = "attach", e.Standalone = "standalone", e.FolderPicker = "folder-picker", e;
|
|
1468
|
-
}({}),
|
|
1468
|
+
}({}), Qt = /* @__PURE__ */ function(e) {
|
|
1469
1469
|
return e.Attach = "attach", e.Browse = "browse", e.Full = "full", e;
|
|
1470
|
-
}({}),
|
|
1470
|
+
}({}), $t = (e) => {
|
|
1471
1471
|
switch (e) {
|
|
1472
1472
|
case "attach": return "attach";
|
|
1473
1473
|
case "standalone": return "browse";
|
|
@@ -1479,37 +1479,37 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1479
1479
|
} catch {
|
|
1480
1480
|
return e;
|
|
1481
1481
|
}
|
|
1482
|
-
},
|
|
1483
|
-
if (
|
|
1482
|
+
}, en = (e, t) => {
|
|
1483
|
+
if (Kt.test(e)) return !0;
|
|
1484
1484
|
if (t == null) return !1;
|
|
1485
1485
|
t.lastIndex = 0;
|
|
1486
1486
|
let n = t.test(e);
|
|
1487
1487
|
return t.lastIndex = 0, n;
|
|
1488
|
-
}, Z = (e) => e.replace(/\/+$/, "") || "/",
|
|
1488
|
+
}, Z = (e) => e.replace(/\/+$/, "") || "/", tn = (e, t) => {
|
|
1489
1489
|
let n = e.split("/").filter(Boolean);
|
|
1490
1490
|
return X(n[n.length - 1] ?? t);
|
|
1491
|
-
},
|
|
1491
|
+
}, nn = (e, t) => Z(e || `/${t}`).replace(/^\/+/, "") || t, rn = (e, t) => {
|
|
1492
1492
|
let n = Z(t);
|
|
1493
1493
|
for (let r of e) {
|
|
1494
|
-
if (r.nodeType !==
|
|
1494
|
+
if (r.nodeType !== B.FOLDER) continue;
|
|
1495
1495
|
if (Z(r.path) === n) return r;
|
|
1496
|
-
let e =
|
|
1496
|
+
let e = rn(r.items ?? [], t);
|
|
1497
1497
|
if (e) return e;
|
|
1498
1498
|
}
|
|
1499
|
-
},
|
|
1499
|
+
}, an = (e) => e?.permissions?.includes(ee.WRITE) ?? !1, on = (e, t) => {
|
|
1500
1500
|
for (let n of e) {
|
|
1501
1501
|
if (n.path === t || n.id === t) return n;
|
|
1502
|
-
let e =
|
|
1502
|
+
let e = on(n.items ?? [], t);
|
|
1503
1503
|
if (e) return e;
|
|
1504
1504
|
}
|
|
1505
|
-
},
|
|
1505
|
+
}, sn = (e) => {
|
|
1506
1506
|
switch (e) {
|
|
1507
|
-
case
|
|
1508
|
-
case
|
|
1509
|
-
case
|
|
1507
|
+
case Qt.Attach: return !1;
|
|
1508
|
+
case Qt.Browse:
|
|
1509
|
+
case Qt.Full: return !0;
|
|
1510
1510
|
default: throw Error(`Unhandled actionProfile: ${String(e)}`);
|
|
1511
1511
|
}
|
|
1512
|
-
},
|
|
1512
|
+
}, cn = (e) => e === Qt.Full, ln = (e, t) => {
|
|
1513
1513
|
let n = e.replace(/\/$/, ""), r = n.lastIndexOf("/");
|
|
1514
1514
|
if (r <= 0) {
|
|
1515
1515
|
let e = r === 0 ? n.slice(1) : n;
|
|
@@ -1522,13 +1522,13 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1522
1522
|
parentVirtualPath: n.slice(0, r),
|
|
1523
1523
|
name: n.slice(r + 1)
|
|
1524
1524
|
};
|
|
1525
|
-
},
|
|
1525
|
+
}, un = (e, t) => {
|
|
1526
1526
|
let n = `files/${t}/`;
|
|
1527
1527
|
return e.startsWith(n) ? e.slice(n.length) : e;
|
|
1528
|
-
},
|
|
1528
|
+
}, dn = (e, t, n) => {
|
|
1529
1529
|
let r = e.replace(/\/+$/, "").split("/").filter(Boolean).map(X).join("/"), i = r ? `/${t}/${r}` : `/${t}`;
|
|
1530
1530
|
return n ? `${i}/` : i;
|
|
1531
|
-
},
|
|
1531
|
+
}, fn = (e, t, n) => {
|
|
1532
1532
|
if (!e) return {
|
|
1533
1533
|
bucket: n,
|
|
1534
1534
|
path: e
|
|
@@ -1538,15 +1538,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1538
1538
|
bucket: n,
|
|
1539
1539
|
path: e
|
|
1540
1540
|
};
|
|
1541
|
-
let o =
|
|
1541
|
+
let o = un(a.dialCorePath, a.bucket), s = r === -1 ? "" : e.slice(r + 1);
|
|
1542
1542
|
return {
|
|
1543
1543
|
bucket: a.bucket,
|
|
1544
1544
|
path: o + s
|
|
1545
1545
|
};
|
|
1546
|
-
},
|
|
1546
|
+
}, pn = (e) => e.startsWith("files/"), mn = (e, t) => {
|
|
1547
1547
|
let n = `files/${t}/`;
|
|
1548
1548
|
if (e.startsWith(n)) return X(e.slice(n.length));
|
|
1549
|
-
if (
|
|
1549
|
+
if (pn(e)) {
|
|
1550
1550
|
let n = e.slice(6), r = n.indexOf("/");
|
|
1551
1551
|
if (r >= 0) {
|
|
1552
1552
|
let e = n.slice(0, r), i = n.slice(r + 1);
|
|
@@ -1566,28 +1566,28 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1566
1566
|
}
|
|
1567
1567
|
let o = a.replace(/\/{2,}/g, "/");
|
|
1568
1568
|
return o && !o.endsWith("/") ? `${o}/` : o;
|
|
1569
|
-
},
|
|
1569
|
+
}, hn = (e) => {
|
|
1570
1570
|
let t = e.replace(/\/$/, ""), n = t.lastIndexOf("/");
|
|
1571
1571
|
return n > 0 ? t.slice(0, n + 1) : "";
|
|
1572
|
-
},
|
|
1573
|
-
let r = e.nodeType ===
|
|
1572
|
+
}, gn = (e, t) => e.startsWith("/") || e === t || e.startsWith(`${t}/`), _n = (e, t, n) => {
|
|
1573
|
+
let r = e.nodeType === B.FOLDER, i = e.id ? mn(e.id, t) : null, a = i != null && !gn(i, n) ? i : Q(e.path, n);
|
|
1574
1574
|
return r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, "");
|
|
1575
|
-
},
|
|
1576
|
-
let r = e.nodeType ===
|
|
1575
|
+
}, vn = (e, t, n) => e.map((e) => {
|
|
1576
|
+
let r = e.nodeType === B.FOLDER, i = Q(e.sourceUrl, n), a = Q(e.destinationUrl, n), o = tn(e.sourceUrl, i);
|
|
1577
1577
|
return {
|
|
1578
|
-
destinationName:
|
|
1578
|
+
destinationName: tn(e.destinationUrl, a),
|
|
1579
1579
|
dto: {
|
|
1580
1580
|
bucket: t,
|
|
1581
1581
|
sourcePath: r ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, ""),
|
|
1582
1582
|
destinationPath: r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, ""),
|
|
1583
1583
|
overwrite: e.overwrite === !0,
|
|
1584
|
-
nodeType: r ?
|
|
1584
|
+
nodeType: r ? j.Folder : j.Item,
|
|
1585
1585
|
name: o
|
|
1586
1586
|
}
|
|
1587
1587
|
};
|
|
1588
|
-
}),
|
|
1588
|
+
}), yn = (e, t, n) => {
|
|
1589
1589
|
let r = e.map((e) => {
|
|
1590
|
-
let t = e.nodeType ===
|
|
1590
|
+
let t = e.nodeType === B.FOLDER, r = Q(e.sourceUrl, n), i = Q(e.destinationUrl, n), a = tn(e.sourceUrl, r), o = tn(e.destinationUrl, i), s = t ? r.endsWith("/") ? r : `${r}/` : r.replace(/\/$/, ""), c = t ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, "");
|
|
1591
1591
|
return {
|
|
1592
1592
|
isFolder: t,
|
|
1593
1593
|
name: a,
|
|
@@ -1595,8 +1595,8 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1595
1595
|
overwrite: e.overwrite === !0,
|
|
1596
1596
|
sourcePath: s,
|
|
1597
1597
|
destinationPath: c,
|
|
1598
|
-
sourceParent:
|
|
1599
|
-
destinationParent:
|
|
1598
|
+
sourceParent: hn(s),
|
|
1599
|
+
destinationParent: hn(c)
|
|
1600
1600
|
};
|
|
1601
1601
|
});
|
|
1602
1602
|
return {
|
|
@@ -1604,7 +1604,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1604
1604
|
bucket: t,
|
|
1605
1605
|
sourcePath: e.sourcePath,
|
|
1606
1606
|
destinationPath: e.destinationPath,
|
|
1607
|
-
nodeType: e.isFolder ?
|
|
1607
|
+
nodeType: e.isFolder ? F.Folder : F.Item,
|
|
1608
1608
|
name: e.name
|
|
1609
1609
|
})),
|
|
1610
1610
|
preparedMoveItems: r.filter((e) => e.sourceParent !== e.destinationParent).map((e) => ({
|
|
@@ -1614,30 +1614,30 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1614
1614
|
sourcePath: e.sourcePath,
|
|
1615
1615
|
destinationPath: e.destinationPath,
|
|
1616
1616
|
overwrite: e.overwrite,
|
|
1617
|
-
nodeType: e.isFolder ?
|
|
1617
|
+
nodeType: e.isFolder ? P.Folder : P.Item,
|
|
1618
1618
|
name: e.name
|
|
1619
1619
|
}
|
|
1620
1620
|
}))
|
|
1621
1621
|
};
|
|
1622
|
-
},
|
|
1622
|
+
}, bn = (e) => {
|
|
1623
1623
|
if (!e?.length) return;
|
|
1624
|
-
let t = e.map((e) =>
|
|
1624
|
+
let t = e.map((e) => Xt[e.toUpperCase()]).filter((e) => e != null);
|
|
1625
1625
|
return t.length > 0 ? t : void 0;
|
|
1626
|
-
},
|
|
1626
|
+
}, xn = (e, t) => {
|
|
1627
1627
|
let n = t.find((e) => e.success);
|
|
1628
1628
|
if (n != null) return e.find(({ dto: e }) => e.sourcePath === n.sourcePath && e.destinationPath === n.destinationPath) ?? e.find(({ dto: e }) => e.destinationPath === n.destinationPath) ?? e[0];
|
|
1629
|
-
},
|
|
1629
|
+
}, Sn = (e, t, n, r, i) => {
|
|
1630
1630
|
let a = e.get(n);
|
|
1631
1631
|
if (a == null) return [];
|
|
1632
1632
|
let o = r.replace(/\/$/, "");
|
|
1633
1633
|
return a.map((a) => {
|
|
1634
|
-
let s = a.nodeType ===
|
|
1634
|
+
let s = a.nodeType === N.Folder, c = X(a.name), l = s ? `${o}/${c}/` : `${o}/${c}`, u = {
|
|
1635
1635
|
id: a.path,
|
|
1636
1636
|
name: c,
|
|
1637
1637
|
path: l,
|
|
1638
1638
|
url: a.url,
|
|
1639
1639
|
parentPath: r,
|
|
1640
|
-
nodeType: s ?
|
|
1640
|
+
nodeType: s ? B.FOLDER : B.ITEM,
|
|
1641
1641
|
folderId: i,
|
|
1642
1642
|
bucket: a.bucket,
|
|
1643
1643
|
author: a.author,
|
|
@@ -1648,23 +1648,23 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1648
1648
|
};
|
|
1649
1649
|
if (s) {
|
|
1650
1650
|
let r = `${n}${c}/`;
|
|
1651
|
-
u.permissions =
|
|
1651
|
+
u.permissions = bn(a.permissions) ?? bn(t.get(r)), u.items = Sn(e, t, r, l, a.path);
|
|
1652
1652
|
}
|
|
1653
1653
|
return u;
|
|
1654
1654
|
});
|
|
1655
|
-
},
|
|
1655
|
+
}, Cn = (e, t, n, r) => {
|
|
1656
1656
|
let i = new Map(e), a = [...i.get(t) ?? []], o = {
|
|
1657
1657
|
name: n.name,
|
|
1658
1658
|
path: n.path,
|
|
1659
1659
|
folderId: n.folderId,
|
|
1660
|
-
nodeType:
|
|
1660
|
+
nodeType: N.Folder,
|
|
1661
1661
|
bucket: n.bucket,
|
|
1662
1662
|
parentPath: n.parentPath || void 0,
|
|
1663
1663
|
url: n.path,
|
|
1664
1664
|
permissions: r
|
|
1665
1665
|
};
|
|
1666
1666
|
return a.some((e) => e.name.toLowerCase() === n.name.toLowerCase()) || a.push(o), i.set(t, a), i;
|
|
1667
|
-
},
|
|
1667
|
+
}, wn = (e, t, n) => {
|
|
1668
1668
|
if (!e) return e;
|
|
1669
1669
|
let r = typeof n == "string" ? { status: n } : n, i = e.files.map((e, n) => n === t ? {
|
|
1670
1670
|
...e,
|
|
@@ -1674,12 +1674,12 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1674
1674
|
...e,
|
|
1675
1675
|
files: i
|
|
1676
1676
|
};
|
|
1677
|
-
},
|
|
1678
|
-
if (t ===
|
|
1677
|
+
}, Tn = (e, t, n, r, i) => {
|
|
1678
|
+
if (t === z.Shared) {
|
|
1679
1679
|
if (r === "") return e.listSharedFiles({ path: void 0 }).then((e) => ({ items: e.items }));
|
|
1680
1680
|
let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
|
|
1681
1681
|
if (a) {
|
|
1682
|
-
let n =
|
|
1682
|
+
let n = un(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1));
|
|
1683
1683
|
return e.listFiles({
|
|
1684
1684
|
bucket: a.bucket,
|
|
1685
1685
|
path: n,
|
|
@@ -1691,7 +1691,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1691
1691
|
}
|
|
1692
1692
|
return Promise.resolve({ items: [] });
|
|
1693
1693
|
}
|
|
1694
|
-
return t ===
|
|
1694
|
+
return t === z.Organization ? e.listPublicFiles({ path: r || void 0 }).then((e) => ({ items: e.items })) : e.listFiles({
|
|
1695
1695
|
bucket: n,
|
|
1696
1696
|
path: r,
|
|
1697
1697
|
permissions: !0
|
|
@@ -1699,11 +1699,11 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1699
1699
|
items: e.items,
|
|
1700
1700
|
permissions: e.permissions
|
|
1701
1701
|
}));
|
|
1702
|
-
},
|
|
1703
|
-
if (t ===
|
|
1702
|
+
}, En = async (e, t, n, r, i) => {
|
|
1703
|
+
if (t === z.Shared) {
|
|
1704
1704
|
let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
|
|
1705
1705
|
if (!a) return { items: [] };
|
|
1706
|
-
let o =
|
|
1706
|
+
let o = un(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1)), { items: s } = await e.listFiles({
|
|
1707
1707
|
bucket: a.bucket,
|
|
1708
1708
|
path: o,
|
|
1709
1709
|
permissions: !0,
|
|
@@ -1711,7 +1711,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1711
1711
|
});
|
|
1712
1712
|
return { items: s };
|
|
1713
1713
|
}
|
|
1714
|
-
if (t ===
|
|
1714
|
+
if (t === z.Organization) {
|
|
1715
1715
|
let { items: t } = await e.listPublicFiles({
|
|
1716
1716
|
path: r || void 0,
|
|
1717
1717
|
recursive: !0
|
|
@@ -1725,15 +1725,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1725
1725
|
recursive: !0
|
|
1726
1726
|
});
|
|
1727
1727
|
return { items: a };
|
|
1728
|
-
},
|
|
1729
|
-
let r = e.nodeType ===
|
|
1728
|
+
}, Dn = (e, t, n) => {
|
|
1729
|
+
let r = e.nodeType === N.Folder, i = X(e.name), a = e.bucket ?? t, o = un(e.url ?? e.path ?? "", a).replace(/\/$/, ""), s = o.lastIndexOf("/"), c = s > 0 ? o.slice(0, s) : "", l = c ? `/${n}/${c}` : `/${n}`, u = r ? `${l}/${i}/` : `${l}/${i}`;
|
|
1730
1730
|
return {
|
|
1731
1731
|
id: e.path,
|
|
1732
1732
|
name: i,
|
|
1733
1733
|
path: u,
|
|
1734
1734
|
url: e.url,
|
|
1735
1735
|
parentPath: l,
|
|
1736
|
-
nodeType: r ?
|
|
1736
|
+
nodeType: r ? B.FOLDER : B.ITEM,
|
|
1737
1737
|
folderId: e.folderId,
|
|
1738
1738
|
bucket: a,
|
|
1739
1739
|
author: e.author,
|
|
@@ -1741,50 +1741,50 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1741
1741
|
contentType: e.contentType,
|
|
1742
1742
|
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : void 0
|
|
1743
1743
|
};
|
|
1744
|
-
},
|
|
1744
|
+
}, On = (e, t) => ({
|
|
1745
1745
|
...t,
|
|
1746
1746
|
bucket: e.bucket ?? t.bucket,
|
|
1747
1747
|
author: e.author,
|
|
1748
1748
|
contentLength: e.contentLength,
|
|
1749
1749
|
contentType: e.contentType,
|
|
1750
1750
|
resourceType: e.resourceType ?? t.resourceType,
|
|
1751
|
-
permissions:
|
|
1751
|
+
permissions: bn(e.permissions) ?? t.permissions,
|
|
1752
1752
|
updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : t.updatedAt,
|
|
1753
1753
|
createdAt: e.createdAt ? new Date(e.createdAt).toISOString() : t.createdAt
|
|
1754
|
-
}),
|
|
1754
|
+
}), kn = /* @__PURE__ */ function(e) {
|
|
1755
1755
|
return e.Blob = "blob", e.Stream = "stream", e.Cancelled = "cancelled", e;
|
|
1756
|
-
}({}),
|
|
1756
|
+
}({}), An = (e) => {
|
|
1757
1757
|
let t = e.lastIndexOf("."), n = t > 0;
|
|
1758
1758
|
return {
|
|
1759
1759
|
base: n ? e.slice(0, t) : e,
|
|
1760
1760
|
extension: n ? e.slice(t) : ""
|
|
1761
1761
|
};
|
|
1762
|
-
},
|
|
1763
|
-
if (
|
|
1764
|
-
let { base: n, extension: r } =
|
|
1765
|
-
return i <= 0 ?
|
|
1766
|
-
},
|
|
1767
|
-
let { base: t, extension: n } =
|
|
1768
|
-
return r === "" ? e :
|
|
1762
|
+
}, jn = (e, t = 255) => {
|
|
1763
|
+
if (l(e) <= t) return e;
|
|
1764
|
+
let { base: n, extension: r } = An(e), i = t - l(r);
|
|
1765
|
+
return i <= 0 ? p(e, t) : `${p(n, i)}${r}`;
|
|
1766
|
+
}, Mn = (e) => {
|
|
1767
|
+
let { base: t, extension: n } = An(e), r = t.replace(new RegExp(ne.source, "g"), "_").replace(/[.\s]+$/, "");
|
|
1768
|
+
return r === "" ? e : jn(`${r}${n}`);
|
|
1769
1769
|
}, $ = /* @__PURE__ */ function(e) {
|
|
1770
1770
|
return e.Queued = "queued", e.Uploading = "uploading", e.Completed = "completed", e.Failed = "failed", e.Cancelled = "cancelled", e;
|
|
1771
|
-
}({}),
|
|
1772
|
-
let [a, o] =
|
|
1773
|
-
|
|
1771
|
+
}({}), Nn = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, onNotification: i }) => {
|
|
1772
|
+
let [a, o] = C(""), [s, c] = C(() => /* @__PURE__ */ new Map()), l = S(s);
|
|
1773
|
+
y(() => {
|
|
1774
1774
|
l.current = s;
|
|
1775
1775
|
}, [s]);
|
|
1776
|
-
let [u, d] =
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}, [r]),
|
|
1780
|
-
|
|
1781
|
-
}, []),
|
|
1776
|
+
let [u, d] = C(() => /* @__PURE__ */ new Map()), [f, p] = C(!0), [m, h] = C(null), [g, _] = C(0), [b, w] = C(void 0), [T, E] = C(() => /* @__PURE__ */ new Set()), D = S(/* @__PURE__ */ new Map()), [O, k] = C(!1), [A, j] = C(null), M = S(null), P = S(null), F = S(/* @__PURE__ */ new Set()), I = S(/* @__PURE__ */ new Set()), [L, R] = C(() => /* @__PURE__ */ new Set()), [ee, V] = C(() => /* @__PURE__ */ new Set()), te = S(r);
|
|
1777
|
+
y(() => {
|
|
1778
|
+
te.current !== r && (te.current = r, c(/* @__PURE__ */ new Map()), d(/* @__PURE__ */ new Map()), o(""), w(void 0), D.current = /* @__PURE__ */ new Map(), F.current = /* @__PURE__ */ new Set(), I.current = /* @__PURE__ */ new Set(), V(/* @__PURE__ */ new Set()), M.current != null && (clearTimeout(M.current), M.current = null), P.current?.(), P.current = null, j(null), k(!1), R(/* @__PURE__ */ new Set()));
|
|
1779
|
+
}, [r]), y(() => () => {
|
|
1780
|
+
M.current != null && clearTimeout(M.current), P.current?.();
|
|
1781
|
+
}, []), y(() => {
|
|
1782
1782
|
let i = !1;
|
|
1783
|
-
return p(!0), h(null),
|
|
1783
|
+
return p(!0), h(null), Tn(e, r, t, a, D.current).then(({ items: e, permissions: t }) => {
|
|
1784
1784
|
i || (c((t) => {
|
|
1785
1785
|
let n = new Map(t);
|
|
1786
1786
|
return n.set(a, e), n;
|
|
1787
|
-
}), d((e) => new Map(e).set(a, t)), r ===
|
|
1787
|
+
}), d((e) => new Map(e).set(a, t)), r === z.Shared && a === "" && (w(e.map((e) => dn(un(e.path, e.bucket ?? ""), n, e.nodeType === N.Folder))), D.current = new Map(e.map((e) => [X(e.name), {
|
|
1788
1788
|
bucket: e.bucket ?? "",
|
|
1789
1789
|
dialCorePath: e.path
|
|
1790
1790
|
}]))));
|
|
@@ -1802,14 +1802,14 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1802
1802
|
a,
|
|
1803
1803
|
g,
|
|
1804
1804
|
n
|
|
1805
|
-
]),
|
|
1806
|
-
if (r !==
|
|
1805
|
+
]), y(() => {
|
|
1806
|
+
if (r !== z.MyFiles) {
|
|
1807
1807
|
E(/* @__PURE__ */ new Set());
|
|
1808
1808
|
return;
|
|
1809
1809
|
}
|
|
1810
1810
|
let i = !1;
|
|
1811
1811
|
return e.listSharedByMe(t).then((e) => {
|
|
1812
|
-
i || E(new Set(e.items.map((e) => un(
|
|
1812
|
+
i || E(new Set(e.items.map((e) => dn(un(e.path, t), n, e.nodeType === N.Folder))));
|
|
1813
1813
|
}).catch(() => {
|
|
1814
1814
|
i || E(/* @__PURE__ */ new Set());
|
|
1815
1815
|
}), () => {
|
|
@@ -1822,21 +1822,21 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1822
1822
|
g,
|
|
1823
1823
|
n
|
|
1824
1824
|
]);
|
|
1825
|
-
let
|
|
1825
|
+
let ne = x(() => [{
|
|
1826
1826
|
id: t,
|
|
1827
1827
|
name: n,
|
|
1828
1828
|
path: `/${n}`,
|
|
1829
1829
|
parentPath: "",
|
|
1830
|
-
nodeType:
|
|
1830
|
+
nodeType: B.FOLDER,
|
|
1831
1831
|
folderId: t,
|
|
1832
|
-
permissions:
|
|
1833
|
-
items:
|
|
1832
|
+
permissions: bn(u.get("")),
|
|
1833
|
+
items: Sn(s, u, "", `/${n}`, t)
|
|
1834
1834
|
}], [
|
|
1835
1835
|
s,
|
|
1836
1836
|
u,
|
|
1837
1837
|
n,
|
|
1838
1838
|
t
|
|
1839
|
-
]),
|
|
1839
|
+
]), re = v((e) => {
|
|
1840
1840
|
if (e == null) {
|
|
1841
1841
|
o("");
|
|
1842
1842
|
return;
|
|
@@ -1854,9 +1854,9 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1854
1854
|
i = t.startsWith(r) ? t.slice(r.length) : t;
|
|
1855
1855
|
}
|
|
1856
1856
|
o(i && !i.endsWith("/") ? `${i}/` : i);
|
|
1857
|
-
}, [n]), ie =
|
|
1858
|
-
|
|
1859
|
-
}, []), ae = ie, oe =
|
|
1857
|
+
}, [n]), ie = v(() => {
|
|
1858
|
+
_((e) => e + 1);
|
|
1859
|
+
}, []), ae = ie, oe = v((o) => {
|
|
1860
1860
|
if (o.length === 0) return;
|
|
1861
1861
|
let s = new Set([...L].map((e) => Q(e, n))), l = (e) => e === a || a.startsWith(e) || s.has(e), u = o.filter((e) => !l(e)), f = o.filter((e) => l(e) && e !== a);
|
|
1862
1862
|
u.length > 0 && (c((e) => {
|
|
@@ -1868,11 +1868,11 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1868
1868
|
})), f.forEach((n) => {
|
|
1869
1869
|
(async () => {
|
|
1870
1870
|
try {
|
|
1871
|
-
let { items: i, permissions: a } = await
|
|
1871
|
+
let { items: i, permissions: a } = await Tn(e, r, t, n, D.current);
|
|
1872
1872
|
c((e) => new Map(e).set(n, i)), a != null && d((e) => new Map(e).set(n, a));
|
|
1873
1873
|
} catch {
|
|
1874
1874
|
i?.({
|
|
1875
|
-
variant:
|
|
1875
|
+
variant: H.Error,
|
|
1876
1876
|
reason: q.FolderLoadFailed
|
|
1877
1877
|
});
|
|
1878
1878
|
}
|
|
@@ -1886,32 +1886,32 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1886
1886
|
L,
|
|
1887
1887
|
n,
|
|
1888
1888
|
i
|
|
1889
|
-
]), se =
|
|
1890
|
-
c((r) =>
|
|
1891
|
-
}, []), ce =
|
|
1889
|
+
]), se = v((e, t, n) => {
|
|
1890
|
+
c((r) => Cn(r, e, t, n));
|
|
1891
|
+
}, []), ce = v((a) => {
|
|
1892
1892
|
let o = a == null ? "" : Q(a, n), s = a == null ? `/${n}` : Z(a);
|
|
1893
1893
|
if (!l.current.has(o)) {
|
|
1894
1894
|
if (F.current.has(o)) {
|
|
1895
|
-
|
|
1895
|
+
V((e) => {
|
|
1896
1896
|
let t = new Set(e);
|
|
1897
1897
|
return t.add(s), t;
|
|
1898
1898
|
});
|
|
1899
1899
|
return;
|
|
1900
1900
|
}
|
|
1901
|
-
F.current.add(o),
|
|
1901
|
+
F.current.add(o), V((e) => {
|
|
1902
1902
|
let t = new Set(e);
|
|
1903
1903
|
return t.add(s), t;
|
|
1904
1904
|
}), (async () => {
|
|
1905
1905
|
try {
|
|
1906
|
-
let { items: n, permissions: i } = await
|
|
1906
|
+
let { items: n, permissions: i } = await Tn(e, r, t, o, D.current);
|
|
1907
1907
|
c((e) => new Map(e).set(o, n)), i != null && d((e) => new Map(e).set(o, i)), I.current.delete(o);
|
|
1908
1908
|
} catch {
|
|
1909
1909
|
i?.({
|
|
1910
|
-
variant:
|
|
1910
|
+
variant: H.Error,
|
|
1911
1911
|
reason: q.FolderLoadFailed
|
|
1912
1912
|
});
|
|
1913
1913
|
} finally {
|
|
1914
|
-
F.current.delete(o),
|
|
1914
|
+
F.current.delete(o), V((e) => {
|
|
1915
1915
|
let t = new Set(e);
|
|
1916
1916
|
return t.delete(s), t;
|
|
1917
1917
|
});
|
|
@@ -1924,7 +1924,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1924
1924
|
e,
|
|
1925
1925
|
i,
|
|
1926
1926
|
n
|
|
1927
|
-
]), le =
|
|
1927
|
+
]), le = x(() => {
|
|
1928
1928
|
let e = /* @__PURE__ */ new Set();
|
|
1929
1929
|
for (let t of L) {
|
|
1930
1930
|
let r = Q(t, n);
|
|
@@ -1935,25 +1935,25 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1935
1935
|
L,
|
|
1936
1936
|
s,
|
|
1937
1937
|
n
|
|
1938
|
-
]), ue =
|
|
1938
|
+
]), ue = v((a) => {
|
|
1939
1939
|
L.forEach((e) => {
|
|
1940
1940
|
a.has(e) || I.current.delete(Q(e, n));
|
|
1941
|
-
}),
|
|
1941
|
+
}), R(a), [...a].filter((e) => {
|
|
1942
1942
|
let t = Q(e, n);
|
|
1943
1943
|
return !l.current.has(t) && !F.current.has(t) && !I.current.has(t);
|
|
1944
1944
|
}).forEach((a) => {
|
|
1945
1945
|
let o = Q(a, n);
|
|
1946
1946
|
F.current.add(o), (async () => {
|
|
1947
1947
|
try {
|
|
1948
|
-
let { items: n, permissions: i } = await
|
|
1948
|
+
let { items: n, permissions: i } = await Tn(e, r, t, o, D.current);
|
|
1949
1949
|
c((e) => new Map(e).set(o, n)), i != null && d((e) => new Map(e).set(o, i));
|
|
1950
1950
|
} catch {
|
|
1951
1951
|
I.current.add(o), i?.({
|
|
1952
|
-
variant:
|
|
1952
|
+
variant: H.Error,
|
|
1953
1953
|
reason: q.FolderLoadFailed
|
|
1954
1954
|
});
|
|
1955
1955
|
} finally {
|
|
1956
|
-
F.current.delete(o),
|
|
1956
|
+
F.current.delete(o), V((e) => {
|
|
1957
1957
|
let t = new Set(e);
|
|
1958
1958
|
return t.delete(Z(a)), t;
|
|
1959
1959
|
});
|
|
@@ -1967,18 +1967,18 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1967
1967
|
L,
|
|
1968
1968
|
i,
|
|
1969
1969
|
n
|
|
1970
|
-
]), de =
|
|
1971
|
-
|
|
1972
|
-
}, []), fe =
|
|
1973
|
-
if (
|
|
1970
|
+
]), de = v(() => {
|
|
1971
|
+
M.current != null && (clearTimeout(M.current), M.current = null), P.current?.(), P.current = null, j(null), k(!1);
|
|
1972
|
+
}, []), fe = v((i, o) => {
|
|
1973
|
+
if (M.current != null && (clearTimeout(M.current), M.current = null), P.current?.(), P.current = null, !o.trim()) {
|
|
1974
1974
|
j(null), k(!1);
|
|
1975
1975
|
return;
|
|
1976
1976
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1977
|
+
M.current = setTimeout(() => {
|
|
1978
|
+
M.current = null;
|
|
1979
1979
|
let i = o.toLowerCase();
|
|
1980
|
-
if (r ===
|
|
1981
|
-
P.current?.(), P.current = null, k(!0), j((s.get("") ?? []).filter((e) => X(e.name).toLowerCase().includes(i)).map((e) =>
|
|
1980
|
+
if (r === z.Shared && a === "") {
|
|
1981
|
+
P.current?.(), P.current = null, k(!0), j((s.get("") ?? []).filter((e) => X(e.name).toLowerCase().includes(i)).map((e) => Dn(e, e.bucket ?? t, n))), k(!1);
|
|
1982
1982
|
return;
|
|
1983
1983
|
}
|
|
1984
1984
|
let c = !1;
|
|
@@ -1986,9 +1986,9 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
1986
1986
|
c = !0;
|
|
1987
1987
|
}, k(!0), (async () => {
|
|
1988
1988
|
try {
|
|
1989
|
-
let { items: o } = await
|
|
1989
|
+
let { items: o } = await En(e, r, t, a, D.current);
|
|
1990
1990
|
if (c) return;
|
|
1991
|
-
j(o.filter((e) => X(e.name).toLowerCase().includes(i)).map((e) =>
|
|
1991
|
+
j(o.filter((e) => X(e.name).toLowerCase().includes(i)).map((e) => Dn(e, e.bucket ?? t, n)));
|
|
1992
1992
|
} catch {
|
|
1993
1993
|
c || j([]);
|
|
1994
1994
|
} finally {
|
|
@@ -2003,21 +2003,21 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2003
2003
|
e,
|
|
2004
2004
|
a,
|
|
2005
2005
|
n
|
|
2006
|
-
]), pe = a ? `/${n}/${a}` : `/${n}`, me =
|
|
2007
|
-
let e =
|
|
2008
|
-
if (e) return Z(pe) === Z(`/${n}`) ? e :
|
|
2006
|
+
]), pe = a ? `/${n}/${a}` : `/${n}`, me = x(() => {
|
|
2007
|
+
let e = ne[0];
|
|
2008
|
+
if (e) return Z(pe) === Z(`/${n}`) ? e : rn(e.items ?? [], pe);
|
|
2009
2009
|
}, [
|
|
2010
|
-
|
|
2010
|
+
ne,
|
|
2011
2011
|
pe,
|
|
2012
2012
|
n
|
|
2013
2013
|
]);
|
|
2014
2014
|
return {
|
|
2015
|
-
items:
|
|
2015
|
+
items: ne,
|
|
2016
2016
|
isLoading: f,
|
|
2017
2017
|
error: m,
|
|
2018
2018
|
path: pe,
|
|
2019
2019
|
folderPath: a,
|
|
2020
|
-
onPathChange:
|
|
2020
|
+
onPathChange: re,
|
|
2021
2021
|
retry: ie,
|
|
2022
2022
|
onSearchFiles: fe,
|
|
2023
2023
|
isSearching: O,
|
|
@@ -2027,8 +2027,8 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2027
2027
|
loadedPaths: le,
|
|
2028
2028
|
onExpandedPathsChange: ue,
|
|
2029
2029
|
onFolderPopupPathChange: ce,
|
|
2030
|
-
folderPopupLoadingPaths:
|
|
2031
|
-
sharedWithMeIds:
|
|
2030
|
+
folderPopupLoadingPaths: ee,
|
|
2031
|
+
sharedWithMeIds: x(() => r === z.Shared ? b : void 0, [r, b]),
|
|
2032
2032
|
sharedByMePaths: T,
|
|
2033
2033
|
currentFolder: me,
|
|
2034
2034
|
cache: s,
|
|
@@ -2039,23 +2039,23 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2039
2039
|
mergeCreatedFolder: se,
|
|
2040
2040
|
bumpRetry: ae
|
|
2041
2041
|
};
|
|
2042
|
-
},
|
|
2043
|
-
let [i, a] =
|
|
2042
|
+
}, Pn = ({ filesApi: e, bucket: t, rootLabel: n, onNotification: r }) => {
|
|
2043
|
+
let [i, a] = C(void 0), [o, s] = C(!1);
|
|
2044
2044
|
return {
|
|
2045
2045
|
fileMetadata: i,
|
|
2046
2046
|
isFileMetadataLoading: o,
|
|
2047
|
-
onGetInfo:
|
|
2047
|
+
onGetInfo: v((i) => {
|
|
2048
2048
|
(async () => {
|
|
2049
2049
|
s(!0);
|
|
2050
2050
|
try {
|
|
2051
|
-
let r = i.bucket ?? t, o =
|
|
2052
|
-
a(
|
|
2051
|
+
let r = i.bucket ?? t, o = _n(i, r, n);
|
|
2052
|
+
a(On(await e.getFileMetadata({
|
|
2053
2053
|
bucket: r,
|
|
2054
2054
|
path: o
|
|
2055
2055
|
}), i));
|
|
2056
2056
|
} catch {
|
|
2057
2057
|
r?.({
|
|
2058
|
-
variant:
|
|
2058
|
+
variant: H.Error,
|
|
2059
2059
|
reason: q.MetadataLoadFailed
|
|
2060
2060
|
});
|
|
2061
2061
|
} finally {
|
|
@@ -2068,20 +2068,20 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2068
2068
|
n,
|
|
2069
2069
|
r
|
|
2070
2070
|
]),
|
|
2071
|
-
clearMetadata:
|
|
2071
|
+
clearMetadata: v(() => {
|
|
2072
2072
|
a(void 0), s(!1);
|
|
2073
2073
|
}, [])
|
|
2074
2074
|
};
|
|
2075
|
-
},
|
|
2076
|
-
let [g,
|
|
2075
|
+
}, Fn = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, folderPath: i, currentFolder: a, sharedRootMetaRef: o, listingPermissionsCache: s, invalidateFolders: c, bumpRetry: l, mergeCreatedFolder: u, setFolderPath: d, onNotification: f, onOperationSuccess: p, downloadDestination: m, forbiddenSymbolsRegExp: h }) => {
|
|
2076
|
+
let [g, _] = C(!1), [y, b] = C(!1), [x, w] = C(!1), [T, E] = C(!1), [D, O] = C(!1), [k, j] = C(!1), N = S(null), P = S(null), I = v((e, t) => {
|
|
2077
2077
|
let n = null;
|
|
2078
2078
|
if (!e || e.trim() === "") n = { reason: J.Empty };
|
|
2079
|
-
else if (
|
|
2079
|
+
else if (en(e, h)) n = {
|
|
2080
2080
|
reason: J.ForbiddenSymbols,
|
|
2081
2081
|
symbols: te
|
|
2082
2082
|
};
|
|
2083
2083
|
else if (e.startsWith(".")) n = { reason: J.LeadingDot };
|
|
2084
|
-
else if (e ===
|
|
2084
|
+
else if (e === Gt) n = { reason: J.ReservedName };
|
|
2085
2085
|
else if (e.length > 255) n = {
|
|
2086
2086
|
reason: J.TooLong,
|
|
2087
2087
|
maxLength: 255
|
|
@@ -2093,38 +2093,38 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2093
2093
|
existingName: a.name
|
|
2094
2094
|
});
|
|
2095
2095
|
}
|
|
2096
|
-
return
|
|
2097
|
-
}, [h]), L =
|
|
2098
|
-
let { parentVirtualPath: h, name: g } =
|
|
2099
|
-
id:
|
|
2100
|
-
path:
|
|
2096
|
+
return P.current = n, n;
|
|
2097
|
+
}, [h]), L = v(async (c, d, m) => {
|
|
2098
|
+
let { parentVirtualPath: h, name: g } = ln(d, n), v = Q(h, n), y = a && i === v ? a : {
|
|
2099
|
+
id: v,
|
|
2100
|
+
path: v,
|
|
2101
2101
|
name: h.split("/").filter(Boolean).pop() ?? "",
|
|
2102
|
-
folderId:
|
|
2103
|
-
nodeType:
|
|
2102
|
+
folderId: v,
|
|
2103
|
+
nodeType: B.FOLDER,
|
|
2104
2104
|
items: []
|
|
2105
|
-
}, b =
|
|
2106
|
-
if (
|
|
2107
|
-
|
|
2108
|
-
let { bucket: x, path: S } = r ===
|
|
2105
|
+
}, b = P.current;
|
|
2106
|
+
if (P.current = null, I(g, y) || b) return;
|
|
2107
|
+
_(!0);
|
|
2108
|
+
let { bucket: x, path: S } = r === z.Shared ? fn(v, o.current, t) : {
|
|
2109
2109
|
bucket: t,
|
|
2110
|
-
path:
|
|
2110
|
+
path: v
|
|
2111
2111
|
};
|
|
2112
2112
|
try {
|
|
2113
|
-
u(
|
|
2113
|
+
u(v, await e.createFolder({
|
|
2114
2114
|
bucket: x,
|
|
2115
2115
|
parentPath: S || void 0,
|
|
2116
2116
|
name: g
|
|
2117
|
-
}), s.get(
|
|
2117
|
+
}), s.get(v)), l(), p?.({
|
|
2118
2118
|
kind: Y.FolderCreated,
|
|
2119
2119
|
name: g
|
|
2120
2120
|
});
|
|
2121
2121
|
} catch {
|
|
2122
2122
|
f?.({
|
|
2123
|
-
variant:
|
|
2123
|
+
variant: H.Error,
|
|
2124
2124
|
reason: q.FolderCreateFailed
|
|
2125
2125
|
});
|
|
2126
2126
|
} finally {
|
|
2127
|
-
|
|
2127
|
+
_(!1);
|
|
2128
2128
|
}
|
|
2129
2129
|
}, [
|
|
2130
2130
|
r,
|
|
@@ -2140,16 +2140,16 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2140
2140
|
p,
|
|
2141
2141
|
o,
|
|
2142
2142
|
f
|
|
2143
|
-
]),
|
|
2143
|
+
]), R = v((r) => {
|
|
2144
2144
|
(async () => {
|
|
2145
2145
|
b(!0);
|
|
2146
2146
|
try {
|
|
2147
|
-
let i = r.length === 1 ? r[0].nodeType ===
|
|
2148
|
-
if (a.type ===
|
|
2149
|
-
if (r.length === 1 && r[0].nodeType ===
|
|
2147
|
+
let i = r.length === 1 ? r[0].nodeType === B.ITEM ? r[0].name : `${r[0].name}.zip` : "files.zip", a = await m.resolveDestination(i, r.length === 1 && r[0].nodeType === B.ITEM ? r[0].contentType ?? "application/octet-stream" : "application/zip");
|
|
2148
|
+
if (a.type === kn.Cancelled) return;
|
|
2149
|
+
if (r.length === 1 && r[0].nodeType === B.ITEM) {
|
|
2150
2150
|
let t = r[0];
|
|
2151
2151
|
if (!t.bucket) throw Error("File is missing bucket");
|
|
2152
|
-
let i =
|
|
2152
|
+
let i = _n(t, t.bucket, n), o = await e.downloadFile(t.bucket, i);
|
|
2153
2153
|
if (!o.ok) throw Error(`Download failed with status ${o.status}`);
|
|
2154
2154
|
let s = await m.triggerDownload(o, t.name, a);
|
|
2155
2155
|
p?.({
|
|
@@ -2160,9 +2160,9 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2160
2160
|
} else {
|
|
2161
2161
|
let o = r.map((e) => ({
|
|
2162
2162
|
bucket: e.bucket ?? t,
|
|
2163
|
-
path:
|
|
2163
|
+
path: _n(e, e.bucket ?? t, n),
|
|
2164
2164
|
name: e.name,
|
|
2165
|
-
nodeType: e.nodeType ===
|
|
2165
|
+
nodeType: e.nodeType === B.FOLDER ? A.Folder : A.Item
|
|
2166
2166
|
})), s = await e.downloadArchive(o);
|
|
2167
2167
|
if (!s.ok) throw Error(`Download failed with status ${s.status}`);
|
|
2168
2168
|
let c = await m.triggerDownload(s, i, a);
|
|
@@ -2176,7 +2176,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2176
2176
|
}
|
|
2177
2177
|
} catch {
|
|
2178
2178
|
f?.({
|
|
2179
|
-
variant:
|
|
2179
|
+
variant: H.Error,
|
|
2180
2180
|
reason: r.length === 1 ? q.DownloadFileFailed : q.DownloadFilesFailed
|
|
2181
2181
|
});
|
|
2182
2182
|
} finally {
|
|
@@ -2190,11 +2190,11 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2190
2190
|
f,
|
|
2191
2191
|
e,
|
|
2192
2192
|
m
|
|
2193
|
-
]),
|
|
2193
|
+
]), ee = v((a, s) => {
|
|
2194
2194
|
a.length !== 0 && (async () => {
|
|
2195
2195
|
w(!0);
|
|
2196
2196
|
let u = a.map((e) => {
|
|
2197
|
-
let i = e.nodeType ===
|
|
2197
|
+
let i = e.nodeType === B.FOLDER, a = Q(e.sourceUrl, n), s = i ? a : a.replace(/\/$/, ""), c = tn(e.sourceUrl, s), { bucket: l, path: u } = r === z.Shared ? fn(s, o.current, t) : {
|
|
2198
2198
|
bucket: t,
|
|
2199
2199
|
path: s
|
|
2200
2200
|
};
|
|
@@ -2202,13 +2202,13 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2202
2202
|
bucket: l,
|
|
2203
2203
|
path: u,
|
|
2204
2204
|
name: c,
|
|
2205
|
-
nodeType: i ?
|
|
2205
|
+
nodeType: i ? M.Folder : M.Item
|
|
2206
2206
|
};
|
|
2207
2207
|
});
|
|
2208
2208
|
try {
|
|
2209
2209
|
let { results: t } = await e.deleteFiles(u), r = t.filter((e) => !e.success), i = r.length, a = t.length - i, o = t.find((e) => e.success), c = u.find((e) => e.path === o?.path) ?? u[0];
|
|
2210
2210
|
if (a > 0 && f?.({
|
|
2211
|
-
variant:
|
|
2211
|
+
variant: H.Success,
|
|
2212
2212
|
reason: q.FilesDeleted,
|
|
2213
2213
|
count: a,
|
|
2214
2214
|
name: c?.name,
|
|
@@ -2216,7 +2216,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2216
2216
|
}), i > 0) {
|
|
2217
2217
|
let e = r.slice(0, 3).map((e) => u.find((t) => t.path === e.path)?.name ?? e.path), t = i - e.length;
|
|
2218
2218
|
f?.({
|
|
2219
|
-
variant:
|
|
2219
|
+
variant: H.Error,
|
|
2220
2220
|
reason: q.FilesDeletePartiallyFailed,
|
|
2221
2221
|
names: e,
|
|
2222
2222
|
restCount: t
|
|
@@ -2224,13 +2224,13 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2224
2224
|
}
|
|
2225
2225
|
} catch {
|
|
2226
2226
|
f?.({
|
|
2227
|
-
variant:
|
|
2227
|
+
variant: H.Error,
|
|
2228
2228
|
reason: q.DeleteFailed
|
|
2229
2229
|
});
|
|
2230
2230
|
}
|
|
2231
|
-
let p = u.filter((e) => e.nodeType ===
|
|
2231
|
+
let p = u.filter((e) => e.nodeType === M.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
|
|
2232
2232
|
c([...new Set(u.map((e) => {
|
|
2233
|
-
if (e.nodeType ===
|
|
2233
|
+
if (e.nodeType === M.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
|
|
2234
2234
|
let t = e.path.lastIndexOf("/");
|
|
2235
2235
|
return t > 0 ? e.path.slice(0, t + 1) : "";
|
|
2236
2236
|
}))]), p.some((e) => i === e || i.startsWith(e)) && d((e) => e.replace(/[^/]+\/$/, "")), l(), w(!1);
|
|
@@ -2246,10 +2246,10 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2246
2246
|
c,
|
|
2247
2247
|
l,
|
|
2248
2248
|
d
|
|
2249
|
-
]),
|
|
2249
|
+
]), V = v((e, t) => {
|
|
2250
2250
|
if (!e || e.trim() === "") return { reason: J.Empty };
|
|
2251
|
-
if (e ===
|
|
2252
|
-
if (
|
|
2251
|
+
if (e === Gt) return { reason: J.ReservedName };
|
|
2252
|
+
if (en(e, h)) return {
|
|
2253
2253
|
reason: J.ForbiddenSymbols,
|
|
2254
2254
|
symbols: te
|
|
2255
2255
|
};
|
|
@@ -2262,38 +2262,38 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2262
2262
|
reason: J.DuplicateName,
|
|
2263
2263
|
existingName: i.name
|
|
2264
2264
|
} : null;
|
|
2265
|
-
}, [h, a]),
|
|
2266
|
-
if (r.length === 0 || D ||
|
|
2265
|
+
}, [h, a]), ne = v((r, i) => {
|
|
2266
|
+
if (r.length === 0 || D || k) return;
|
|
2267
2267
|
let a = new AbortController();
|
|
2268
2268
|
N.current = a, (async () => {
|
|
2269
2269
|
O(!0);
|
|
2270
|
-
let o =
|
|
2270
|
+
let o = vn(r, t, n), s = o.map(({ dto: e }) => e);
|
|
2271
2271
|
try {
|
|
2272
2272
|
let { results: t } = await e.copyFiles(s, a.signal), r = t.filter((e) => !e.success).length, c = t.length - r;
|
|
2273
2273
|
if (c > 0) {
|
|
2274
|
-
let e =
|
|
2274
|
+
let e = xn(o, t);
|
|
2275
2275
|
p?.({
|
|
2276
2276
|
kind: c === 1 ? Y.FileCopied : Y.FilesCopied,
|
|
2277
2277
|
name: e?.destinationName,
|
|
2278
2278
|
count: c,
|
|
2279
|
-
destinationFolderName:
|
|
2279
|
+
destinationFolderName: nn(i, n)
|
|
2280
2280
|
});
|
|
2281
2281
|
}
|
|
2282
2282
|
r > 0 && r < t.length ? f?.({
|
|
2283
|
-
variant:
|
|
2283
|
+
variant: H.Error,
|
|
2284
2284
|
reason: q.CopyPartiallyFailed,
|
|
2285
2285
|
count: r
|
|
2286
2286
|
}) : r === t.length && f?.({
|
|
2287
|
-
variant:
|
|
2287
|
+
variant: H.Error,
|
|
2288
2288
|
reason: q.CopyFailed
|
|
2289
2289
|
});
|
|
2290
2290
|
} catch {
|
|
2291
2291
|
a.signal.aborted || f?.({
|
|
2292
|
-
variant:
|
|
2292
|
+
variant: H.Error,
|
|
2293
2293
|
reason: q.CopyFailed
|
|
2294
2294
|
});
|
|
2295
2295
|
} finally {
|
|
2296
|
-
c([...new Set(s.flatMap((e) => [
|
|
2296
|
+
c([...new Set(s.flatMap((e) => [hn(e.sourcePath), hn(e.destinationPath)]))]), l(), O(!1), N.current = null;
|
|
2297
2297
|
}
|
|
2298
2298
|
})();
|
|
2299
2299
|
}, [
|
|
@@ -2303,29 +2303,29 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2303
2303
|
p,
|
|
2304
2304
|
e,
|
|
2305
2305
|
D,
|
|
2306
|
-
|
|
2306
|
+
k,
|
|
2307
2307
|
c,
|
|
2308
2308
|
l
|
|
2309
|
-
]),
|
|
2309
|
+
]), re = v(() => {
|
|
2310
2310
|
N.current?.abort();
|
|
2311
2311
|
}, []);
|
|
2312
2312
|
return {
|
|
2313
2313
|
isCreatingFolder: g,
|
|
2314
2314
|
isDownloading: y,
|
|
2315
|
-
isDeleting:
|
|
2315
|
+
isDeleting: x,
|
|
2316
2316
|
isRenaming: T,
|
|
2317
2317
|
isCopying: D,
|
|
2318
|
-
isMoving:
|
|
2318
|
+
isMoving: k,
|
|
2319
2319
|
onCreateFolder: L,
|
|
2320
2320
|
onCreateFolderValidate: I,
|
|
2321
|
-
onDownloadFiles:
|
|
2322
|
-
onDeleteFiles:
|
|
2323
|
-
onRenameValidate:
|
|
2324
|
-
onMoveToFiles:
|
|
2325
|
-
if (r.length === 0 || D ||
|
|
2326
|
-
let { renameDtos: s, preparedMoveItems: u } =
|
|
2321
|
+
onDownloadFiles: R,
|
|
2322
|
+
onDeleteFiles: ee,
|
|
2323
|
+
onRenameValidate: V,
|
|
2324
|
+
onMoveToFiles: v((r, a, o) => {
|
|
2325
|
+
if (r.length === 0 || D || k || T) return;
|
|
2326
|
+
let { renameDtos: s, preparedMoveItems: u } = yn(r, t, n), m = u.map(({ dto: e }) => e), h = new AbortController();
|
|
2327
2327
|
m.length > 0 && (N.current = h), (async () => {
|
|
2328
|
-
s.length > 0 && E(!0), m.length > 0 &&
|
|
2328
|
+
s.length > 0 && E(!0), m.length > 0 && j(!0);
|
|
2329
2329
|
let [t, r] = await Promise.all([(async () => {
|
|
2330
2330
|
if (s.length === 0) return {
|
|
2331
2331
|
results: [],
|
|
@@ -2365,31 +2365,31 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2365
2365
|
}
|
|
2366
2366
|
})()]), a = t.threw ? s.length : t.results.filter((e) => !e.success).length, g = r.threw && r.aborted, _ = g ? 0 : m.length, v = g ? 0 : r.threw ? m.length : r.results.filter((e) => !e.success).length, y = r.threw ? 0 : r.results.filter((e) => e.success).length, b = s.length + _, x = a + v, S = v > 0;
|
|
2367
2367
|
if (y > 0) {
|
|
2368
|
-
let e =
|
|
2368
|
+
let e = xn(u, r.results);
|
|
2369
2369
|
p?.({
|
|
2370
2370
|
kind: y === 1 ? Y.FileMoved : Y.FilesMoved,
|
|
2371
2371
|
name: e?.destinationName,
|
|
2372
2372
|
count: y,
|
|
2373
|
-
destinationFolderName:
|
|
2373
|
+
destinationFolderName: nn(o, n)
|
|
2374
2374
|
});
|
|
2375
2375
|
}
|
|
2376
2376
|
if (s.length === 1 && a === 0) {
|
|
2377
2377
|
let [e] = s;
|
|
2378
2378
|
p?.({
|
|
2379
2379
|
kind: Y.FileRenamed,
|
|
2380
|
-
name:
|
|
2381
|
-
isFolder: e.nodeType ===
|
|
2380
|
+
name: tn(e.destinationPath, e.destinationPath),
|
|
2381
|
+
isFolder: e.nodeType === F.Folder
|
|
2382
2382
|
});
|
|
2383
2383
|
}
|
|
2384
2384
|
x > 0 && (x === b ? f?.({
|
|
2385
|
-
variant:
|
|
2385
|
+
variant: H.Error,
|
|
2386
2386
|
reason: S ? q.MoveFailed : q.RenameFailed
|
|
2387
2387
|
}) : f?.({
|
|
2388
|
-
variant:
|
|
2388
|
+
variant: H.Error,
|
|
2389
2389
|
reason: S ? q.MovePartiallyFailed : q.RenamePartiallyFailed,
|
|
2390
2390
|
count: x
|
|
2391
2391
|
}));
|
|
2392
|
-
let C = s.find((e) => e.nodeType ===
|
|
2392
|
+
let C = s.find((e) => e.nodeType === F.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
|
|
2393
2393
|
if (C != null) {
|
|
2394
2394
|
let e = C.sourcePath.endsWith("/") ? C.sourcePath : `${C.sourcePath}/`;
|
|
2395
2395
|
if (i === e || i.startsWith(e)) {
|
|
@@ -2397,7 +2397,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2397
2397
|
d(i.replace(e, t));
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
c([...new Set([...s, ...m].flatMap((e) => [
|
|
2400
|
+
c([...new Set([...s, ...m].flatMap((e) => [hn(e.sourcePath), hn(e.destinationPath)]))]), l(), E(!1), j(!1), m.length > 0 && (N.current = null);
|
|
2401
2401
|
})();
|
|
2402
2402
|
}, [
|
|
2403
2403
|
t,
|
|
@@ -2407,35 +2407,35 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2407
2407
|
f,
|
|
2408
2408
|
e,
|
|
2409
2409
|
D,
|
|
2410
|
-
|
|
2410
|
+
k,
|
|
2411
2411
|
T,
|
|
2412
2412
|
c,
|
|
2413
2413
|
l,
|
|
2414
2414
|
d
|
|
2415
2415
|
]),
|
|
2416
|
-
onCopyFiles:
|
|
2417
|
-
cancelCopyMove:
|
|
2416
|
+
onCopyFiles: ne,
|
|
2417
|
+
cancelCopyMove: re
|
|
2418
2418
|
};
|
|
2419
|
-
},
|
|
2420
|
-
let [a, o] =
|
|
2419
|
+
}, In = ({ filesApi: e, bucket: t, rootLabel: n, bumpRetry: r, onNotification: i }) => {
|
|
2420
|
+
let [a, o] = C(!1), [s, c] = C(!1);
|
|
2421
2421
|
return {
|
|
2422
2422
|
isUnsharing: a,
|
|
2423
2423
|
isRemovingAccess: s,
|
|
2424
|
-
onUnshareFiles:
|
|
2424
|
+
onUnshareFiles: v((a) => {
|
|
2425
2425
|
a.length !== 0 && (async () => {
|
|
2426
2426
|
o(!0);
|
|
2427
2427
|
let s = a.map((e) => {
|
|
2428
2428
|
let r = e.bucket ?? t;
|
|
2429
2429
|
return {
|
|
2430
2430
|
bucket: r,
|
|
2431
|
-
path:
|
|
2431
|
+
path: _n(e, r, n)
|
|
2432
2432
|
};
|
|
2433
2433
|
});
|
|
2434
2434
|
try {
|
|
2435
2435
|
await e.discardShared(s), r();
|
|
2436
2436
|
} catch {
|
|
2437
2437
|
i?.({
|
|
2438
|
-
variant:
|
|
2438
|
+
variant: H.Error,
|
|
2439
2439
|
reason: q.UnshareFailed
|
|
2440
2440
|
});
|
|
2441
2441
|
} finally {
|
|
@@ -2449,21 +2449,21 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2449
2449
|
e,
|
|
2450
2450
|
r
|
|
2451
2451
|
]),
|
|
2452
|
-
onRemoveFilesAccess:
|
|
2452
|
+
onRemoveFilesAccess: v((a) => {
|
|
2453
2453
|
a.length !== 0 && (async () => {
|
|
2454
2454
|
c(!0);
|
|
2455
2455
|
let o = a.map((e) => {
|
|
2456
2456
|
let r = e.bucket ?? t;
|
|
2457
2457
|
return {
|
|
2458
2458
|
bucket: r,
|
|
2459
|
-
path:
|
|
2459
|
+
path: _n(e, r, n)
|
|
2460
2460
|
};
|
|
2461
2461
|
});
|
|
2462
2462
|
try {
|
|
2463
2463
|
await e.revokeAccess(o), r();
|
|
2464
2464
|
} catch {
|
|
2465
2465
|
i?.({
|
|
2466
|
-
variant:
|
|
2466
|
+
variant: H.Error,
|
|
2467
2467
|
reason: q.RemoveAccessFailed
|
|
2468
2468
|
});
|
|
2469
2469
|
} finally {
|
|
@@ -2478,17 +2478,17 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2478
2478
|
r
|
|
2479
2479
|
])
|
|
2480
2480
|
};
|
|
2481
|
-
},
|
|
2482
|
-
let t = e.slice(0,
|
|
2481
|
+
}, Ln = 5, Rn = (e) => e.error ? `${e.path} (${e.error})` : e.path, zn = (e) => {
|
|
2482
|
+
let t = e.slice(0, Ln);
|
|
2483
2483
|
return {
|
|
2484
|
-
names: t.map(
|
|
2484
|
+
names: t.map(Rn),
|
|
2485
2485
|
restCount: e.length - t.length
|
|
2486
2486
|
};
|
|
2487
|
-
},
|
|
2487
|
+
}, Bn = (e, t) => `${e}${t}/`, Vn = (e) => /\.zip$/i.test(e), Hn = (e) => {
|
|
2488
2488
|
let [t] = e;
|
|
2489
|
-
if (!(e.length !== 1 || t == null)) return
|
|
2490
|
-
},
|
|
2491
|
-
let [l, u] =
|
|
2489
|
+
if (!(e.length !== 1 || t == null)) return Vn(t.fileContent.name) && !Vn(t.name) ? t : void 0;
|
|
2490
|
+
}, Un = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, cache: i, sharedRootMetaRef: a, invalidateFolders: o, bumpRetry: s, onNotification: c }) => {
|
|
2491
|
+
let [l, u] = C(null), d = S(null), f = v((r, i, a) => {
|
|
2492
2492
|
let l = Q(a, n);
|
|
2493
2493
|
u({
|
|
2494
2494
|
files: [{
|
|
@@ -2499,14 +2499,14 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2499
2499
|
isOpen: !0
|
|
2500
2500
|
}), (async () => {
|
|
2501
2501
|
try {
|
|
2502
|
-
let { results: n } = await e.uploadArchive(r, t,
|
|
2502
|
+
let { results: n } = await e.uploadArchive(r, t, Bn(l, i)), a = n.filter((e) => e.success).length, o = n.filter((e) => !e.success), s = o.length, { names: u, restCount: d } = zn(o);
|
|
2503
2503
|
n.length > 0 && a === 0 ? c?.({
|
|
2504
|
-
variant:
|
|
2504
|
+
variant: H.Error,
|
|
2505
2505
|
reason: q.UploadArchiveFailed,
|
|
2506
2506
|
names: u,
|
|
2507
2507
|
restCount: d
|
|
2508
2508
|
}) : s > 0 && c?.({
|
|
2509
|
-
variant:
|
|
2509
|
+
variant: H.Error,
|
|
2510
2510
|
reason: q.UploadArchivePartiallyFailed,
|
|
2511
2511
|
count: s,
|
|
2512
2512
|
names: u,
|
|
@@ -2514,7 +2514,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2514
2514
|
});
|
|
2515
2515
|
} catch {
|
|
2516
2516
|
c?.({
|
|
2517
|
-
variant:
|
|
2517
|
+
variant: H.Error,
|
|
2518
2518
|
reason: q.UploadArchiveRequestFailed
|
|
2519
2519
|
});
|
|
2520
2520
|
} finally {
|
|
@@ -2530,9 +2530,9 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2530
2530
|
s
|
|
2531
2531
|
]);
|
|
2532
2532
|
return {
|
|
2533
|
-
onUploadFiles:
|
|
2533
|
+
onUploadFiles: v((l, p) => {
|
|
2534
2534
|
if (l.length === 0) return;
|
|
2535
|
-
let m =
|
|
2535
|
+
let m = Hn(l);
|
|
2536
2536
|
if (m != null) {
|
|
2537
2537
|
f(m.fileContent, m.name, p);
|
|
2538
2538
|
return;
|
|
@@ -2546,7 +2546,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2546
2546
|
})),
|
|
2547
2547
|
isOpen: !0
|
|
2548
2548
|
});
|
|
2549
|
-
let g = Q(p, n), { bucket: _, path: v } = r ===
|
|
2549
|
+
let g = Q(p, n), { bucket: _, path: v } = r === z.Shared ? fn(g, a.current, t) : {
|
|
2550
2550
|
bucket: t,
|
|
2551
2551
|
path: g
|
|
2552
2552
|
}, y = new Set((i.get(g) ?? []).map((e) => e.name.toLowerCase()));
|
|
@@ -2555,39 +2555,39 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2555
2555
|
for (; t < l.length;) {
|
|
2556
2556
|
let n = t++, a = l[n];
|
|
2557
2557
|
if (h.signal.aborted) {
|
|
2558
|
-
u((e) =>
|
|
2558
|
+
u((e) => wn(e, n, $.Cancelled));
|
|
2559
2559
|
continue;
|
|
2560
2560
|
}
|
|
2561
|
-
u((e) =>
|
|
2561
|
+
u((e) => wn(e, n, {
|
|
2562
2562
|
status: $.Uploading,
|
|
2563
2563
|
percent: 0
|
|
2564
2564
|
}));
|
|
2565
|
-
let o = y.has(a.name.toLowerCase()) ?
|
|
2565
|
+
let o = y.has(a.name.toLowerCase()) ? Ut.Overwrite : Ut.CreateOnly;
|
|
2566
2566
|
try {
|
|
2567
2567
|
await e.uploadFile(_, `${v}${a.name}`, a.fileContent, {
|
|
2568
2568
|
signal: h.signal,
|
|
2569
2569
|
uploadMode: o,
|
|
2570
2570
|
onProgress: (e) => {
|
|
2571
|
-
u((t) =>
|
|
2571
|
+
u((t) => wn(t, n, {
|
|
2572
2572
|
status: $.Uploading,
|
|
2573
2573
|
percent: e
|
|
2574
2574
|
}));
|
|
2575
2575
|
}
|
|
2576
|
-
}), u((e) =>
|
|
2576
|
+
}), u((e) => wn(e, n, {
|
|
2577
2577
|
status: $.Completed,
|
|
2578
2578
|
percent: 100
|
|
2579
2579
|
})), r += 1;
|
|
2580
2580
|
} catch {
|
|
2581
2581
|
let e = h.signal.aborted ? $.Cancelled : $.Failed;
|
|
2582
|
-
e === $.Failed && (i += 1), u((t) =>
|
|
2582
|
+
e === $.Failed && (i += 1), u((t) => wn(t, n, e));
|
|
2583
2583
|
}
|
|
2584
2584
|
}
|
|
2585
2585
|
};
|
|
2586
2586
|
await Promise.all(Array.from({ length: 3 }, () => a())), h.signal.aborted || (r === 0 && i > 0 ? c?.({
|
|
2587
|
-
variant:
|
|
2587
|
+
variant: H.Error,
|
|
2588
2588
|
reason: q.UploadFailed
|
|
2589
2589
|
}) : c?.({
|
|
2590
|
-
variant:
|
|
2590
|
+
variant: H.Success,
|
|
2591
2591
|
reason: q.UploadCompleted,
|
|
2592
2592
|
folder: v || n
|
|
2593
2593
|
})), o([g]), s(), d.current = null, u(null);
|
|
@@ -2604,29 +2604,29 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2604
2604
|
s,
|
|
2605
2605
|
f
|
|
2606
2606
|
]),
|
|
2607
|
-
onUploadArchive:
|
|
2607
|
+
onUploadArchive: v((e, t, n) => {
|
|
2608
2608
|
f(e, t, n);
|
|
2609
2609
|
}, [f]),
|
|
2610
|
-
onValidateUpload:
|
|
2611
|
-
for (let t of e) t.name =
|
|
2610
|
+
onValidateUpload: v(async (e, t, n) => {
|
|
2611
|
+
for (let t of e) t.name = Mn(t.name);
|
|
2612
2612
|
return { valid: !0 };
|
|
2613
2613
|
}, []),
|
|
2614
2614
|
uploadBatchState: l,
|
|
2615
|
-
cancelUpload:
|
|
2615
|
+
cancelUpload: v(() => {
|
|
2616
2616
|
d.current?.abort();
|
|
2617
2617
|
}, []),
|
|
2618
|
-
clearUploadBatch:
|
|
2618
|
+
clearUploadBatch: v(() => {
|
|
2619
2619
|
u(null);
|
|
2620
2620
|
}, [])
|
|
2621
2621
|
};
|
|
2622
|
-
},
|
|
2623
|
-
let m = c ??
|
|
2622
|
+
}, Wn = ({ filesApi: e, bucket: t, rootLabel: n = "My files", activeTab: r = z.MyFiles, onNotification: i, onOperationSuccess: a, forbiddenSymbolsRegExp: o, variant: s = Zt.Attach, actionProfile: c, labels: l, locale: u, disabledNewButtonTooltip: d, downloadDestination: f, buildValidationErrorMessage: p }) => {
|
|
2623
|
+
let m = c ?? $t(s), h = Nn({
|
|
2624
2624
|
filesApi: e,
|
|
2625
2625
|
bucket: t,
|
|
2626
2626
|
rootLabel: n,
|
|
2627
2627
|
activeTab: r,
|
|
2628
2628
|
onNotification: i
|
|
2629
|
-
}), g =
|
|
2629
|
+
}), g = Un({
|
|
2630
2630
|
filesApi: e,
|
|
2631
2631
|
bucket: t,
|
|
2632
2632
|
rootLabel: n,
|
|
@@ -2636,7 +2636,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2636
2636
|
invalidateFolders: h.invalidateFolders,
|
|
2637
2637
|
bumpRetry: h.bumpRetry,
|
|
2638
2638
|
onNotification: i
|
|
2639
|
-
}),
|
|
2639
|
+
}), _ = Fn({
|
|
2640
2640
|
filesApi: e,
|
|
2641
2641
|
bucket: t,
|
|
2642
2642
|
rootLabel: n,
|
|
@@ -2653,49 +2653,49 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2653
2653
|
onOperationSuccess: a,
|
|
2654
2654
|
downloadDestination: f,
|
|
2655
2655
|
forbiddenSymbolsRegExp: o
|
|
2656
|
-
}), y =
|
|
2656
|
+
}), y = In({
|
|
2657
2657
|
filesApi: e,
|
|
2658
2658
|
bucket: t,
|
|
2659
2659
|
rootLabel: n,
|
|
2660
2660
|
bumpRetry: h.bumpRetry,
|
|
2661
2661
|
onNotification: i
|
|
2662
|
-
}),
|
|
2662
|
+
}), b = Pn({
|
|
2663
2663
|
filesApi: e,
|
|
2664
2664
|
bucket: t,
|
|
2665
2665
|
rootLabel: n,
|
|
2666
2666
|
onNotification: i
|
|
2667
|
-
}), S =
|
|
2667
|
+
}), S = an(h.currentFolder), C = x(() => r === z.Organization || r === z.Shared && h.folderPath === "" ? !1 : S, [
|
|
2668
2668
|
r,
|
|
2669
2669
|
h.folderPath,
|
|
2670
2670
|
S
|
|
2671
|
-
]), w =
|
|
2671
|
+
]), w = x(() => r === z.Shared ? Yt : Jt, [r]), T = x(() => {
|
|
2672
2672
|
let e = {}, t = (t) => {
|
|
2673
2673
|
let n = l[t];
|
|
2674
2674
|
n != null && (e[t] = n);
|
|
2675
2675
|
};
|
|
2676
|
-
return t(
|
|
2676
|
+
return t(R.Download), r === z.MyFiles ? (t(R.Delete), C && (t(R.Rename), sn(m) && (t(R.Copy), t(R.Move), t(R.Duplicate))), cn(m) && t(R.RemoveAccess)) : r === z.Shared && cn(m) && t(R.Unshare), m === Qt.Full && t(R.Info), e;
|
|
2677
2677
|
}, [
|
|
2678
2678
|
r,
|
|
2679
2679
|
C,
|
|
2680
2680
|
m,
|
|
2681
2681
|
l
|
|
2682
|
-
]), E =
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2682
|
+
]), E = x(() => _.isCreatingFolder || _.isDownloading || _.isDeleting || _.isRenaming || _.isCopying || _.isMoving || y.isUnsharing || y.isRemovingAccess || g.uploadBatchState != null, [
|
|
2683
|
+
_.isCreatingFolder,
|
|
2684
|
+
_.isDownloading,
|
|
2685
|
+
_.isDeleting,
|
|
2686
|
+
_.isRenaming,
|
|
2687
|
+
_.isCopying,
|
|
2688
|
+
_.isMoving,
|
|
2689
2689
|
y.isUnsharing,
|
|
2690
2690
|
y.isRemovingAccess,
|
|
2691
2691
|
g.uploadBatchState
|
|
2692
|
-
]), D =
|
|
2693
|
-
let n =
|
|
2692
|
+
]), D = v((e, t) => {
|
|
2693
|
+
let n = _.onCreateFolderValidate(e, t);
|
|
2694
2694
|
return n ? p(n) : null;
|
|
2695
|
-
}, [
|
|
2696
|
-
let n =
|
|
2695
|
+
}, [_, p]), O = v((e, t) => {
|
|
2696
|
+
let n = _.onRenameValidate(e, t);
|
|
2697
2697
|
return n ? p(n, t) : null;
|
|
2698
|
-
}, [
|
|
2698
|
+
}, [_, p]);
|
|
2699
2699
|
return {
|
|
2700
2700
|
items: h.items,
|
|
2701
2701
|
isLoading: h.isLoading,
|
|
@@ -2718,26 +2718,26 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2718
2718
|
uploadBatchState: g.uploadBatchState,
|
|
2719
2719
|
cancelUpload: g.cancelUpload,
|
|
2720
2720
|
clearUploadBatch: g.clearUploadBatch,
|
|
2721
|
-
onCreateFolder:
|
|
2721
|
+
onCreateFolder: _.onCreateFolder,
|
|
2722
2722
|
onCreateFolderValidate: D,
|
|
2723
|
-
isCreatingFolder:
|
|
2724
|
-
onDownloadFiles:
|
|
2725
|
-
isDownloading:
|
|
2726
|
-
onDeleteFiles:
|
|
2727
|
-
isDeleting:
|
|
2723
|
+
isCreatingFolder: _.isCreatingFolder,
|
|
2724
|
+
onDownloadFiles: _.onDownloadFiles,
|
|
2725
|
+
isDownloading: _.isDownloading,
|
|
2726
|
+
onDeleteFiles: _.onDeleteFiles,
|
|
2727
|
+
isDeleting: _.isDeleting,
|
|
2728
2728
|
onRenameValidate: O,
|
|
2729
|
-
onMoveToFiles:
|
|
2730
|
-
isRenaming:
|
|
2731
|
-
onCopyFiles:
|
|
2732
|
-
isCopying:
|
|
2733
|
-
isMoving:
|
|
2734
|
-
cancelCopyMove:
|
|
2729
|
+
onMoveToFiles: _.onMoveToFiles,
|
|
2730
|
+
isRenaming: _.isRenaming,
|
|
2731
|
+
onCopyFiles: _.onCopyFiles,
|
|
2732
|
+
isCopying: _.isCopying,
|
|
2733
|
+
isMoving: _.isMoving,
|
|
2734
|
+
cancelCopyMove: _.cancelCopyMove,
|
|
2735
2735
|
uploadEnabled: C,
|
|
2736
2736
|
isNewButtonDisabled: !C,
|
|
2737
2737
|
disabledNewButtonTooltip: d,
|
|
2738
2738
|
visibleColumns: w,
|
|
2739
2739
|
dateLocale: u,
|
|
2740
|
-
dateOptions:
|
|
2740
|
+
dateOptions: qt,
|
|
2741
2741
|
actionLabels: T,
|
|
2742
2742
|
sharedWithMeIds: h.sharedWithMeIds,
|
|
2743
2743
|
sharedByMePaths: h.sharedByMePaths,
|
|
@@ -2745,70 +2745,70 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2745
2745
|
isUnsharing: y.isUnsharing,
|
|
2746
2746
|
onRemoveFilesAccess: y.onRemoveFilesAccess,
|
|
2747
2747
|
isRemovingAccess: y.isRemovingAccess,
|
|
2748
|
-
fileMetadata:
|
|
2749
|
-
isFileMetadataLoading:
|
|
2750
|
-
onGetInfo:
|
|
2751
|
-
clearMetadata:
|
|
2748
|
+
fileMetadata: b.fileMetadata,
|
|
2749
|
+
isFileMetadataLoading: b.isFileMetadataLoading,
|
|
2750
|
+
onGetInfo: b.onGetInfo,
|
|
2751
|
+
clearMetadata: b.clearMetadata,
|
|
2752
2752
|
isAnyOperationInProgress: E
|
|
2753
2753
|
};
|
|
2754
|
-
},
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
],
|
|
2759
|
-
let i =
|
|
2754
|
+
}, Gn = [
|
|
2755
|
+
z.MyFiles,
|
|
2756
|
+
z.Shared,
|
|
2757
|
+
z.Organization
|
|
2758
|
+
], Kn = (e, t, n, r) => {
|
|
2759
|
+
let i = v((e) => r == null || r.includes(e), [r]), a = x(() => n?.filter((e) => i(e.id)).flatMap(({ id: e, label: t, disabled: n }) => typeof t == "string" ? [{
|
|
2760
2760
|
id: e,
|
|
2761
2761
|
label: t,
|
|
2762
2762
|
disabled: n
|
|
2763
2763
|
}] : []), [n, i]);
|
|
2764
|
-
return
|
|
2765
|
-
i(e) || t(
|
|
2764
|
+
return y(() => {
|
|
2765
|
+
i(e) || t(Gn.find((e) => i(e)) ?? z.MyFiles);
|
|
2766
2766
|
}, [
|
|
2767
2767
|
i,
|
|
2768
2768
|
e,
|
|
2769
2769
|
t
|
|
2770
2770
|
]), { tabs: a };
|
|
2771
|
-
},
|
|
2771
|
+
}, qn = (e) => {
|
|
2772
2772
|
if (e.id) {
|
|
2773
2773
|
let t = document.querySelector(`[row-id="${e.id}"]`);
|
|
2774
2774
|
if (t) return t;
|
|
2775
2775
|
}
|
|
2776
2776
|
return e.rowIndex == null ? null : document.querySelector(`[row-index="${e.rowIndex}"]`);
|
|
2777
|
-
},
|
|
2777
|
+
}, Jn = (e, t) => {
|
|
2778
2778
|
requestAnimationFrame(() => {
|
|
2779
2779
|
requestAnimationFrame(() => {
|
|
2780
|
-
!e.isDestroyed() && t.rowIndex != null && e.ensureNodeVisible(t, "middle"),
|
|
2780
|
+
!e.isDestroyed() && t.rowIndex != null && e.ensureNodeVisible(t, "middle"), qn(t)?.scrollIntoView({
|
|
2781
2781
|
block: "center",
|
|
2782
2782
|
behavior: "auto"
|
|
2783
2783
|
});
|
|
2784
2784
|
});
|
|
2785
2785
|
});
|
|
2786
|
-
},
|
|
2787
|
-
let t =
|
|
2786
|
+
}, Yn = (e) => e.find((e) => e.data?.isTemporary) ?? e[0] ?? null, Xn = ({ resolveTargetNode: e = Yn } = {}) => {
|
|
2787
|
+
let t = S(/* @__PURE__ */ new Set()), n = S(!1), r = S(null), i = v(() => {
|
|
2788
2788
|
t.current = /* @__PURE__ */ new Set(), n.current = !1;
|
|
2789
|
-
}, []), a =
|
|
2789
|
+
}, []), a = v((e) => {
|
|
2790
2790
|
let { api: t } = e;
|
|
2791
2791
|
!t.isDestroyed() && e.rowIndex != null && t.ensureIndexVisible(e.rowIndex);
|
|
2792
|
-
}, []), o =
|
|
2792
|
+
}, []), o = v((r) => {
|
|
2793
2793
|
let { api: i } = r, a = /* @__PURE__ */ new Set(), o = [];
|
|
2794
2794
|
i.forEachNode((e) => {
|
|
2795
2795
|
let r = e.data?.id;
|
|
2796
2796
|
r && (a.add(r), n.current && !t.current.has(r) && o.push(e));
|
|
2797
2797
|
}), t.current = a, n.current = !0;
|
|
2798
2798
|
let s = e(o);
|
|
2799
|
-
s &&
|
|
2800
|
-
}, [e]), s =
|
|
2799
|
+
s && Jn(i, s);
|
|
2800
|
+
}, [e]), s = v((e) => {
|
|
2801
2801
|
let t = r.current;
|
|
2802
2802
|
t !== e && (t != null && (t.removeEventListener("cellEditingStarted", a), t.removeEventListener("rowDataUpdated", o)), e.addEventListener("cellEditingStarted", a), e.addEventListener("rowDataUpdated", o), r.current = e);
|
|
2803
2803
|
}, [a, o]);
|
|
2804
|
-
return
|
|
2804
|
+
return y(() => () => {
|
|
2805
2805
|
let e = r.current;
|
|
2806
2806
|
e != null && !e.isDestroyed() && (e.removeEventListener("cellEditingStarted", a), e.removeEventListener("rowDataUpdated", o)), r.current = null;
|
|
2807
2807
|
}, [a, o]), {
|
|
2808
2808
|
handleGridApiChange: s,
|
|
2809
2809
|
reset: i
|
|
2810
2810
|
};
|
|
2811
|
-
},
|
|
2811
|
+
}, Zn = {
|
|
2812
2812
|
settings: "Settings",
|
|
2813
2813
|
savedNotification: "Chat settings have been saved",
|
|
2814
2814
|
responseFormatLabel: "Response format",
|
|
@@ -2824,11 +2824,11 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2824
2824
|
temperatureHint: "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
|
|
2825
2825
|
saveLabel: "Apply changes",
|
|
2826
2826
|
saveDisabledTooltip: "Please select a response format"
|
|
2827
|
-
},
|
|
2828
|
-
let t =
|
|
2829
|
-
...
|
|
2827
|
+
}, Qn = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? o.PlainText : o.Markdown, $n = (e) => {
|
|
2828
|
+
let t = x(() => ({
|
|
2829
|
+
...Zn,
|
|
2830
2830
|
...e.labels
|
|
2831
|
-
}), [e.labels]), { onSaved: n } = e, r = e.mode === "local" ? e.values.responseFormat :
|
|
2831
|
+
}), [e.labels]), { onSaved: n } = e, r = e.mode === "local" ? e.values.responseFormat : Qn(e.conversation.responseFormat), i = e.mode === "local" ? e.values.systemPrompt : e.conversation.prompt ?? "", a = e.mode === "local" ? e.values.temperature : e.conversation.temperature ?? .5, o = v((t) => {
|
|
2832
2832
|
e.mode === "local" ? e.onValuesChange({
|
|
2833
2833
|
responseFormat: t.responseFormat ?? e.values.responseFormat,
|
|
2834
2834
|
systemPrompt: t.systemPrompt ?? e.values.systemPrompt,
|
|
@@ -2840,7 +2840,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2840
2840
|
...t.temperature != null && { temperature: t.temperature }
|
|
2841
2841
|
}), n?.();
|
|
2842
2842
|
}, [n, e]), s = e.deploymentFeatures?.systemPrompt ?? !1, c = !e.isQuickApp && (e.deploymentFeatures?.temperature ?? !1);
|
|
2843
|
-
return
|
|
2843
|
+
return x(() => ({
|
|
2844
2844
|
features: {
|
|
2845
2845
|
systemPrompt: s,
|
|
2846
2846
|
temperature: c,
|
|
@@ -2876,15 +2876,15 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2876
2876
|
i,
|
|
2877
2877
|
a
|
|
2878
2878
|
]);
|
|
2879
|
-
},
|
|
2880
|
-
let [n, r] =
|
|
2881
|
-
|
|
2879
|
+
}, er = (e = !0, t = !0) => {
|
|
2880
|
+
let [n, r] = C(!1), [i, a] = C([]), o = S(0), s = S(e), c = S(t);
|
|
2881
|
+
b(() => {
|
|
2882
2882
|
s.current = e, c.current = t, t || (o.current = 0, r(!1));
|
|
2883
2883
|
}, [e, t]);
|
|
2884
|
-
let l =
|
|
2884
|
+
let l = v(() => {
|
|
2885
2885
|
a([]);
|
|
2886
2886
|
}, []);
|
|
2887
|
-
return
|
|
2887
|
+
return y(() => {
|
|
2888
2888
|
let e = (e) => !!e.dataTransfer?.types.includes("Files"), t = (t) => {
|
|
2889
2889
|
!c.current || !e(t) || (o.current += 1, r(!0));
|
|
2890
2890
|
}, n = (t) => {
|
|
@@ -2905,21 +2905,21 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2905
2905
|
pendingFiles: i,
|
|
2906
2906
|
onFilesConsumed: l
|
|
2907
2907
|
};
|
|
2908
|
-
},
|
|
2909
|
-
let [e, t] =
|
|
2910
|
-
return
|
|
2908
|
+
}, tr = () => typeof window < "u" ? window.innerWidth : 1024, nr = () => {
|
|
2909
|
+
let [e, t] = C(tr);
|
|
2910
|
+
return y(() => {
|
|
2911
2911
|
if (typeof window > "u") return;
|
|
2912
2912
|
let e = () => t(window.innerWidth);
|
|
2913
2913
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
2914
2914
|
}, []), e;
|
|
2915
|
-
},
|
|
2916
|
-
let t =
|
|
2915
|
+
}, rr = (e) => {
|
|
2916
|
+
let t = nr();
|
|
2917
2917
|
return Math.max(0, t - e);
|
|
2918
|
-
},
|
|
2918
|
+
}, ir = (e) => e.map((e) => e === L.Edit ? re.Edit : re.View), ar = (e, t) => {
|
|
2919
2919
|
let n = new URL(e, t);
|
|
2920
2920
|
return `${t}${n.pathname}${n.search}${n.hash}`;
|
|
2921
|
-
},
|
|
2922
|
-
let [i, a] =
|
|
2921
|
+
}, or = (e, t, n, r = window.location.origin) => {
|
|
2922
|
+
let [i, a] = C(), [o, s] = C(!0), [c, l] = C(null), u = S(0), d = v(async (i = [re.View]) => {
|
|
2923
2923
|
let o = ++u.current;
|
|
2924
2924
|
s(!0), l(null);
|
|
2925
2925
|
try {
|
|
@@ -2929,9 +2929,9 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2929
2929
|
access: i
|
|
2930
2930
|
} });
|
|
2931
2931
|
u.current === o && a({
|
|
2932
|
-
url:
|
|
2932
|
+
url: ar(s.url, r),
|
|
2933
2933
|
expiresInDays: s.expiresInDays,
|
|
2934
|
-
access:
|
|
2934
|
+
access: ir(s.access)
|
|
2935
2935
|
});
|
|
2936
2936
|
} catch (e) {
|
|
2937
2937
|
u.current === o && l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to create share link"));
|
|
@@ -2944,22 +2944,22 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2944
2944
|
n,
|
|
2945
2945
|
e
|
|
2946
2946
|
]);
|
|
2947
|
-
return
|
|
2947
|
+
return y(() => {
|
|
2948
2948
|
a(void 0), d();
|
|
2949
2949
|
}, [t, d]), {
|
|
2950
2950
|
data: i,
|
|
2951
2951
|
isLoading: o,
|
|
2952
2952
|
error: c,
|
|
2953
|
-
setAccess:
|
|
2953
|
+
setAccess: v((e) => {
|
|
2954
2954
|
d(e);
|
|
2955
2955
|
}, [d])
|
|
2956
2956
|
};
|
|
2957
|
-
},
|
|
2957
|
+
}, sr = /* @__PURE__ */ function(e) {
|
|
2958
2958
|
return e.Idle = "idle", e.Loading = "loading", e.Resolved = "resolved", e.Unknown = "unknown", e;
|
|
2959
|
-
}({}),
|
|
2960
|
-
let [t, n] =
|
|
2959
|
+
}({}), cr = { status: "idle" }, lr = (e) => {
|
|
2960
|
+
let [t, n] = C({}), r = S(/* @__PURE__ */ new Set());
|
|
2961
2961
|
return {
|
|
2962
|
-
requestRecipientsCount:
|
|
2962
|
+
requestRecipientsCount: v((t) => {
|
|
2963
2963
|
r.current.has(t) || (r.current.add(t), n((e) => ({
|
|
2964
2964
|
...e,
|
|
2965
2965
|
[t]: { status: "loading" }
|
|
@@ -2981,32 +2981,32 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
2981
2981
|
}
|
|
2982
2982
|
})());
|
|
2983
2983
|
}, [e]),
|
|
2984
|
-
getRecipientsCount:
|
|
2985
|
-
invalidateRecipientsCount:
|
|
2984
|
+
getRecipientsCount: v((e) => t[e] ?? cr, [t]),
|
|
2985
|
+
invalidateRecipientsCount: v((e) => {
|
|
2986
2986
|
r.current.delete(e), n(({ [e]: t, ...n }) => n);
|
|
2987
2987
|
}, [])
|
|
2988
2988
|
};
|
|
2989
|
-
},
|
|
2990
|
-
let { deepResearchToolId: t, selectedItemId: n, selectedDeploymentConfiguration: r } = e, i =
|
|
2991
|
-
...
|
|
2989
|
+
}, ur = { deepResearchFallback: "Deep research" }, dr = (e) => {
|
|
2990
|
+
let { deepResearchToolId: t, selectedItemId: n, selectedDeploymentConfiguration: r } = e, i = x(() => ({
|
|
2991
|
+
...ur,
|
|
2992
2992
|
...e.labels
|
|
2993
|
-
}), [e.labels]), a = e.toolIcon, o =
|
|
2993
|
+
}), [e.labels]), a = e.toolIcon, o = x(() => {
|
|
2994
2994
|
if (t == null || r == null) return null;
|
|
2995
2995
|
let e = r.properties?.[t];
|
|
2996
2996
|
return e == null || !(e.type === "boolean" || e.type == null && typeof e.default == "boolean") ? null : e;
|
|
2997
|
-
}, [t, r]), s =
|
|
2998
|
-
|
|
2997
|
+
}, [t, r]), s = x(() => typeof o?.default == "boolean" ? o.default : !1, [o]), [c, l] = C(s);
|
|
2998
|
+
y(() => {
|
|
2999
2999
|
l(s);
|
|
3000
3000
|
}, [n, s]);
|
|
3001
|
-
let u =
|
|
3001
|
+
let u = v((e) => {
|
|
3002
3002
|
e === t && l((e) => !e);
|
|
3003
|
-
}, [t]), d =
|
|
3003
|
+
}, [t]), d = v((e) => {
|
|
3004
3004
|
if (t == null) return;
|
|
3005
3005
|
let n = e?.[t];
|
|
3006
3006
|
typeof n == "boolean" && l(n);
|
|
3007
3007
|
}, [t]);
|
|
3008
3008
|
return {
|
|
3009
|
-
toolsMenuItems:
|
|
3009
|
+
toolsMenuItems: x(() => o == null || t == null ? [] : [{
|
|
3010
3010
|
id: t,
|
|
3011
3011
|
label: typeof o.title == "string" && o.title || i.deepResearchFallback,
|
|
3012
3012
|
icon: a ?? null,
|
|
@@ -3019,7 +3019,7 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
3019
3019
|
a
|
|
3020
3020
|
]),
|
|
3021
3021
|
onToolToggle: u,
|
|
3022
|
-
toolConfigurationValue:
|
|
3022
|
+
toolConfigurationValue: x(() => t == null || o == null ? {} : { [t]: c }, [
|
|
3023
3023
|
t,
|
|
3024
3024
|
o,
|
|
3025
3025
|
c
|
|
@@ -3028,4 +3028,4 @@ var H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) ||
|
|
|
3028
3028
|
};
|
|
3029
3029
|
};
|
|
3030
3030
|
//#endregion
|
|
3031
|
-
export {
|
|
3031
|
+
export { he as AttachmentValidationErrorReason, Jt as COLUMNS_WITHOUT_AUTHOR, Yt as COLUMNS_WITH_AUTHOR, Xt as CORE_PERMISSION_MAP, ye as ConversationExportMode, G as ConversationTransferErrorCode, W as ConversationTransferJobStatus, be as ConversationTransferSubjectKind, xe as ConversationTransferWarningCode, qt as DATE_OPTIONS, Qt as DialFileManagerActionProfile, Zt as DialFileManagerVariant, Ut as DialFilesApiUploadMode, kn as DownloadDestinationType, Se as EXPORT_APP_NAME, U as ExportFileNameKind, q as FileManagerNotificationReason, J as FileNameValidationErrorReason, Y as FileOperationKind, $ as FileUploadStatus, Kt as PATH_SEPARATOR_REGEXP, Gt as RESERVED_MARKER_NAME, sr as RecipientsCountStatus, Wt as UPLOAD_CONCURRENCY, it as attachmentToDto, at as attachmentsToDtos, Sn as buildFromCache, dn as buildSharedItemVirtualPath, ot as createMessagePair, $t as deriveActionProfile, un as dialCorePathToRelative, oe as downloadAttachment, Tn as fetchByTab, En as fetchForSearch, on as findDialFileByPath, xn as findFirstSuccessfulCopyMoveItem, rn as findFolderByVirtualPath, ve as formatDateYM, _e as formatDateYMD, nn as formatOperationFolderName, Ve as formatQuotedNameList, K as getConversationPath, ut as getStarterConversationText, dt as getStarterSubmitText, tn as getVirtualPathName, st as hasActiveToolConfig, an as hasDialFileWritePermission, en as hasForbiddenNameSymbols, Pt as isAwaitingGenerationResume, sn as isCopyMoveDuplicateAllowed, ie as isDialFileId, ae as isDownloadableAttachment, ct as isMessageChanged, cn as isShareActionsAllowed, bn as mapCorePermissions, On as mapFileMetadataToDialFile, Dn as mapSearchItem, Cn as mergeCreatedFolderIntoCache, Z as normalizeVirtualPath, ln as parseNewFolderVirtualPath, vn as prepareCopyItems, yn as prepareMoveRenameItems, fn as resolveOwnerCoords, Mn as sanitizeFileName, wn as updateEntry, le as useAttachmentAction, Je as useAttachmentUpload, ge as useAttachmentValidation, $n as useChatSettingsFormConfig, rt as useConversationExport, pt as useConversationHandlers, At as useConversationImport, Nt as useConversationScroll, Ht as useConversationSources, Bt as useConversationStream, Nn as useDialFileListing, Wn as useDialFileManager, Kn as useDialFileManagerTabConfig, Pn as useDialFileMetadata, Fn as useDialFileMutations, In as useDialFileSharing, Un as useDialFileUploadBatch, Xn as useGridEditingScroll, er as usePageFileDrag, rr as usePanelMaxWidth, or as useShareLink, lr as useShareRecipientsCount, dr as useToolsMenu, nr as useViewportWidth };
|