@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/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, getUtf8ByteLength as c, messageAttachmentToDisplayAttachment as l, triggerAnchorDownload as u, triggerBlobDownload as d, truncateToUtf8Bytes as f } from "@epam/ai-dial-chat-shared";
3
- import { isReferenceOnlyAttachment as p, normalizeRawAnnotations as m, parsePdfPageReference as h, resolveMessageAnnotations as g } from "@epam/ai-dial-quotations";
4
- import { useCallback as _, useEffect as v, useLayoutEffect as y, useMemo as b, useRef as x, useState as S } from "react";
5
- import { isMimeTypeAllowed as C, mimeTypesToExtensionLabels as w } from "@epam/ai-dial-attachment-input";
6
- import { strFromU8 as T, strToU8 as E, unzipSync as D, zipSync as O } from "fflate";
7
- import { ArchiveItemDtoNodeTypeEnum as k, CopyItemDtoNodeTypeEnum as A, DeleteItemDtoNodeTypeEnum as j, ListFilesItemDtoNodeTypeEnum as M, MoveItemDtoNodeTypeEnum as N, RenameItemDtoNodeTypeEnum as P, SendCompletionDtoModeEnum as F, ShareLinkResponseDtoAccessEnum as I } from "@epam/ai-dial-chat-api-client";
8
- import { DialFileManagerActions as L, DialFileManagerTabs as R, DialFileNodeType as z, DialFilePermission as ee, FileManagerColumnKey as B } from "@epam/ai-dial-react-file-manager";
9
- import { NOT_ALLOWED_SYMBOLS as te, NOT_ALLOWED_SYMBOLS_REGEXP as ne, NotificationVariant as V } from "@epam/ai-dial-ui-kit";
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 H = (e) => e.startsWith("files/"), ie = (e) => e.url != null && H(e.url) || e.data != null, ae = (e, t) => {
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 && H(n)) {
14
+ if (n != null && ie(n)) {
15
15
  let e = t(n);
16
- return e == null ? !1 : (u(e, r), !0);
16
+ return e == null ? !1 : (d(e, r), !0);
17
17
  }
18
- return o == null ? !1 : (d(s(o, a || i.Plain), r), !0);
19
- }, oe = (e, t) => {
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 (H(r)) {
23
+ if (ie(r)) {
24
24
  let n = t(r);
25
25
  if (n == null) return;
26
- u(n, e.title ?? r.split("/").pop() ?? "");
26
+ d(n, e.title ?? r.split("/").pop() ?? "");
27
27
  } else window.open(n, "_blank", "noopener,noreferrer");
28
- }, se = (t, n) => {
29
- let r = h(t.url);
28
+ }, ce = (t, n) => {
29
+ let r = g(t.url);
30
30
  if (r == null) return null;
31
- let i = H(r.baseUrl) ? n(r.baseUrl) : r.baseUrl;
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
- }, ce = ({ resolveDownloadUrl: e }) => {
57
+ }, le = ({ resolveDownloadUrl: e }) => {
58
58
  let { openCanvas: n } = t();
59
- return { handleAttachmentClick: _((t) => {
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
- ae(t, e);
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 = se(s, e);
70
+ }, c = ce(s, e);
71
71
  if (c) {
72
72
  n(c, o);
73
73
  return;
74
74
  }
75
- oe(s, e);
75
+ se(s, e);
76
76
  }, [n, e]) };
77
- }, le = 100, ue = "*/*", de = (e) => e.startsWith(".") || e.includes("/"), fe = (e) => {
78
- if (e != null) return e.map((e) => e === "*" ? ue : e).filter(de);
79
- }, pe = (e) => {
80
- let t = fe(e);
81
- if (!(t == null || t.length === 0) && !t.some((e) => e === ue)) return t.join(",");
82
- }, me = /* @__PURE__ */ function(e) {
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
- }({}), he = ({ allowedMimeTypes: e, onValidationError: t, debounceMs: r = le }) => {
85
- let i = e.length > 0, a = b(() => pe(e), [e]), o = x(null);
86
- return v(() => () => {
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: _((i) => {
92
- if (!C(i.contentType, e)) return o.current != null && clearTimeout(o.current), o.current = setTimeout(() => {
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: w(e) }
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
- }, ge = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, _e = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, ve = /* @__PURE__ */ function(e) {
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
- }({}), ye = /* @__PURE__ */ function(e) {
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
- }({}), be = /* @__PURE__ */ function(e) {
117
+ }({}), xe = /* @__PURE__ */ function(e) {
118
118
  return e.AttachmentSkipped = "attachmentSkipped", e;
119
- }({}), xe = "ai_dial", Se = (e, t = []) => ({
119
+ }({}), Se = "ai_dial", Ce = (e, t = []) => ({
120
120
  version: 5,
121
121
  history: e,
122
122
  folders: t
123
- }), Ce = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), we = {
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
- }, Te = (e, t, n = /* @__PURE__ */ new Date()) => `${ge(n)}_${t}_${e}.${we[e]}`, Ee = (e) => e.startsWith("files/"), De = (e) => {
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 && Ee(n) && t.add(n);
131
+ n != null && De(n) && t.add(n);
132
132
  }
133
133
  return Array.from(t, (e) => ({ fileId: e }));
134
- }, Oe = (e) => e.startsWith("files/"), ke = (e) => {
135
- if (!Oe(e)) return;
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
- }, Ae = class extends Error {
148
+ }, je = class extends Error {
149
149
  constructor(e) {
150
150
  super(e), this.name = "UnsupportedImportFormatError";
151
151
  }
152
- }, je = (e) => typeof e == "object" && !!e, Me = 5, Ne = (e) => {
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 Ae("Import file is not valid JSON");
157
+ throw new je("Import file is not valid JSON");
158
158
  }
159
- if (!je(t) || t.version !== Me || !Array.isArray(t.history)) throw new Ae("Import file is not a supported export format");
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: Me,
162
+ version: Ne,
163
163
  history: t.history,
164
164
  folders: n
165
165
  };
166
- }, Pe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, Fe = (e) => {
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 Pe.test(n) ? e.slice(0, t) : e;
171
- }, Ie = "conversations/", Le = (e) => e.startsWith(Ie) ? e.slice(14) : e, Re = (e, t) => {
172
- let n = Le(e.id), r = n.split("/"), i = Le(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = `${Fe(s.at(-1) ?? r.at(-1) ?? n)}__${crypto.randomUUID()}`, u = [
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
- ...c,
175
- l
176
- ].join("/"), d = o.length ? `${t}/${o.join("/")}` : t;
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}/${u}`,
181
- folderId: d
180
+ id: `${t}/${d}`,
181
+ folderId: f
182
182
  },
183
- subPath: u
183
+ subPath: d
184
184
  };
185
- }, ze = (e) => {
186
- let t = Le(e.folderId).split("/").filter(Boolean).slice(1);
185
+ }, Be = (e) => {
186
+ let t = Re(e.folderId).split("/").filter(Boolean).slice(1);
187
187
  return t.length ? t.join(" / ") : void 0;
188
- }, Be = (e) => e.map((e) => `"${e}"`).join(", "), Ve = (e, t) => ({
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
- }), He = (e) => e.split("/").pop() || e, Ue = (e, t, n) => {
210
+ }), Ue = (e) => e.split("/").pop() || e, We = (e, t, n) => {
211
211
  let r = [], i = [];
212
- for (let a of De(e)) {
213
- let e = ke(a.fileId);
212
+ for (let a of Oe(e)) {
213
+ let e = Ae(a.fileId);
214
214
  if (!e) {
215
- i.push(He(a.fileId));
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
- }, We = 700, Ge = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", Ke = (e, t = /* @__PURE__ */ new Date()) => `uploads/${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}/${encodeURIComponent(Ge(e))}`, qe = ({ filesApi: e, bucket: t, onNetworkError: r, debounceMs: i = We }) => {
235
- let a = x([]), o = x(null);
236
- return { handleUploadAttachment: _(async (s) => {
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: Ke(s.name),
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
- }, Je = async (e, t, n) => {
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
- }, Ye = () => {
276
- let [e, t] = S([]), n = x(/* @__PURE__ */ new Map()), r = x(/* @__PURE__ */ new Map()), i = _((e, n) => {
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 = _((e) => {
282
- let n = crypto.randomUUID();
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 = _((e) => {
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 = _((e) => {
290
+ }, []), s = v((e) => {
291
291
  r.current.get(e)?.();
292
- }, []), c = _(() => {
292
+ }, []), l = v(() => {
293
293
  for (let e of n.current.values()) e.abort();
294
294
  n.current.clear(), r.current.clear(), t([]);
295
- }, []), l = _((e, t) => {
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 v(() => {
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: c,
314
- startJob: l
313
+ dismissAll: l,
314
+ startJob: u
315
315
  };
316
- }, Xe = E("", !0).constructor, Ze = (e) => e instanceof Xe ? e : new Xe(e), Qe = (e) => e.length > 0 && e.split("/").every((e) => e !== "" && e !== "." && e !== ".."), $e = (e, t) => {
317
- let n = [], r = { "conversation.json": Ze(E(JSON.stringify(e, null, 2))) };
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 (!Qe(e.path)) {
319
+ if (!$e(e.path)) {
320
320
  n.push(e.path);
321
321
  continue;
322
322
  }
323
- r[`res/${e.path}`] = Ze(e.data);
323
+ r[`res/${e.path}`] = Qe(e.data);
324
324
  }
325
- let i = O(r);
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
- }, et = 5, tt = (e) => !e.sharedWithMe && !e.publishedWithMe, nt = ({ conversationsApi: e, filesApi: t, normalizeConversationPath: n, classifyTransferError: r = () => ({}), resolveErrorTraceId: i = async () => void 0, onSuccess: a, onWarning: o, onError: s }) => {
331
- let c = Ye(), l = _(async (e, n) => {
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 Je(e, et, async (e) => {
334
+ entries: await Ye(e, tt, async (e) => {
335
335
  if (n.aborted || a) return;
336
- let o = ke(e.fileId);
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 = _(async (t, u, f, p, m) => {
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: [f],
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 === ve.WithoutAttachments) {
387
- d(Ce(Se([h], [])), Te(U.SingleConversation, xe)), a?.({
386
+ if (p === ye.WithoutAttachments) {
387
+ f(we(Ce([h], [])), Ee(U.SingleConversation, Se)), a?.({
388
388
  jobId: t,
389
- titles: [f]
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(De(h), m);
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 } = $e(Se([h], []), e);
402
+ let { blob: i, skippedPaths: u } = et(Ce([h], []), e);
403
403
  (n || u.length > 0) && o?.({
404
404
  jobId: t,
405
- code: be.AttachmentSkipped
406
- }), d(i, Te(U.SingleConversationWithAttachments, xe)), a?.({
405
+ code: xe.AttachmentSkipped
406
+ }), f(i, Ee(U.SingleConversationWithAttachments, Se)), a?.({
407
407
  jobId: t,
408
- titles: [f]
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: [f],
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
- ]), f = _((e, t, n) => {
430
+ ]), d = v((e, t, n) => {
431
431
  let r = c.addJob({
432
- kind: ye.Single,
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 = _(async (t, o) => {
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(tt).map((e) => ({
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 f = [];
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
- f.push(t);
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
- d(Ce(Se(f, [])), Te(U.AllConversationsHistory, xe)), a?.({ jobId: t }), c.updateJob(t, { status: W.Success });
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: ye.All });
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: f,
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
- }, rt = (e) => {
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
- }, it = (e) => {
538
- if (e.length) return e.map(rt);
539
- }, at = (e, t, n) => {
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
- }, ot = (e) => e != null && Object.keys(e).length > 0, st = (e, t, n, r) => {
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
- }, ct = (e) => e["dial:widgetOptions"].populateText || e.title, lt = (e, t) => {
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 : ct(e);
562
- }, ut = (e, t) => {
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 ?? ct(e);
565
- }, dt = (e) => {
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 dt(t === -1 ? e : e.substring(t + 1));
574
- }, ft = ({ conversation: e, conversationId: t, bucket: n, isStreaming: r, startStream: i, state: { setConversation: o, conversationRef: s }, filesApi: c, conversationsApi: l, rateApi: u, resolveModelId: d, onConversationDeleted: f, showNetworkError: p, toolConfigurationValue: m }) => {
575
- let [h, g] = S(null), [v, y] = S(/* @__PURE__ */ new Set()), [b, x] = S(null), { handleUploadAttachment: C } = qe({
576
- filesApi: c,
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: p
579
- }), w = _(async (n, r) => {
578
+ onNetworkError: m
579
+ }), T = v(async (n, r) => {
580
580
  if (!t || !e) return;
581
- let a = it(r), c = ot(m), l = a?.length || c ? {
581
+ let a = at(r), l = st(h), u = a?.length || l ? {
582
582
  ...a?.length ? { attachments: a } : {},
583
- ...c ? { configuration_value: m } : {}
584
- } : void 0, u = d(), { userMessage: f, assistantMessage: p } = at(n, l, u);
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
- f,
592
- p
591
+ p,
592
+ m
593
593
  ]
594
594
  };
595
595
  return s.current = t, t;
596
- }), i(t, n, e.messages.length + 1, u, l, crypto.randomUUID(), F.Append);
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
- d,
601
+ f,
602
602
  o,
603
603
  i,
604
- m
605
- ]), T = _((n) => {
604
+ h
605
+ ]), E = v((n) => {
606
606
  if (r || !t || !e || n === -1 || e.messages[n]?.role !== a.Assistant) return;
607
- let c = e.messages[n - 1];
608
- if (!c || c.role !== a.User) return;
609
- let l = d();
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: l
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
- }), y((e) => new Set([...e].filter((e) => e < n))), i(t, c.content, n, l, c.custom_content, crypto.randomUUID(), F.Regenerate);
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
- d,
631
+ f,
632
632
  o,
633
633
  i
634
- ]), E = _((e) => {
635
- r || g(e);
636
- }, [r]), D = _(() => {
637
- if (!t || h == null) return;
638
- g(null);
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 = h;
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 l.deleteConversation({ path: e }), f?.(), t;
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, l.saveConversation({
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
- l,
659
- f,
660
- h,
658
+ u,
659
+ p,
660
+ g,
661
661
  o
662
- ]), O = _(async (n, r, i) => {
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, d = {
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 = d, d));
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 = () => l.saveConversation({
682
+ }, m = () => u.saveConversation({
683
683
  path: f,
684
- saveConversationBodyDto: { conversation: d }
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 u.rateMessage({ rateMessageDto: {
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
- ]), k = _((n, r, a) => {
712
+ ]), A = v((n, r, a) => {
713
713
  if (!t || !e) return;
714
- let c = a ?? n.title, l = ut(n, a), u = r ? { [r]: n.const } : void 0, f = ot(m), p = u || f ? {
715
- ...u ? { form_value: u } : {},
716
- ...f ? { configuration_value: m } : {}
717
- } : void 0, h = d(), { userMessage: g, assistantMessage: _ } = at(c, p, h);
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
- g,
725
- _
724
+ _,
725
+ v
726
726
  ]
727
727
  };
728
728
  return s.current = t, t;
729
- }), i(t, l, e.messages.length + 1, h, p, crypto.randomUUID(), F.Append);
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
- d,
734
+ f,
735
735
  o,
736
736
  i,
737
- m
737
+ h
738
738
  ]);
739
739
  return {
740
- handleSend: w,
741
- handleUploadAttachment: C,
742
- handleRegenerateMessage: T,
743
- handleDeleteMessage: E,
744
- handleConfirmDelete: D,
745
- handleRateMessage: O,
746
- handleButtonSelect: _((n, i, a) => {
747
- !t || !e || r || (n["dial:widgetOptions"].confirmationMessage ? x({
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
- }) : k(n, i, a));
751
+ }) : A(n, i, a));
752
752
  }, [
753
753
  e,
754
754
  t,
755
755
  r,
756
- k
756
+ A
757
757
  ]),
758
- handleConfirmStarter: _(() => {
759
- if (!b) return;
760
- let { starter: e, propertyKey: t, description: n } = b;
761
- x(null), k(e, t, n);
762
- }, [b, k]),
763
- handleStartEdit: _((e) => {
764
- y((t) => new Set([...t, e]));
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: _((e) => {
767
- y((t) => {
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: _(async (n, c, l, u) => {
772
+ handleEditMessage: v(async (n, l, u, d) => {
773
773
  if (r || !t || !e) return;
774
- let f = n;
775
- if (f === -1 || e.messages[f].role !== a.User) return;
776
- let p = e.messages[f];
777
- if (!st(p, c, l, u)) {
778
- y((e) => {
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(f), t;
780
+ return t.delete(p), t;
781
781
  });
782
782
  return;
783
783
  }
784
- let m = it(u), h = new Set(l.map((e) => e.id)), g = [...(p.custom_content?.attachments ?? []).filter((e) => {
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 h.has(t);
787
- }), ...m ?? []], { attachments: _, ...v } = p.custom_content ?? {}, b = g.length > 0 ? {
788
- ...v,
789
- attachments: g
790
- } : Object.keys(v).length > 0 ? v : void 0, x = {
791
- ...p,
792
- content: c,
793
- custom_content: b
794
- }, S = Date.now(), C = {
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(S).toISOString()
798
- }, w = [
799
- ...e.messages.slice(0, f),
800
- x,
801
- C
802
- ], T = {
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: w
804
+ messages: T
805
805
  };
806
- o(() => (s.current = T, T));
807
- let E = d();
808
- i(t, c, w.length - 1, E, b, crypto.randomUUID(), F.Edit), y(/* @__PURE__ */ new Set());
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
- d,
814
+ f,
815
815
  o,
816
816
  i
817
817
  ]),
818
- editingMessageIndexes: v,
819
- pendingDeleteIndex: h,
820
- setPendingDeleteIndex: g,
821
- pendingStarterContext: b,
822
- setPendingStarterContext: x
818
+ editingMessageIndexes: y,
819
+ pendingDeleteIndex: g,
820
+ setPendingDeleteIndex: _,
821
+ pendingStarterContext: x,
822
+ setPendingStarterContext: S
823
823
  };
824
- }, pt = (e) => {
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
- }, mt = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", ht = (e, t, n) => n === 0 ? `${e}${t}` : `${e} (${n})${t}`, gt = (e) => {
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 } = pt(mt(e)), a = 0, o = ht(r, i, a);
835
- for (; n.has(o);) a += 1, o = ht(r, i, a);
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/${_e(t)}/${encodeURIComponent(o)}`,
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
- }, _t = "conversation.json", vt = /^conversations\/.*\.json$/, yt = "res/", bt = (e) => e.find((e) => e === _t) ?? e.find((e) => vt.test(e)) ?? e.find((e) => !e.includes("/") && e.toLowerCase().endsWith(".json")), xt = (e) => new Promise((t, n) => {
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
- }), St = async (e) => {
850
- let t = await xt(e), n;
849
+ }), Ct = async (e) => {
850
+ let t = await St(e), n;
851
851
  try {
852
- n = D(t);
852
+ n = O(t);
853
853
  } catch {
854
- throw new Ae("Import file is not a valid archive");
854
+ throw new je("Import file is not a valid archive");
855
855
  }
856
- let r = Object.keys(n), i = bt(r);
857
- if (!i) throw new Ae("Archive does not contain a readable conversation-JSON entry");
858
- let a = Ne(T(n[i])), o = /* @__PURE__ */ new Map();
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(yt)) continue;
860
+ if (e.endsWith("/") || !e.startsWith(bt)) continue;
861
861
  let t = e.slice(4);
862
- !t || !Qe(t) || o.set(t, n[e]);
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
- }, Ct = 5, wt = 5, Tt = (e) => /\.(dial|zip)$/i.test(e.name), Et = (e) => new Promise((t, n) => {
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
- }), Dt = async (e) => {
872
- if (Tt(e)) {
873
- let { envelope: t, attachments: n } = await St(e);
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: Ne(await Et(e)).history,
881
+ history: Pe(await Dt(e)).history,
882
882
  attachments: /* @__PURE__ */ new Map(),
883
883
  isArchive: !1
884
884
  };
885
- }, Ot = async (e, t, n, r, i, a, o) => {
886
- let { plan: s, skippedNames: c } = Ue(e, t, r), l = !1, u = await Je(s, Ct, async (e) => {
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 <= wt; s += 1) try {
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 === wt) return {
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
- }, kt = ({ conversationsApi: e, filesApi: t, bucket: n, onImported: r, classifyTransferError: i = () => ({}), resolveErrorTraceId: a = async () => void 0, onSuccess: o, onWarning: s, onError: c }) => {
929
- let l = Ye(), u = _(async (u, d, f) => {
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
- c?.({
932
- jobId: u,
931
+ l?.({
932
+ jobId: c,
933
933
  code: G.MissingBucket
934
- }), l.updateJob(u, { status: W.Failed });
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/${_e(v)}`, r = [];
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
- c?.({
949
- jobId: u,
948
+ l?.({
949
+ jobId: c,
950
950
  code: G.Unauthorized
951
- }), l.updateJob(u, { status: W.Failed });
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 = gt({
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 Ot(r, d.attachments, n, b, t, y, f);
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 } = Re(Ve(r, i), n);
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
- c?.({
996
- jobId: u,
995
+ l?.({
996
+ jobId: c,
997
997
  code: G.Unauthorized
998
- }), l.updateJob(u, { status: W.Failed });
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: u,
1006
+ jobId: c,
1007
1007
  titles: p
1008
1008
  });
1009
1009
  }
1010
- m.length > 0 && c?.({
1011
- jobId: u,
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: u,
1017
- code: be.AttachmentSkipped,
1016
+ jobId: c,
1017
+ code: xe.AttachmentSkipped,
1018
1018
  names: h
1019
- }), l.updateJob(u, { status: m.length > 0 ? W.Failed : W.Success });
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
- c,
1026
+ l,
1027
1027
  r,
1028
1028
  o,
1029
1029
  s,
1030
- l,
1030
+ u,
1031
1031
  a
1032
- ]), d = _(async (e) => {
1032
+ ]), f = v(async (e) => {
1033
1033
  let t;
1034
1034
  try {
1035
- t = await Dt(e);
1035
+ t = await Ot(e);
1036
1036
  } catch (e) {
1037
- c?.({
1038
- jobId: crypto.randomUUID(),
1037
+ l?.({
1038
+ jobId: c(),
1039
1039
  code: G.UnsupportedFormat
1040
- }), e instanceof Ae || console.error("Failed to parse import file", e);
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: ye.All } : {
1044
- kind: ye.Single,
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 ? ze(r) : void 0
1047
- }, a = l.addJob(i);
1048
- return l.startJob(a, (e) => u(a, t, e));
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: l.jobs,
1056
- importConversations: d,
1057
- dismissJob: l.dismissJob,
1058
- retryJob: l.retryJob,
1059
- dismissAll: l.dismissAll
1055
+ jobs: u.jobs,
1056
+ importConversations: f,
1057
+ dismissJob: u.dismissJob,
1058
+ retryJob: u.retryJob,
1059
+ dismissAll: u.dismissAll
1060
1060
  };
1061
- }, At = 80, jt = 1, Mt = ({ messages: e, isAssistantTyping: t, conversationId: n }) => {
1062
- let [r, i] = S(!1), a = x(null), o = x(null), s = x(null), c = x(!1), l = x(!1), u = x(null), d = x(/* @__PURE__ */ new Map()), f = _((e, t) => {
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 = x(null), m = _((e) => {
1064
+ }, []), p = S(null), m = v((e) => {
1065
1065
  p.current = e;
1066
- }, []), h = _((e, t) => {
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
- }, []), b = _(() => {
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
- }, []), C = _((e = !1) => {
1080
- let t = b();
1079
+ }, []), x = v((e = !1) => {
1080
+ let t = _();
1081
1081
  t != null && h(Math.max(t, 0), e);
1082
- }, [h, b]), w = _(() => {
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 = _((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 = _((e, t = !1) => {
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 = b();
1099
+ }, [E, h]), O = v(() => {
1100
+ let e = _();
1101
1101
  return e == null ? null : Math.max(e, 0);
1102
- }, [b]), k = _(() => {
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 + jt && (e.scrollTop = t);
1109
- }, [k]), j = _((e) => {
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 = _((e) => {
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 >= At);
1124
- }, [w]), P = x(e.length), F = x(null);
1125
- y(() => {
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) && C(!1), a());
1135
+ t || ((r || i) && x(!1), a());
1136
1136
  }, [
1137
1137
  e,
1138
1138
  t,
1139
1139
  n,
1140
- C,
1140
+ x,
1141
1141
  M,
1142
1142
  g
1143
- ]), y(() => {
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 v(() => {
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]), v(() => {
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
- C(!1);
1175
- }, [C]),
1173
+ scrollToBottom: v(() => {
1174
+ x(!1);
1175
+ }, [x]),
1176
1176
  armAnchor: m
1177
1177
  };
1178
- }, Nt = (e) => {
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
- }, Pt = (e, t) => {
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
- }, Ft = (e, t) => {
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
- }, It = (e, t) => {
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 ? Ft(n[t].attachments ?? [], e.attachments) : n[t].attachments
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
- }, Lt = (e, t, n) => {
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 ? m(l, r) : [], p = [...c ?? [], ...d], h = a || o?.length || s?.length || p.length || u;
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
- ...h && { custom_content: {
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: It(e.custom_content?.stages ?? [], s) },
1242
- ...p.length && { annotations: Pt(e.custom_content?.annotations ?? [], p) },
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
- }, Rt = 300 * 1e3, zt = ({ conversationId: e, state: { setConversation: t, conversationRef: n }, transport: r, generation: { startGeneration: i, completeGeneration: a }, channel: o, overlay: s, onStopError: c }) => {
1248
- let [l, u] = S(() => /* @__PURE__ */ new Set()), [d, f] = S(null), p = x(null), m = x(null), h = x(/* @__PURE__ */ new Set()), g = x(/* @__PURE__ */ new Set()), y = x(e);
1249
- v(() => {
1250
- y.current = e;
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 b = _((e) => K(y.current ?? "") === e, []), C = _((e) => {
1253
- u((t) => {
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
- }, []), w = _((e) => {
1259
- u((t) => {
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
- }, []), T = _((e, c, l, u, d, h, _ = F.Append) => {
1265
- let v = h ?? crypto.randomUUID(), y = K(e);
1266
- p.current = v, m.current = y, f(y);
1267
- let x;
1268
- _ === F.Regenerate ? x = l : _ === F.Edit && (x = l - 1);
1269
- let S = i(y, v);
1270
- C(y), s?.notifyGenerationStart?.(), o?.ensureConnected(), r.streamCompletion(y, c, u, {
1271
- signal: S.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
- p.current === v && b(y) && t((t) => {
1273
+ m.current === y && x(b) && t((t) => {
1274
1274
  if (!t) return t;
1275
- let r = Lt(t.messages, l, e);
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 (w(y), p.current === v && (p.current = null, m.current = null, f(null)), a(y, v), g.current.has(v) ? g.current.delete(v) : s?.notifyGenerationEnd?.(), b(y)) try {
1286
- let i = await r.getConversation(dt(e));
1287
- if (!b(y)) return;
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
- w(y), p.current === v && (p.current = null, m.current = null, f(null)), b(y) && t((t) => {
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 === l ? {
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
- }, d, v, _, x, o?.channelId ?? void 0);
1304
+ }, f, y, v, S, o?.channelId ?? void 0);
1305
1305
  }, [
1306
1306
  i,
1307
1307
  a,
1308
- C,
1309
1308
  w,
1310
- b,
1309
+ T,
1310
+ x,
1311
1311
  o?.channelId,
1312
1312
  o?.ensureConnected,
1313
1313
  s,
1314
1314
  r
1315
- ]), E = _(() => {
1316
- let t = p.current;
1315
+ ]), D = v(() => {
1316
+ let t = m.current;
1317
1317
  if (!t || !e) return;
1318
1318
  let n = K(e);
1319
- m.current === n && (g.current.add(t), s?.notifyStopGenerating?.(), r.stopCompletion({
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
- c?.(t);
1324
+ l?.(t);
1325
1325
  }));
1326
1326
  }, [
1327
1327
  e,
1328
- c,
1328
+ l,
1329
1329
  s,
1330
1330
  r
1331
- ]), D = _((e, i) => {
1332
- if (!Nt(i)) return;
1331
+ ]), O = v((e, i) => {
1332
+ if (!Pt(i)) return;
1333
1333
  let a = K(e);
1334
- if (h.current.has(a)) return;
1335
- h.current.add(a), C(a);
1334
+ if (g.current.has(a)) return;
1335
+ g.current.add(a), w(a);
1336
1336
  let o = new AbortController(), s = (e) => {
1337
- h.current.delete(a), w(a), e && b(a) && (t(e), n.current = e);
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(dt(e)));
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
- }, Rt);
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(dt(e));
1374
- if (!Nt(t)) {
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
- b,
1388
+ T,
1389
+ x,
1390
1390
  r
1391
- ]), O = e != null && l.has(K(e)), k = e == null ? null : K(e);
1391
+ ]), k = e != null && u.has(K(e)), A = e == null ? null : K(e);
1392
1392
  return {
1393
- startStream: T,
1394
- handleStop: E,
1395
- resumeIfAwaitingGeneration: D,
1396
- isStreaming: O,
1397
- canStopStreaming: k != null && d === k
1393
+ startStream: E,
1394
+ handleStop: D,
1395
+ resumeIfAwaitingGeneration: O,
1396
+ isStreaming: k,
1397
+ canStopStreaming: A != null && f === A
1398
1398
  };
1399
- }, Bt = {}, Vt = (e, t = Bt) => b(() => {
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 u of e) {
1402
- let e = u.custom_content?.attachments;
1403
- if (u.role === a.User) for (let r of e ?? []) {
1404
- let e = l(r, t);
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 (u.role === a.Assistant) {
1408
- let n = e?.filter((e) => !p(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 = l(e, t);
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 (!p(t)) continue;
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 g(u)) {
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]), Ht = /* @__PURE__ */ function(e) {
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
- }({}), Ut = 3, Wt = r, Gt = /[/\\]/, Kt = {
1447
+ }({}), Wt = 3, Gt = r, Kt = /[/\\]/, qt = {
1448
1448
  year: "numeric",
1449
1449
  month: "short",
1450
1450
  day: "2-digit"
1451
- }, qt = [
1452
- B.Name,
1453
- B.UpdatedAt,
1454
- B.Size,
1455
- B.Actions
1456
- ], Jt = [
1457
- B.Name,
1458
- B.UpdatedAt,
1459
- B.Size,
1460
- B.Author,
1461
- B.Actions
1462
- ], Yt = {
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
- }, Xt = /* @__PURE__ */ function(e) {
1466
+ }, Zt = /* @__PURE__ */ function(e) {
1467
1467
  return e.Attach = "attach", e.Standalone = "standalone", e.FolderPicker = "folder-picker", e;
1468
- }({}), Zt = /* @__PURE__ */ function(e) {
1468
+ }({}), Qt = /* @__PURE__ */ function(e) {
1469
1469
  return e.Attach = "attach", e.Browse = "browse", e.Full = "full", e;
1470
- }({}), Qt = (e) => {
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
- }, $t = (e, t) => {
1483
- if (Gt.test(e)) return !0;
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(/\/+$/, "") || "/", en = (e, t) => {
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
- }, tn = (e, t) => Z(e || `/${t}`).replace(/^\/+/, "") || t, nn = (e, t) => {
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 !== z.FOLDER) continue;
1494
+ if (r.nodeType !== B.FOLDER) continue;
1495
1495
  if (Z(r.path) === n) return r;
1496
- let e = nn(r.items ?? [], t);
1496
+ let e = rn(r.items ?? [], t);
1497
1497
  if (e) return e;
1498
1498
  }
1499
- }, rn = (e) => e?.permissions?.includes(ee.WRITE) ?? !1, an = (e, t) => {
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 = an(n.items ?? [], t);
1502
+ let e = on(n.items ?? [], t);
1503
1503
  if (e) return e;
1504
1504
  }
1505
- }, on = (e) => {
1505
+ }, sn = (e) => {
1506
1506
  switch (e) {
1507
- case Zt.Attach: return !1;
1508
- case Zt.Browse:
1509
- case Zt.Full: return !0;
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
- }, sn = (e) => e === Zt.Full, cn = (e, t) => {
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
- }, ln = (e, t) => {
1525
+ }, un = (e, t) => {
1526
1526
  let n = `files/${t}/`;
1527
1527
  return e.startsWith(n) ? e.slice(n.length) : e;
1528
- }, un = (e, t, n) => {
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
- }, dn = (e, t, n) => {
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 = ln(a.dialCorePath, a.bucket), s = r === -1 ? "" : e.slice(r + 1);
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
- }, fn = (e) => e.startsWith("files/"), pn = (e, t) => {
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 (fn(e)) {
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
- }, mn = (e) => {
1569
+ }, hn = (e) => {
1570
1570
  let t = e.replace(/\/$/, ""), n = t.lastIndexOf("/");
1571
1571
  return n > 0 ? t.slice(0, n + 1) : "";
1572
- }, hn = (e, t) => e.startsWith("/") || e === t || e.startsWith(`${t}/`), gn = (e, t, n) => {
1573
- let r = e.nodeType === z.FOLDER, i = e.id ? pn(e.id, t) : null, a = i != null && !hn(i, n) ? i : Q(e.path, n);
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
- }, _n = (e, t, n) => e.map((e) => {
1576
- let r = e.nodeType === z.FOLDER, i = Q(e.sourceUrl, n), a = Q(e.destinationUrl, n), o = en(e.sourceUrl, i);
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: en(e.destinationUrl, a),
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 ? A.Folder : A.Item,
1584
+ nodeType: r ? j.Folder : j.Item,
1585
1585
  name: o
1586
1586
  }
1587
1587
  };
1588
- }), vn = (e, t, n) => {
1588
+ }), yn = (e, t, n) => {
1589
1589
  let r = e.map((e) => {
1590
- let t = e.nodeType === z.FOLDER, r = Q(e.sourceUrl, n), i = Q(e.destinationUrl, n), a = en(e.sourceUrl, r), o = en(e.destinationUrl, i), s = t ? r.endsWith("/") ? r : `${r}/` : r.replace(/\/$/, ""), c = t ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, "");
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: mn(s),
1599
- destinationParent: mn(c)
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 ? P.Folder : P.Item,
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 ? N.Folder : N.Item,
1617
+ nodeType: e.isFolder ? P.Folder : P.Item,
1618
1618
  name: e.name
1619
1619
  }
1620
1620
  }))
1621
1621
  };
1622
- }, yn = (e) => {
1622
+ }, bn = (e) => {
1623
1623
  if (!e?.length) return;
1624
- let t = e.map((e) => Yt[e.toUpperCase()]).filter((e) => e != null);
1624
+ let t = e.map((e) => Xt[e.toUpperCase()]).filter((e) => e != null);
1625
1625
  return t.length > 0 ? t : void 0;
1626
- }, bn = (e, t) => {
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
- }, xn = (e, t, n, r, i) => {
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 === M.Folder, c = X(a.name), l = s ? `${o}/${c}/` : `${o}/${c}`, u = {
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 ? z.FOLDER : z.ITEM,
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 = yn(a.permissions) ?? yn(t.get(r)), u.items = xn(e, t, r, l, a.path);
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
- }, Sn = (e, t, n, r) => {
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: M.Folder,
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
- }, Cn = (e, t, n) => {
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
- }, wn = (e, t, n, r, i) => {
1678
- if (t === R.Shared) {
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 = ln(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1));
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 === R.Organization ? e.listPublicFiles({ path: r || void 0 }).then((e) => ({ items: e.items })) : e.listFiles({
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
- }, Tn = async (e, t, n, r, i) => {
1703
- if (t === R.Shared) {
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 = ln(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1)), { items: s } = await e.listFiles({
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 === R.Organization) {
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
- }, En = (e, t, n) => {
1729
- let r = e.nodeType === M.Folder, i = X(e.name), a = e.bucket ?? t, o = ln(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}`;
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 ? z.FOLDER : z.ITEM,
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
- }, Dn = (e, t) => ({
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: yn(e.permissions) ?? t.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
- }), On = /* @__PURE__ */ function(e) {
1754
+ }), kn = /* @__PURE__ */ function(e) {
1755
1755
  return e.Blob = "blob", e.Stream = "stream", e.Cancelled = "cancelled", e;
1756
- }({}), kn = (e) => {
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
- }, An = (e, t = 255) => {
1763
- if (c(e) <= t) return e;
1764
- let { base: n, extension: r } = kn(e), i = t - c(r);
1765
- return i <= 0 ? f(e, t) : `${f(n, i)}${r}`;
1766
- }, jn = (e) => {
1767
- let { base: t, extension: n } = kn(e), r = t.replace(new RegExp(ne.source, "g"), "_").replace(/[.\s]+$/, "");
1768
- return r === "" ? e : An(`${r}${n}`);
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
- }({}), Mn = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, onNotification: i }) => {
1772
- let [a, o] = S(""), [s, c] = S(() => /* @__PURE__ */ new Map()), l = x(s);
1773
- v(() => {
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] = S(() => /* @__PURE__ */ new Map()), [f, p] = S(!0), [m, h] = S(null), [g, y] = S(0), [C, w] = S(void 0), [T, E] = S(() => /* @__PURE__ */ new Set()), D = x(/* @__PURE__ */ new Map()), [O, k] = S(!1), [A, j] = S(null), N = x(null), P = x(null), F = x(/* @__PURE__ */ new Set()), I = x(/* @__PURE__ */ new Set()), [L, ee] = S(() => /* @__PURE__ */ new Set()), [B, te] = S(() => /* @__PURE__ */ new Set()), ne = x(r);
1777
- v(() => {
1778
- ne.current !== r && (ne.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(), te(/* @__PURE__ */ new Set()), N.current != null && (clearTimeout(N.current), N.current = null), P.current?.(), P.current = null, j(null), k(!1), ee(/* @__PURE__ */ new Set()));
1779
- }, [r]), v(() => () => {
1780
- N.current != null && clearTimeout(N.current), P.current?.();
1781
- }, []), v(() => {
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), wn(e, r, t, a, D.current).then(({ items: e, permissions: t }) => {
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 === R.Shared && a === "" && (w(e.map((e) => un(ln(e.path, e.bucket ?? ""), n, e.nodeType === M.Folder))), D.current = new Map(e.map((e) => [X(e.name), {
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
- ]), v(() => {
1806
- if (r !== R.MyFiles) {
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(ln(e.path, t), n, e.nodeType === M.Folder))));
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 re = b(() => [{
1825
+ let ne = x(() => [{
1826
1826
  id: t,
1827
1827
  name: n,
1828
1828
  path: `/${n}`,
1829
1829
  parentPath: "",
1830
- nodeType: z.FOLDER,
1830
+ nodeType: B.FOLDER,
1831
1831
  folderId: t,
1832
- permissions: yn(u.get("")),
1833
- items: xn(s, u, "", `/${n}`, t)
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
- ]), H = _((e) => {
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
- y((e) => e + 1);
1859
- }, []), ae = ie, oe = _((o) => {
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 wn(e, r, t, n, D.current);
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: V.Error,
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 = _((e, t, n) => {
1890
- c((r) => Sn(r, e, t, n));
1891
- }, []), ce = _((a) => {
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
- te((e) => {
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), te((e) => {
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 wn(e, r, t, o, D.current);
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: V.Error,
1910
+ variant: H.Error,
1911
1911
  reason: q.FolderLoadFailed
1912
1912
  });
1913
1913
  } finally {
1914
- F.current.delete(o), te((e) => {
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 = b(() => {
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 = _((a) => {
1938
+ ]), ue = v((a) => {
1939
1939
  L.forEach((e) => {
1940
1940
  a.has(e) || I.current.delete(Q(e, n));
1941
- }), ee(a), [...a].filter((e) => {
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 wn(e, r, t, o, D.current);
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: V.Error,
1952
+ variant: H.Error,
1953
1953
  reason: q.FolderLoadFailed
1954
1954
  });
1955
1955
  } finally {
1956
- F.current.delete(o), te((e) => {
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
- N.current != null && (clearTimeout(N.current), N.current = null), P.current?.(), P.current = null, j(null), k(!1);
1972
- }, []), fe = _((i, o) => {
1973
- if (N.current != null && (clearTimeout(N.current), N.current = null), P.current?.(), P.current = null, !o.trim()) {
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
- N.current = setTimeout(() => {
1978
- N.current = null;
1977
+ M.current = setTimeout(() => {
1978
+ M.current = null;
1979
1979
  let i = o.toLowerCase();
1980
- if (r === R.Shared && a === "") {
1981
- P.current?.(), P.current = null, k(!0), j((s.get("") ?? []).filter((e) => X(e.name).toLowerCase().includes(i)).map((e) => En(e, e.bucket ?? t, n))), k(!1);
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 Tn(e, r, t, a, D.current);
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) => En(e, e.bucket ?? t, n)));
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 = b(() => {
2007
- let e = re[0];
2008
- if (e) return Z(pe) === Z(`/${n}`) ? e : nn(e.items ?? [], pe);
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
- re,
2010
+ ne,
2011
2011
  pe,
2012
2012
  n
2013
2013
  ]);
2014
2014
  return {
2015
- items: re,
2015
+ items: ne,
2016
2016
  isLoading: f,
2017
2017
  error: m,
2018
2018
  path: pe,
2019
2019
  folderPath: a,
2020
- onPathChange: H,
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: B,
2031
- sharedWithMeIds: b(() => r === R.Shared ? C : void 0, [r, C]),
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
- }, Nn = ({ filesApi: e, bucket: t, rootLabel: n, onNotification: r }) => {
2043
- let [i, a] = S(void 0), [o, s] = S(!1);
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: _((i) => {
2047
+ onGetInfo: v((i) => {
2048
2048
  (async () => {
2049
2049
  s(!0);
2050
2050
  try {
2051
- let r = i.bucket ?? t, o = gn(i, r, n);
2052
- a(Dn(await e.getFileMetadata({
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: V.Error,
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
- }, Pn = ({ 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, v] = S(!1), [y, b] = S(!1), [C, w] = S(!1), [T, E] = S(!1), [D, O] = S(!1), [A, M] = S(!1), N = x(null), F = x(null), I = _((e, t) => {
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 ($t(e, h)) n = {
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 === Wt) n = { reason: J.ReservedName };
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 F.current = n, n;
2097
- }, [h]), L = _(async (c, d, m) => {
2098
- let { parentVirtualPath: h, name: g } = cn(d, n), _ = Q(h, n), y = a && i === _ ? a : {
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: z.FOLDER,
2102
+ folderId: v,
2103
+ nodeType: B.FOLDER,
2104
2104
  items: []
2105
- }, b = F.current;
2106
- if (F.current = null, I(g, y) || b) return;
2107
- v(!0);
2108
- let { bucket: x, path: S } = r === R.Shared ? dn(_, o.current, t) : {
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(_, await e.createFolder({
2113
+ u(v, await e.createFolder({
2114
2114
  bucket: x,
2115
2115
  parentPath: S || void 0,
2116
2116
  name: g
2117
- }), s.get(_)), l(), p?.({
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: V.Error,
2123
+ variant: H.Error,
2124
2124
  reason: q.FolderCreateFailed
2125
2125
  });
2126
2126
  } finally {
2127
- v(!1);
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
- ]), ee = _((r) => {
2143
+ ]), R = v((r) => {
2144
2144
  (async () => {
2145
2145
  b(!0);
2146
2146
  try {
2147
- let i = r.length === 1 ? r[0].nodeType === z.ITEM ? r[0].name : `${r[0].name}.zip` : "files.zip", a = await m.resolveDestination(i, r.length === 1 && r[0].nodeType === z.ITEM ? r[0].contentType ?? "application/octet-stream" : "application/zip");
2148
- if (a.type === On.Cancelled) return;
2149
- if (r.length === 1 && r[0].nodeType === z.ITEM) {
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 = gn(t, t.bucket, n), o = await e.downloadFile(t.bucket, 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: gn(e, e.bucket ?? t, n),
2163
+ path: _n(e, e.bucket ?? t, n),
2164
2164
  name: e.name,
2165
- nodeType: e.nodeType === z.FOLDER ? k.Folder : k.Item
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: V.Error,
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
- ]), B = _((a, s) => {
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 === z.FOLDER, a = Q(e.sourceUrl, n), s = i ? a : a.replace(/\/$/, ""), c = en(e.sourceUrl, s), { bucket: l, path: u } = r === R.Shared ? dn(s, o.current, t) : {
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 ? j.Folder : j.Item
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: V.Success,
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: V.Error,
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: V.Error,
2227
+ variant: H.Error,
2228
2228
  reason: q.DeleteFailed
2229
2229
  });
2230
2230
  }
2231
- let p = u.filter((e) => e.nodeType === j.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
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 === j.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
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
- ]), ne = _((e, t) => {
2249
+ ]), V = v((e, t) => {
2250
2250
  if (!e || e.trim() === "") return { reason: J.Empty };
2251
- if (e === Wt) return { reason: J.ReservedName };
2252
- if ($t(e, h)) return {
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]), re = _((r, i) => {
2266
- if (r.length === 0 || D || A) return;
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 = _n(r, t, n), s = o.map(({ dto: e }) => e);
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 = bn(o, t);
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: tn(i, n)
2279
+ destinationFolderName: nn(i, n)
2280
2280
  });
2281
2281
  }
2282
2282
  r > 0 && r < t.length ? f?.({
2283
- variant: V.Error,
2283
+ variant: H.Error,
2284
2284
  reason: q.CopyPartiallyFailed,
2285
2285
  count: r
2286
2286
  }) : r === t.length && f?.({
2287
- variant: V.Error,
2287
+ variant: H.Error,
2288
2288
  reason: q.CopyFailed
2289
2289
  });
2290
2290
  } catch {
2291
2291
  a.signal.aborted || f?.({
2292
- variant: V.Error,
2292
+ variant: H.Error,
2293
2293
  reason: q.CopyFailed
2294
2294
  });
2295
2295
  } finally {
2296
- c([...new Set(s.flatMap((e) => [mn(e.sourcePath), mn(e.destinationPath)]))]), l(), O(!1), N.current = null;
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
- A,
2306
+ k,
2307
2307
  c,
2308
2308
  l
2309
- ]), H = _(() => {
2309
+ ]), re = v(() => {
2310
2310
  N.current?.abort();
2311
2311
  }, []);
2312
2312
  return {
2313
2313
  isCreatingFolder: g,
2314
2314
  isDownloading: y,
2315
- isDeleting: C,
2315
+ isDeleting: x,
2316
2316
  isRenaming: T,
2317
2317
  isCopying: D,
2318
- isMoving: A,
2318
+ isMoving: k,
2319
2319
  onCreateFolder: L,
2320
2320
  onCreateFolderValidate: I,
2321
- onDownloadFiles: ee,
2322
- onDeleteFiles: B,
2323
- onRenameValidate: ne,
2324
- onMoveToFiles: _((r, a, o) => {
2325
- if (r.length === 0 || D || A || T) return;
2326
- let { renameDtos: s, preparedMoveItems: u } = vn(r, t, n), m = u.map(({ dto: e }) => e), h = new AbortController();
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 && M(!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 = bn(u, r.results);
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: tn(o, n)
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: en(e.destinationPath, e.destinationPath),
2381
- isFolder: e.nodeType === P.Folder
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: V.Error,
2385
+ variant: H.Error,
2386
2386
  reason: S ? q.MoveFailed : q.RenameFailed
2387
2387
  }) : f?.({
2388
- variant: V.Error,
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 === P.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
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) => [mn(e.sourcePath), mn(e.destinationPath)]))]), l(), E(!1), M(!1), m.length > 0 && (N.current = null);
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
- A,
2410
+ k,
2411
2411
  T,
2412
2412
  c,
2413
2413
  l,
2414
2414
  d
2415
2415
  ]),
2416
- onCopyFiles: re,
2417
- cancelCopyMove: H
2416
+ onCopyFiles: ne,
2417
+ cancelCopyMove: re
2418
2418
  };
2419
- }, Fn = ({ filesApi: e, bucket: t, rootLabel: n, bumpRetry: r, onNotification: i }) => {
2420
- let [a, o] = S(!1), [s, c] = S(!1);
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: _((a) => {
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: gn(e, r, n)
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: V.Error,
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: _((a) => {
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: gn(e, r, n)
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: V.Error,
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
- }, In = 5, Ln = (e) => e.error ? `${e.path} (${e.error})` : e.path, Rn = (e) => {
2482
- let t = e.slice(0, In);
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(Ln),
2484
+ names: t.map(Rn),
2485
2485
  restCount: e.length - t.length
2486
2486
  };
2487
- }, zn = (e, t) => `${e}${t}/`, Bn = (e) => /\.zip$/i.test(e), Vn = (e) => {
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 Bn(t.fileContent.name) && !Bn(t.name) ? t : void 0;
2490
- }, Hn = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, cache: i, sharedRootMetaRef: a, invalidateFolders: o, bumpRetry: s, onNotification: c }) => {
2491
- let [l, u] = S(null), d = x(null), f = _((r, i, a) => {
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, zn(l, i)), a = n.filter((e) => e.success).length, o = n.filter((e) => !e.success), s = o.length, { names: u, restCount: d } = Rn(o);
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: V.Error,
2504
+ variant: H.Error,
2505
2505
  reason: q.UploadArchiveFailed,
2506
2506
  names: u,
2507
2507
  restCount: d
2508
2508
  }) : s > 0 && c?.({
2509
- variant: V.Error,
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: V.Error,
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: _((l, p) => {
2533
+ onUploadFiles: v((l, p) => {
2534
2534
  if (l.length === 0) return;
2535
- let m = Vn(l);
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 === R.Shared ? dn(g, a.current, t) : {
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) => Cn(e, n, $.Cancelled));
2558
+ u((e) => wn(e, n, $.Cancelled));
2559
2559
  continue;
2560
2560
  }
2561
- u((e) => Cn(e, n, {
2561
+ u((e) => wn(e, n, {
2562
2562
  status: $.Uploading,
2563
2563
  percent: 0
2564
2564
  }));
2565
- let o = y.has(a.name.toLowerCase()) ? Ht.Overwrite : Ht.CreateOnly;
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) => Cn(t, n, {
2571
+ u((t) => wn(t, n, {
2572
2572
  status: $.Uploading,
2573
2573
  percent: e
2574
2574
  }));
2575
2575
  }
2576
- }), u((e) => Cn(e, n, {
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) => Cn(t, n, e));
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: V.Error,
2587
+ variant: H.Error,
2588
2588
  reason: q.UploadFailed
2589
2589
  }) : c?.({
2590
- variant: V.Success,
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: _((e, t, n) => {
2607
+ onUploadArchive: v((e, t, n) => {
2608
2608
  f(e, t, n);
2609
2609
  }, [f]),
2610
- onValidateUpload: _(async (e, t, n) => {
2611
- for (let t of e) t.name = jn(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
- }, Un = ({ filesApi: e, bucket: t, rootLabel: n = "My files", activeTab: r = R.MyFiles, onNotification: i, onOperationSuccess: a, forbiddenSymbolsRegExp: o, variant: s = Xt.Attach, actionProfile: c, labels: l, locale: u, disabledNewButtonTooltip: d, downloadDestination: f, buildValidationErrorMessage: p }) => {
2623
- let m = c ?? Qt(s), h = Mn({
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 = Hn({
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
- }), v = Pn({
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 = Fn({
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
- }), x = Nn({
2662
+ }), b = Pn({
2663
2663
  filesApi: e,
2664
2664
  bucket: t,
2665
2665
  rootLabel: n,
2666
2666
  onNotification: i
2667
- }), S = rn(h.currentFolder), C = b(() => r === R.Organization || r === R.Shared && h.folderPath === "" ? !1 : 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 = b(() => r === R.Shared ? Jt : qt, [r]), T = b(() => {
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(L.Download), r === R.MyFiles ? (t(L.Delete), C && (t(L.Rename), on(m) && (t(L.Copy), t(L.Move), t(L.Duplicate))), sn(m) && t(L.RemoveAccess)) : r === R.Shared && sn(m) && t(L.Unshare), m === Zt.Full && t(L.Info), e;
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 = b(() => v.isCreatingFolder || v.isDownloading || v.isDeleting || v.isRenaming || v.isCopying || v.isMoving || y.isUnsharing || y.isRemovingAccess || g.uploadBatchState != null, [
2683
- v.isCreatingFolder,
2684
- v.isDownloading,
2685
- v.isDeleting,
2686
- v.isRenaming,
2687
- v.isCopying,
2688
- v.isMoving,
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 = _((e, t) => {
2693
- let n = v.onCreateFolderValidate(e, t);
2692
+ ]), D = v((e, t) => {
2693
+ let n = _.onCreateFolderValidate(e, t);
2694
2694
  return n ? p(n) : null;
2695
- }, [v, p]), O = _((e, t) => {
2696
- let n = v.onRenameValidate(e, t);
2695
+ }, [_, p]), O = v((e, t) => {
2696
+ let n = _.onRenameValidate(e, t);
2697
2697
  return n ? p(n, t) : null;
2698
- }, [v, p]);
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: v.onCreateFolder,
2721
+ onCreateFolder: _.onCreateFolder,
2722
2722
  onCreateFolderValidate: D,
2723
- isCreatingFolder: v.isCreatingFolder,
2724
- onDownloadFiles: v.onDownloadFiles,
2725
- isDownloading: v.isDownloading,
2726
- onDeleteFiles: v.onDeleteFiles,
2727
- isDeleting: v.isDeleting,
2723
+ isCreatingFolder: _.isCreatingFolder,
2724
+ onDownloadFiles: _.onDownloadFiles,
2725
+ isDownloading: _.isDownloading,
2726
+ onDeleteFiles: _.onDeleteFiles,
2727
+ isDeleting: _.isDeleting,
2728
2728
  onRenameValidate: O,
2729
- onMoveToFiles: v.onMoveToFiles,
2730
- isRenaming: v.isRenaming,
2731
- onCopyFiles: v.onCopyFiles,
2732
- isCopying: v.isCopying,
2733
- isMoving: v.isMoving,
2734
- cancelCopyMove: v.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: Kt,
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: x.fileMetadata,
2749
- isFileMetadataLoading: x.isFileMetadataLoading,
2750
- onGetInfo: x.onGetInfo,
2751
- clearMetadata: x.clearMetadata,
2748
+ fileMetadata: b.fileMetadata,
2749
+ isFileMetadataLoading: b.isFileMetadataLoading,
2750
+ onGetInfo: b.onGetInfo,
2751
+ clearMetadata: b.clearMetadata,
2752
2752
  isAnyOperationInProgress: E
2753
2753
  };
2754
- }, Wn = [
2755
- R.MyFiles,
2756
- R.Shared,
2757
- R.Organization
2758
- ], Gn = (e, t, n, r) => {
2759
- let i = _((e) => r == null || r.includes(e), [r]), a = b(() => n?.filter((e) => i(e.id)).flatMap(({ id: e, label: t, disabled: n }) => typeof t == "string" ? [{
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 v(() => {
2765
- i(e) || t(Wn.find((e) => i(e)) ?? R.MyFiles);
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
- }, Kn = (e) => {
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
- }, qn = (e, t) => {
2777
+ }, Jn = (e, t) => {
2778
2778
  requestAnimationFrame(() => {
2779
2779
  requestAnimationFrame(() => {
2780
- !e.isDestroyed() && t.rowIndex != null && e.ensureNodeVisible(t, "middle"), Kn(t)?.scrollIntoView({
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
- }, Jn = (e) => e.find((e) => e.data?.isTemporary) ?? e[0] ?? null, Yn = ({ resolveTargetNode: e = Jn } = {}) => {
2787
- let t = x(/* @__PURE__ */ new Set()), n = x(!1), r = x(null), i = _(() => {
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 = _((e) => {
2789
+ }, []), a = v((e) => {
2790
2790
  let { api: t } = e;
2791
2791
  !t.isDestroyed() && e.rowIndex != null && t.ensureIndexVisible(e.rowIndex);
2792
- }, []), o = _((r) => {
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 && qn(i, s);
2800
- }, [e]), s = _((e) => {
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 v(() => () => {
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
- }, Xn = {
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
- }, Zn = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? o.PlainText : o.Markdown, Qn = (e) => {
2828
- let t = b(() => ({
2829
- ...Xn,
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 : Zn(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 = _((t) => {
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 b(() => ({
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
- }, $n = (e = !0, t = !0) => {
2880
- let [n, r] = S(!1), [i, a] = S([]), o = x(0), s = x(e), c = x(t);
2881
- y(() => {
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 v(() => {
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
- }, er = () => typeof window < "u" ? window.innerWidth : 1024, tr = () => {
2909
- let [e, t] = S(er);
2910
- return v(() => {
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
- }, nr = (e) => {
2916
- let t = tr();
2915
+ }, rr = (e) => {
2916
+ let t = nr();
2917
2917
  return Math.max(0, t - e);
2918
- }, rr = (e) => e.map((e) => e === I.Edit ? re.Edit : re.View), ir = (e, t) => {
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
- }, ar = (e, t, n, r = window.location.origin) => {
2922
- let [i, a] = S(), [o, s] = S(!0), [c, l] = S(null), u = x(0), d = _(async (i = [re.View]) => {
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: ir(s.url, r),
2932
+ url: ar(s.url, r),
2933
2933
  expiresInDays: s.expiresInDays,
2934
- access: rr(s.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 v(() => {
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: _((e) => {
2953
+ setAccess: v((e) => {
2954
2954
  d(e);
2955
2955
  }, [d])
2956
2956
  };
2957
- }, or = /* @__PURE__ */ function(e) {
2957
+ }, sr = /* @__PURE__ */ function(e) {
2958
2958
  return e.Idle = "idle", e.Loading = "loading", e.Resolved = "resolved", e.Unknown = "unknown", e;
2959
- }({}), sr = { status: "idle" }, cr = (e) => {
2960
- let [t, n] = S({}), r = x(/* @__PURE__ */ new Set());
2959
+ }({}), cr = { status: "idle" }, lr = (e) => {
2960
+ let [t, n] = C({}), r = S(/* @__PURE__ */ new Set());
2961
2961
  return {
2962
- requestRecipientsCount: _((t) => {
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: _((e) => t[e] ?? sr, [t]),
2985
- invalidateRecipientsCount: _((e) => {
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
- }, lr = { deepResearchFallback: "Deep research" }, ur = (e) => {
2990
- let { deepResearchToolId: t, selectedItemId: n, selectedDeploymentConfiguration: r } = e, i = b(() => ({
2991
- ...lr,
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 = b(() => {
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 = b(() => typeof o?.default == "boolean" ? o.default : !1, [o]), [c, l] = S(s);
2998
- v(() => {
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 = _((e) => {
3001
+ let u = v((e) => {
3002
3002
  e === t && l((e) => !e);
3003
- }, [t]), d = _((e) => {
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: b(() => o == null || t == null ? [] : [{
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: b(() => t == null || o == null ? {} : { [t]: c }, [
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 { me as AttachmentValidationErrorReason, qt as COLUMNS_WITHOUT_AUTHOR, Jt as COLUMNS_WITH_AUTHOR, Yt as CORE_PERMISSION_MAP, ve as ConversationExportMode, G as ConversationTransferErrorCode, W as ConversationTransferJobStatus, ye as ConversationTransferSubjectKind, be as ConversationTransferWarningCode, Kt as DATE_OPTIONS, Zt as DialFileManagerActionProfile, Xt as DialFileManagerVariant, Ht as DialFilesApiUploadMode, On as DownloadDestinationType, xe as EXPORT_APP_NAME, U as ExportFileNameKind, q as FileManagerNotificationReason, J as FileNameValidationErrorReason, Y as FileOperationKind, $ as FileUploadStatus, Gt as PATH_SEPARATOR_REGEXP, Wt as RESERVED_MARKER_NAME, or as RecipientsCountStatus, Ut as UPLOAD_CONCURRENCY, rt as attachmentToDto, it as attachmentsToDtos, xn as buildFromCache, un as buildSharedItemVirtualPath, at as createMessagePair, Qt as deriveActionProfile, ln as dialCorePathToRelative, ae as downloadAttachment, wn as fetchByTab, Tn as fetchForSearch, an as findDialFileByPath, bn as findFirstSuccessfulCopyMoveItem, nn as findFolderByVirtualPath, _e as formatDateYM, ge as formatDateYMD, tn as formatOperationFolderName, Be as formatQuotedNameList, K as getConversationPath, lt as getStarterConversationText, ut as getStarterSubmitText, en as getVirtualPathName, ot as hasActiveToolConfig, rn as hasDialFileWritePermission, $t as hasForbiddenNameSymbols, Nt as isAwaitingGenerationResume, on as isCopyMoveDuplicateAllowed, H as isDialFileId, ie as isDownloadableAttachment, st as isMessageChanged, sn as isShareActionsAllowed, yn as mapCorePermissions, Dn as mapFileMetadataToDialFile, En as mapSearchItem, Sn as mergeCreatedFolderIntoCache, Z as normalizeVirtualPath, cn as parseNewFolderVirtualPath, _n as prepareCopyItems, vn as prepareMoveRenameItems, dn as resolveOwnerCoords, jn as sanitizeFileName, Cn as updateEntry, ce as useAttachmentAction, qe as useAttachmentUpload, he as useAttachmentValidation, Qn as useChatSettingsFormConfig, nt as useConversationExport, ft as useConversationHandlers, kt as useConversationImport, Mt as useConversationScroll, Vt as useConversationSources, zt as useConversationStream, Mn as useDialFileListing, Un as useDialFileManager, Gn as useDialFileManagerTabConfig, Nn as useDialFileMetadata, Pn as useDialFileMutations, Fn as useDialFileSharing, Hn as useDialFileUploadBatch, Yn as useGridEditingScroll, $n as usePageFileDrag, nr as usePanelMaxWidth, ar as useShareLink, cr as useShareRecipientsCount, ur as useToolsMenu, tr as useViewportWidth };
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 };