@epam/ai-dial-chat-hooks 1.2.0-dev.285 → 1.2.0-dev.288

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.
@@ -1,159 +1,167 @@
1
1
  import { safeDecodeURI as e } from "../../shared/string-utils.js";
2
- import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as a, StreamUpstreamError as o } from "../create-chat-stream-api.js";
3
- import { getConversationPath as s } from "./conversation-path.js";
4
- import { applyChunkToMessages as c } from "./apply-chunk.js";
5
- import { restoreBufferedMessage as l } from "./buffered-generation.js";
6
- import { createResumeIfAwaitingGeneration as ee, fetchConversationForRecovery as te, findPendingBackgroundMessageIndex as u, hasGeneratedPayload as ne, isAwaitingGenerationResume as d } from "./generation-resume.js";
7
- import { createFrameScheduler as re } from "./frame-scheduler.js";
8
- import { MessageRole as f, generateUUID as ie } from "@epam/ai-dial-chat-shared";
9
- import { useCallback as p, useEffect as m, useMemo as ae, useRef as h, useState as g } from "react";
10
- import { SendCompletionDtoModeEnum as oe } from "@epam/ai-dial-chat-api-client";
2
+ import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as ee, StreamUpstreamError as a } from "../create-chat-stream-api.js";
3
+ import { getConversationPath as o } from "./conversation-path.js";
4
+ import { applyChunkToMessages as s } from "./apply-chunk.js";
5
+ import { restoreBufferedMessage as c } from "./buffered-generation.js";
6
+ import { createResumeIfAwaitingGeneration as te, fetchConversationForRecovery as ne, findPendingBackgroundMessageIndex as l, hasGeneratedPayload as re, isAwaitingGenerationResume as u } from "./generation-resume.js";
7
+ import { createFrameScheduler as ie } from "./frame-scheduler.js";
8
+ import { MessageRole as d, generateUUID as ae } from "@epam/ai-dial-chat-shared";
9
+ import { useCallback as f, useEffect as p, useMemo as oe, useRef as m, useState as h } from "react";
10
+ import { SendCompletionDtoModeEnum as g } from "@epam/ai-dial-chat-api-client";
11
11
  //#region src/conversation/useConversationStream/useConversationStream.ts
12
- var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof o ? e.message : "", _ = (e) => {
12
+ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof a ? e.message : "", _ = (e) => {
13
13
  if (!e) return;
14
- let t = u(e);
14
+ let t = l(e);
15
15
  return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
16
- }, v = ({ conversationId: o, state: { setConversation: v, conversationRef: y }, transport: b, generation: { startGeneration: le, completeGeneration: x }, channel: S, overlay: C, onStopError: w, generationConflictMessage: ue = t, generationPersistenceErrorMessage: T = n, onStreamError: E, batchChunksPerFrame: D = !1 }) => {
17
- let O = h(E);
18
- m(() => {
16
+ }, v = ({ conversationId: a, state: { setConversation: v, conversationRef: y }, transport: b, generation: { startGeneration: le, completeGeneration: x }, channel: S, overlay: C, onStopError: w, generationConflictMessage: ue = t, generationPersistenceErrorMessage: T = n, onStreamError: E, batchChunksPerFrame: D = !1 }) => {
17
+ let O = m(E);
18
+ p(() => {
19
19
  O.current = E;
20
20
  }, [E]);
21
- let de = h(D);
22
- m(() => {
21
+ let de = m(D);
22
+ p(() => {
23
23
  de.current = D;
24
24
  }, [D]);
25
- let [k] = g(re), [A, j] = g(() => /* @__PURE__ */ new Set()), [M, N] = g(null), P = h(null), F = h(null), I = h(/* @__PURE__ */ new Set()), L = h(/* @__PURE__ */ new Map()), R = h(/* @__PURE__ */ new Set()), fe = h(/* @__PURE__ */ new Map()), z = h(!0), B = h(/* @__PURE__ */ new Map()), [V, H] = g(B.current), U = h(/* @__PURE__ */ new Set()), [W, G] = g(U.current);
26
- m(() => (z.current = !0, () => {
27
- z.current = !1;
25
+ let [k] = h(ie), [A, j] = h(() => /* @__PURE__ */ new Set()), [M, N] = h(() => /* @__PURE__ */ new Set()), P = m(/* @__PURE__ */ new Map()), F = m(/* @__PURE__ */ new Set()), I = m(/* @__PURE__ */ new Map()), L = m(/* @__PURE__ */ new Set()), fe = m(/* @__PURE__ */ new Map()), R = m(!0), z = m(/* @__PURE__ */ new Map()), [B, V] = h(z.current), H = m(/* @__PURE__ */ new Set()), [pe, U] = h(H.current);
26
+ p(() => (R.current = !0, () => {
27
+ R.current = !1;
28
28
  }), []);
29
- let K = p((e) => {
30
- if (!B.current.has(e)) return;
31
- let t = new Map(B.current);
32
- t.delete(e), B.current = t, z.current && H(t);
33
- }, []), q = p((e, t, n) => {
34
- if (!z.current || !n()) return;
35
- let r = new Map(B.current);
29
+ let W = f((e) => {
30
+ if (!z.current.has(e)) return;
31
+ let t = new Map(z.current);
32
+ t.delete(e), z.current = t, R.current && V(t);
33
+ }, []), G = f((e, t, n) => {
34
+ if (!R.current || !n()) return;
35
+ let r = new Map(z.current);
36
36
  r.set(e, {
37
37
  retry: t,
38
38
  isCurrent: n
39
- }), B.current = r, H(r);
40
- }, []), pe = p(async () => {
41
- if (!o) return;
42
- let e = B.current.get(s(o));
43
- if (!(!e || !e.isCurrent() || U.current.has(e))) {
44
- U.current.add(e), G(new Set(U.current));
39
+ }), z.current = r, V(r);
40
+ }, []), K = f(async () => {
41
+ if (!a) return;
42
+ let e = z.current.get(o(a));
43
+ if (!(!e || !e.isCurrent() || H.current.has(e))) {
44
+ H.current.add(e), U(new Set(H.current));
45
45
  try {
46
46
  await e.retry();
47
47
  } finally {
48
- U.current.delete(e), z.current && G(new Set(U.current));
48
+ H.current.delete(e), R.current && U(new Set(H.current));
49
49
  }
50
50
  }
51
- }, [o]), J = h(o);
52
- m(() => (J.current = o, () => k.cancelAll()), [o, k]);
53
- let Y = p((e) => z.current && s(J.current ?? "") === e, []), X = p((e) => {
54
- K(e), j((t) => {
51
+ }, [a]), me = m(a);
52
+ p(() => (me.current = a, () => k.cancelAll()), [a, k]);
53
+ let q = f((e) => R.current && o(me.current ?? "") === e, []), J = f((e) => {
54
+ W(e), j((t) => {
55
55
  if (t.has(e)) return t;
56
56
  let n = new Set(t);
57
57
  return n.add(e), n;
58
58
  });
59
- }, [K]), Z = p((e) => {
59
+ }, [W]), Y = f((e) => {
60
60
  j((t) => {
61
61
  if (!t.has(e)) return t;
62
62
  let n = new Set(t);
63
63
  return n.delete(e), n;
64
64
  });
65
- }, []), Q = ae(() => ee({
65
+ }, []), X = f((e, t) => {
66
+ N((n) => {
67
+ if (n.has(e) === t) return n;
68
+ let r = new Set(n);
69
+ return t ? r.add(e) : r.delete(e), r;
70
+ });
71
+ }, []), he = f((e, t) => {
72
+ P.current.get(e) === t && (P.current.delete(e), X(e, !1));
73
+ }, [X]), Z = oe(() => te({
66
74
  transport: b,
67
75
  setConversation: v,
68
76
  conversationRef: y,
69
- resumingPathsRef: I,
70
- bufferedGenerationsRef: L,
71
- addStreamingPath: X,
72
- removeStreamingPath: Z,
73
- isPathDisplayed: Y,
77
+ resumingPathsRef: F,
78
+ bufferedGenerationsRef: I,
79
+ addStreamingPath: J,
80
+ removeStreamingPath: Y,
81
+ isPathDisplayed: q,
74
82
  generationPersistenceErrorMessage: T,
75
83
  frameScheduler: D ? k : void 0,
76
- stoppedGenerationIdsRef: R,
77
- onReloadError: q,
78
- onReloadSuccess: K
84
+ stoppedGenerationIdsRef: L,
85
+ onReloadError: G,
86
+ onReloadSuccess: W
79
87
  }), [
80
- X,
81
- Z,
88
+ J,
82
89
  Y,
90
+ q,
83
91
  b,
84
92
  T,
85
93
  D,
86
94
  k,
87
- q,
88
- K
89
- ]), me = p((t, n, o, ee, re, p, m = oe.Append, ae = {}) => {
90
- let h = p ?? ie(), g = s(t);
91
- k.flush(g), I.current.delete(g), P.current = h, F.current = g, fe.current.set(g, h), N(g);
95
+ G,
96
+ W
97
+ ]), ge = f((t, n, a, te, ie, f, p = g.Append, oe = {}) => {
98
+ let m = f ?? ae(), h = o(t);
99
+ k.flush(h), F.current.delete(h), P.current.set(h, m), fe.current.set(h, m), X(h, !0);
92
100
  let _;
93
- m === oe.Regenerate ? _ = o : m === oe.Edit && (_ = o - 1);
94
- let w = () => fe.current.get(g) !== h, E = le(g, h), D = y.current?.messages[o];
95
- D ? L.current.set(g, {
96
- generationId: h,
97
- messageIndex: o,
101
+ p === g.Regenerate ? _ = a : p === g.Edit && (_ = a - 1);
102
+ let w = () => fe.current.get(h) !== m, E = le(h, m), D = y.current?.messages[a];
103
+ D ? I.current.set(h, {
104
+ generationId: m,
105
+ messageIndex: a,
98
106
  message: D
99
- }) : L.current.delete(g), X(g), C?.notifyGenerationStart?.(), S?.ensureConnected();
107
+ }) : I.current.delete(h), J(h), C?.notifyGenerationStart?.(), S?.ensureConnected();
100
108
  let A = () => {
101
- w() || Z(g), P.current === h && (P.current = null, F.current = null, N(null)), x(g, h), S?.notifyGenerationSettled?.();
109
+ w() || Y(h), he(h, m), x(h, m), S?.notifyGenerationSettled?.();
102
110
  }, j = () => {
103
111
  if (w()) return;
104
- let e = L.current.get(g);
105
- !e || e.generationId !== h || (e.message = {
112
+ let e = I.current.get(h);
113
+ !e || e.generationId !== m || (e.message = {
106
114
  ...e.message,
107
115
  streamErrorMessage: T
108
- }, O.current?.(new i()), Y(g) && v((t) => {
109
- if (!t || w() || !Y(g)) return t;
110
- let n = l(t, e);
116
+ }, O.current?.(new i()), q(h) && v((t) => {
117
+ if (!t || w() || !q(h)) return t;
118
+ let n = c(t, e);
111
119
  return y.current = n, n;
112
120
  }));
113
- }, M = L.current.get(g), B = () => z.current && !w() && L.current.get(g) === M, V = async () => {
114
- if (B()) {
115
- if (!Y(g)) {
116
- M && L.current.delete(g);
121
+ }, M = I.current.get(h), N = () => R.current && !w() && I.current.get(h) === M, z = async () => {
122
+ if (N()) {
123
+ if (!q(h)) {
124
+ M && I.current.delete(h);
117
125
  return;
118
126
  }
119
127
  try {
120
128
  let n = await b.getConversation(e(t));
121
- if (!B()) return;
122
- if (K(g), !Y(g)) {
123
- M && L.current.delete(g);
129
+ if (!N()) return;
130
+ if (W(h), !q(h)) {
131
+ M && I.current.delete(h);
124
132
  return;
125
133
  }
126
- if (u(n) !== -1) {
127
- Q(t, n, { seedMessage: M?.message });
134
+ if (l(n) !== -1) {
135
+ Z(t, n, { seedMessage: M?.message });
128
136
  return;
129
137
  }
130
- if (M && M.messageIndex === n.messages.length - 1 && d(n) && ne(M.message)) {
138
+ if (M && M.messageIndex === n.messages.length - 1 && u(n) && re(M.message)) {
131
139
  j();
132
140
  return;
133
141
  }
134
- M && L.current.delete(g), v(n), y.current = n;
142
+ M && I.current.delete(h), v(n), y.current = n;
135
143
  } catch {
136
- B() && q(g, V, B);
144
+ N() && G(h, z, N);
137
145
  }
138
146
  }
139
- }, H = {
147
+ }, B = {
140
148
  signal: E.signal,
141
149
  onChunk: (e) => {
142
- if (P.current !== h) return;
143
- let t = L.current.get(g);
144
- if (t?.generationId === h) {
145
- let n = c([t.message], 0, e);
150
+ if (w()) return;
151
+ let t = I.current.get(h);
152
+ if (t?.generationId === m) {
153
+ let n = s([t.message], 0, e);
146
154
  n && (t.message = n[0]);
147
155
  }
148
- if (Y(g)) {
149
- if (de.current && t?.generationId === h) {
150
- k.schedule(g, () => {
151
- let e = L.current.get(g);
152
- if (P.current !== h || !Y(g) || e?.generationId !== h) return;
156
+ if (q(h)) {
157
+ if (de.current && t?.generationId === m) {
158
+ k.schedule(h, () => {
159
+ let e = I.current.get(h);
160
+ if (w() || !q(h) || e?.generationId !== m) return;
153
161
  let t = { ...e };
154
162
  v((e) => {
155
163
  if (!e) return e;
156
- let n = l(e, t);
164
+ let n = c(e, t);
157
165
  return y.current = n, n;
158
166
  });
159
167
  });
@@ -161,10 +169,10 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
161
169
  }
162
170
  v((t) => {
163
171
  if (!t) return t;
164
- let n = L.current.get(g), r;
165
- if (n?.generationId === h) r = l(t, n);
172
+ let n = I.current.get(h), r;
173
+ if (n?.generationId === m) r = c(t, n);
166
174
  else {
167
- let n = c(t.messages, o, e);
175
+ let n = s(t.messages, a, e);
168
176
  if (!n) return t;
169
177
  r = {
170
178
  ...t,
@@ -176,103 +184,105 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
176
184
  }
177
185
  },
178
186
  onComplete: async () => {
179
- k.flush(g), A(), R.current.has(h) ? R.current.delete(h) : w() || C?.notifyGenerationEnd?.(), await V();
187
+ k.flush(h), A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.(), await z();
180
188
  },
181
189
  onError: (e) => {
182
- if (k.flush(g), O.current?.(e), e instanceof a && !w()) {
183
- G(e);
190
+ if (k.flush(h), O.current?.(e), e instanceof ee && !w()) {
191
+ pe(e);
184
192
  return;
185
193
  }
186
- if (e instanceof r && ae.resumeOnConflict && !w()) {
187
- pe(e);
194
+ if (e instanceof r && oe.resumeOnConflict && !w()) {
195
+ U(e);
188
196
  return;
189
197
  }
190
- U(e);
198
+ V(e);
191
199
  }
192
- }, U = (e) => {
193
- let t = L.current.get(g), n = t?.generationId === h ? t : void 0;
200
+ }, V = (e) => {
201
+ let t = I.current.get(h), n = t?.generationId === m ? t : void 0;
194
202
  if (n && (e instanceof i ? n.message = {
195
203
  ...n.message,
196
204
  streamErrorMessage: T
197
- } : L.current.delete(g)), A(), w() || !Y(g)) return;
205
+ } : I.current.delete(h)), A(), w() || !q(h)) return;
198
206
  let r = ce(e, ue, T);
199
207
  v((e) => {
200
- if (!e || w() || !Y(g)) return e;
201
- let t = n?.generationId === h ? l(e, n) : e, i = {
208
+ if (!e || w() || !q(h)) return e;
209
+ let t = n?.generationId === m ? c(e, n) : e, i = {
202
210
  ...t,
203
- messages: t.messages.map((e, t) => t === o ? {
211
+ messages: t.messages.map((e, t) => t === a ? {
204
212
  ...e,
205
213
  streamErrorMessage: r
206
214
  } : e)
207
215
  };
208
216
  return y.current = i, i;
209
217
  });
210
- }, W = () => {
211
- A(), R.current.has(h) ? R.current.delete(h) : w() || C?.notifyGenerationEnd?.();
212
- }, G = async (n) => {
213
- I.current.add(g), J(await te(() => b.getConversation(e(t)), w), n, !1);
218
+ }, H = () => {
219
+ A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
214
220
  }, pe = async (n) => {
215
- P.current === h && N(null), I.current.add(g), J(await te(() => b.getConversation(e(t)), w, (e) => e.messages.length === o && e.messages.at(-1)?.role === f.User), n, !0);
216
- }, J = (e, n, r) => {
221
+ F.current.add(h), K(await ne(() => b.getConversation(e(t)), w), n, !1);
222
+ }, U = async (n) => {
223
+ P.current.get(h) === m && X(h, !1), F.current.add(h), K(await ne(() => b.getConversation(e(t)), w, (e) => e.messages.length === a && e.messages.at(-1)?.role === d.User), n, !0);
224
+ }, K = (e, n, r) => {
217
225
  if (w()) {
218
226
  A();
219
227
  return;
220
228
  }
221
- let i = e?.messages[e.messages.length - 1], a = e != null && e.messages.length - 1 === o && i?.role === f.Assistant, s = r && e != null && u(e) !== -1;
222
- if (!e || !a && !s) {
223
- I.current.delete(g), U(n);
229
+ let i = e?.messages[e.messages.length - 1], ee = e != null && e.messages.length - 1 === a && i?.role === d.Assistant, o = r && e != null && l(e) !== -1;
230
+ if (!e || !ee && !o) {
231
+ F.current.delete(h), V(n);
224
232
  return;
225
233
  }
226
- let c = L.current.get(g), l = c?.generationId === h ? c : void 0;
227
- if (d(e)) {
228
- Q(t, e, {
229
- seedMessage: a ? l?.message : void 0,
234
+ let s = I.current.get(h), c = s?.generationId === m ? s : void 0;
235
+ if (u(e)) {
236
+ Z(t, e, {
237
+ seedMessage: ee ? c?.message : void 0,
230
238
  skipDedupe: !0,
231
- onSettled: W
239
+ onSettled: H
232
240
  });
233
241
  return;
234
242
  }
235
- I.current.delete(g), l && L.current.delete(g), Y(g) && (v(e), y.current = e), W();
243
+ F.current.delete(h), c && I.current.delete(h), q(h) && (v(e), y.current = e), H();
236
244
  };
237
245
  (async () => {
238
246
  try {
239
- let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t = R.current.has(h);
247
+ let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t = L.current.has(m);
240
248
  if (E.signal.aborted || w() || t) {
241
- L.current.get(g)?.generationId === h && L.current.delete(g), w() || Z(g), P.current === h && (P.current = null, F.current = null, N(null)), x(g, h), S?.notifyGenerationSettled?.(), t ? R.current.delete(h) : w() || C?.notifyGenerationEnd?.();
249
+ I.current.get(h)?.generationId === m && I.current.delete(h), w() || Y(h), he(h, m), x(h, m), S?.notifyGenerationSettled?.(), t ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
242
250
  return;
243
251
  }
244
- b.streamCompletion(g, n, ee, H, re, h, m, _, e);
252
+ b.streamCompletion(h, n, te, B, ie, m, p, _, e);
245
253
  } catch (e) {
246
- H.onError(e instanceof Error ? e : Error(String(e)));
254
+ B.onError(e instanceof Error ? e : Error(String(e)));
247
255
  }
248
256
  })();
249
257
  }, [
250
258
  le,
251
259
  x,
252
- X,
253
- Z,
260
+ J,
254
261
  Y,
262
+ X,
263
+ he,
264
+ q,
255
265
  S?.channelId,
256
266
  S?.ensureConnected,
257
267
  S?.waitForChannel,
258
268
  S?.notifyGenerationSettled,
259
269
  C,
260
270
  b,
261
- Q,
271
+ Z,
262
272
  ue,
263
273
  T,
264
274
  k,
265
- q,
266
- K
267
- ]), he = p((e, t) => {
268
- let n = s(e), r = L.current.get(n);
269
- return B.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === f.Assistant && !d(t) ? (K(n), L.current.delete(n), t) : r ? l(t, r) : t;
270
- }, [K]), ge = p(() => {
271
- if (!o) return;
272
- let e = s(o), t = (F.current === e ? P.current : null) ?? _(y.current);
275
+ G,
276
+ W
277
+ ]), _e = f((e, t) => {
278
+ let n = o(e), r = I.current.get(n);
279
+ return z.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === d.Assistant && !u(t) ? (W(n), I.current.delete(n), t) : r ? c(t, r) : t;
280
+ }, [W]), ve = f(() => {
281
+ if (!a) return;
282
+ let e = o(a), t = P.current.get(e) ?? _(y.current);
273
283
  if (!t) return;
274
- R.current.add(t), k.flush(e), C?.notifyStopGenerating?.();
275
- let n = L.current.get(e)?.message.content;
284
+ L.current.add(t), k.flush(e), C?.notifyStopGenerating?.();
285
+ let n = I.current.get(e)?.message.content;
276
286
  b.stopCompletion({
277
287
  generationId: t,
278
288
  path: e,
@@ -282,23 +292,23 @@ var se = 2e4, ce = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
282
292
  w?.(t);
283
293
  });
284
294
  }, [
285
- o,
295
+ a,
286
296
  y,
287
297
  k,
288
298
  w,
289
299
  C,
290
300
  b
291
- ]), _e = p((e, t) => Q(e, t), [Q]), ve = o != null && A.has(s(o)), $ = o == null ? null : s(o), ye = $ != null && (M === $ || ve && _(y.current) != null), be = $ ? V.get($) : void 0, xe = be?.isCurrent() ?? !1;
301
+ ]), ye = f((e, t) => Z(e, t), [Z]), be = a != null && A.has(o(a)), Q = a == null ? null : o(a), xe = Q != null && (M.has(Q) || be && _(y.current) != null), $ = Q ? B.get(Q) : void 0, Se = $?.isCurrent() ?? !1;
292
302
  return {
293
- hasConversationReloadError: xe,
294
- isReloadingConversation: !!be && xe && W.has(be),
295
- retryConversationReload: pe,
296
- startStream: me,
297
- handleStop: ge,
298
- resumeIfAwaitingGeneration: _e,
299
- restoreBufferedGeneration: he,
300
- isStreaming: ve,
301
- canStopStreaming: ye
303
+ hasConversationReloadError: Se,
304
+ isReloadingConversation: !!$ && Se && pe.has($),
305
+ retryConversationReload: K,
306
+ startStream: ge,
307
+ handleStop: ve,
308
+ resumeIfAwaitingGeneration: ye,
309
+ restoreBufferedGeneration: _e,
310
+ isStreaming: be,
311
+ canStopStreaming: xe
302
312
  };
303
313
  };
304
314
  //#endregion
@@ -200,7 +200,7 @@ declare interface OoxmlDocxHighlightLocation {
200
200
  path: number[];
201
201
  /** Inclusive start character offset within the story's matched text. */
202
202
  start: number;
203
- /** Exclusive end character offset, already converted from the wire's inclusive `end`. */
203
+ /** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
204
204
  endExclusive: number;
205
205
  /** The cited text, compared against the text resolved over `[start, endExclusive)`. */
206
206
  text: string;
@@ -264,7 +264,7 @@ declare interface OoxmlPptxHighlightLocation {
264
264
  shapeId: string;
265
265
  /** Inclusive start character offset within the shape's matched text. */
266
266
  start: number;
267
- /** Exclusive end character offset, already converted from the wire's inclusive `end`. */
267
+ /** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
268
268
  endExclusive: number;
269
269
  /** The cited text, compared against the text resolved over `[start, endExclusive)`. */
270
270
  text: string;
@@ -1,7 +1,7 @@
1
1
  import { isDialFileId as e } from "./dial-file.js";
2
2
  import { AttachmentContentType as t, AttachmentErrorType as n, OoxmlFileType as r, OoxmlHighlightKind as i, getOoxmlFileType as a } from "@epam/ai-dial-attachment-canvas";
3
3
  import { MIMEType as o, base64ToBlob as s, tryBase64ToBytes as c } from "@epam/ai-dial-chat-shared";
4
- import { annotationHighlightId as l, annotationToOfficeHighlightLocations as u, annotationsToPdfHighlights as d, gatherSameSourceAnnotations as f, getAnnotationPdfPage as p, parsePdfPageReference as m } from "@epam/ai-dial-quotations";
4
+ import { annotationHighlightIds as l, annotationToOfficeHighlightLocations as u, annotationsToPdfHighlights as d, gatherSameSourceAnnotations as f, getAnnotationPdfPage as p, parsePdfPageReference as m } from "@epam/ai-dial-quotations";
5
5
  import { LRUCache as h } from "lru-cache";
6
6
  //#region src/files/attachment-canvas.ts
7
7
  var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
@@ -166,7 +166,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
166
166
  if (a?.type !== o.PDF) return null;
167
167
  let s = e(a.url) ? i.resolveDialFileDownloadUrl(a.url) : a.url;
168
168
  if (s == null) return null;
169
- let c = (r.find((e) => e.annotations.includes(n))?.annotations ?? [n]).filter((e) => e.body?.source?.attachment?.url === a.url), u = c.indexOf(n), f = d(c), m = l(n, u), h = p(n), g = f.some((e) => e.id === m);
169
+ let c = (r.find((e) => e.annotations.includes(n))?.annotations ?? [n]).filter((e) => e.body?.source?.attachment?.url === a.url), u = c.indexOf(n), f = d(c), m = l(c)[u], h = p(n), g = f.some((e) => e.id === m);
170
170
  if (!g && h != null) {
171
171
  let e = `page-anchor-${m}`;
172
172
  return {
@@ -227,15 +227,15 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
227
227
  if (c !== r.Docx && c !== r.Xlsx && c !== r.Pptx) return null;
228
228
  let d = e(s.url) ? o.resolveDialFileDownloadUrl(s.url) : s.url;
229
229
  if (d == null) return null;
230
- let p = f(n, i), m = [], h;
230
+ let p = f(n, i), m = [], h, g = l(p);
231
231
  return p.forEach((e, t) => {
232
232
  let r = u(e);
233
233
  if (r.length === 0) return;
234
- let i = l(e, t);
234
+ let i = g[t];
235
235
  m.push({
236
236
  id: i,
237
237
  locations: r.map(B)
238
- }), e === n && (h = i);
238
+ }), e === n && h == null && (h = i);
239
239
  }), {
240
240
  type: t.Ooxml,
241
241
  url: d,
@@ -7,17 +7,17 @@ import { findFirstSuccessfulCopyMoveItem as p } from "../dial-file-manager-mappi
7
7
  import { DownloadDestinationType as m } from "../download-destination.js";
8
8
  import { getParentFolderPath as h } from "@epam/ai-dial-chat-shared";
9
9
  import { useCallback as g, useRef as _, useState as v } from "react";
10
- import { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as S } from "@epam/ai-dial-chat-api-client";
11
- import { NOT_ALLOWED_SYMBOLS as C, NotificationVariant as w } from "@epam/ai-dial-ui-kit";
12
- import { DialFileManagerTabs as T, DialFileNodeType as E } from "@epam/ai-dial-react-file-manager";
10
+ import { ArchiveItemDtoNodeTypeEnum as y, CopyItemDtoNodeTypeEnum as b, DeleteItemDtoNodeTypeEnum as x, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as te } from "@epam/ai-dial-chat-api-client";
11
+ import { NOT_ALLOWED_SYMBOLS as S, NotificationVariant as C } from "@epam/ai-dial-ui-kit";
12
+ import { DialFileManagerTabs as w, DialFileNodeType as T } from "@epam/ai-dial-react-file-manager";
13
13
  //#region src/files/useDialFileMutations/useDialFileMutations.ts
14
- var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, currentFolder: M, sharedRootMetaRef: N, listingPermissionsCache: P, invalidateFolders: F, bumpRetry: I, mergeCreatedFolder: L, setFolderPath: R, onNotification: z, onOperationSuccess: B, downloadDestination: V, forbiddenSymbolsRegExp: H }) => {
15
- let [te, U] = v(!1), [ne, W] = v(!1), [re, G] = v(!1), [K, q] = v(!1), [J, Y] = v(!1), [X, ie] = v(!1), Z = _(null), Q = _(null), $ = g((e, n) => {
14
+ var E = ({ filesApi: E, bucket: D, rootLabel: O, activeTab: k, folderPath: A, currentFolder: j, sharedRootMetaRef: M, listingPermissionsCache: N, invalidateFolders: P, bumpRetry: F, mergeCreatedFolder: I, setFolderPath: L, onNotification: R, onOperationSuccess: z, downloadDestination: B, forbiddenSymbolsRegExp: V }) => {
15
+ let [ne, H] = v(!1), [re, U] = v(!1), [ie, W] = v(!1), [G, K] = v(!1), [q, J] = v(!1), [Y, X] = v(!1), Z = _(null), Q = _(null), $ = g((e, n) => {
16
16
  let i = null;
17
17
  if (!e || e.trim() === "") i = { reason: t.Empty };
18
- else if (o(e, H)) i = {
18
+ else if (o(e, V)) i = {
19
19
  reason: t.ForbiddenSymbols,
20
- symbols: C
20
+ symbols: S
21
21
  };
22
22
  else if (e === r) i = { reason: t.ReservedName };
23
23
  else if (e.length > 255) i = {
@@ -32,246 +32,249 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
32
32
  });
33
33
  }
34
34
  return Q.current = i, i;
35
- }, [H]), ae = g(async (t, r, i) => {
36
- let { parentVirtualPath: a, name: o } = s(r, k), l = u(a, k), d = M && j === l ? M : {
35
+ }, [V]), ae = g(async (t, r, i) => {
36
+ let { parentVirtualPath: a, name: o } = s(r, O), l = u(a, O), d = j && A === l ? j : {
37
37
  id: l,
38
38
  path: l,
39
39
  name: a.split("/").filter(Boolean).pop() ?? "",
40
40
  folderId: l,
41
- nodeType: E.FOLDER,
41
+ nodeType: T.FOLDER,
42
42
  items: []
43
43
  }, f = Q.current;
44
44
  if (Q.current = null, $(o, d) || f) return;
45
- U(!0);
46
- let { bucket: p, path: m } = A === T.Shared ? c(l, N.current, O) : {
47
- bucket: O,
45
+ H(!0);
46
+ let { bucket: p, path: m } = k === w.Shared ? c(l, M.current, D) : {
47
+ bucket: D,
48
48
  path: l
49
49
  };
50
50
  try {
51
- L(l, await D.createFolder({
51
+ I(l, await E.createFolder({
52
52
  bucket: p,
53
53
  parentPath: m,
54
54
  name: o
55
- }), P.get(l)), I(), B?.({
55
+ }), N.get(l)), F(), z?.({
56
56
  kind: n.FolderCreated,
57
57
  name: o
58
58
  });
59
59
  } catch {
60
- z?.({
61
- variant: w.Error,
60
+ R?.({
61
+ variant: C.Error,
62
62
  reason: e.FolderCreateFailed
63
63
  });
64
64
  } finally {
65
- U(!1);
65
+ H(!1);
66
66
  }
67
67
  }, [
68
- A,
69
- O,
70
- M,
68
+ k,
71
69
  D,
72
70
  j,
71
+ E,
72
+ A,
73
73
  $,
74
- k,
75
- P,
76
- L,
77
- I,
78
- B,
74
+ O,
79
75
  N,
80
- z
76
+ I,
77
+ F,
78
+ z,
79
+ M,
80
+ R
81
81
  ]), oe = g((t) => {
82
82
  (async () => {
83
- W(!0);
83
+ U(!0);
84
84
  try {
85
- let e = t.length === 1 ? t[0].nodeType === E.ITEM ? t[0].name : `${t[0].name}.zip` : "files.zip", r = await V.resolveDestination(e, t.length === 1 && t[0].nodeType === E.ITEM ? t[0].contentType ?? "application/octet-stream" : "application/zip");
85
+ let e = t.length === 1 ? t[0].nodeType === T.ITEM ? t[0].name : `${t[0].name}.zip` : "files.zip", r = await B.resolveDestination(e, t.length === 1 && t[0].nodeType === T.ITEM ? t[0].contentType ?? "application/octet-stream" : "application/zip");
86
86
  if (r.type === m.Cancelled) return;
87
- if (t.length === 1 && t[0].nodeType === E.ITEM) {
87
+ if (t.length === 1 && t[0].nodeType === T.ITEM) {
88
88
  let e = t[0];
89
89
  if (!e.bucket) throw Error("File is missing bucket");
90
- let i = l(e, e.bucket, k), a = await D.downloadFile(e.bucket, i);
90
+ let i = l(e, e.bucket, O), a = await E.downloadFile(e.bucket, i);
91
91
  if (!a.ok) throw Error(`Download failed with status ${a.status}`);
92
- let o = await V.triggerDownload(a, e.name, r);
93
- B?.({
92
+ let o = await B.triggerDownload(a, e.name, r);
93
+ z?.({
94
94
  kind: n.FileDownloaded,
95
95
  name: o,
96
96
  count: 1
97
97
  });
98
98
  } else {
99
99
  let i = t.map((e) => ({
100
- bucket: e.bucket ?? O,
101
- path: l(e, e.bucket ?? O, k),
100
+ bucket: e.bucket ?? D,
101
+ path: l(e, e.bucket ?? D, O),
102
102
  name: e.name,
103
- nodeType: e.nodeType === E.FOLDER ? y.Folder : y.Item
104
- })), a = await D.downloadArchive(i);
103
+ nodeType: e.nodeType === T.FOLDER ? y.Folder : y.Item
104
+ })), a = await E.downloadArchive(i);
105
105
  if (!a.ok) throw Error(`Download failed with status ${a.status}`);
106
- let o = await V.triggerDownload(a, e, r);
107
- t.length === 1 ? B?.({
106
+ let o = await B.triggerDownload(a, e, r);
107
+ t.length === 1 ? z?.({
108
108
  kind: n.FileDownloaded,
109
109
  name: o
110
- }) : B?.({
110
+ }) : z?.({
111
111
  kind: n.FilesDownloaded,
112
112
  count: t.length
113
113
  });
114
114
  }
115
115
  } catch {
116
- z?.({
117
- variant: w.Error,
116
+ R?.({
117
+ variant: C.Error,
118
118
  reason: t.length === 1 ? e.DownloadFileFailed : e.DownloadFilesFailed
119
119
  });
120
120
  } finally {
121
- W(!1);
121
+ U(!1);
122
122
  }
123
123
  })();
124
124
  }, [
125
+ D,
125
126
  O,
126
- k,
127
- B,
128
127
  z,
129
- D,
130
- V
128
+ R,
129
+ E,
130
+ B
131
131
  ]), se = g((t, n) => {
132
132
  t.length !== 0 && (async () => {
133
- G(!0);
134
- let r = t.map((e) => {
135
- let t = e.nodeType === E.FOLDER, n = u(e.sourceUrl, k), r = t ? n : n.replace(/\/$/, ""), i = a(e.sourceUrl, r), { bucket: o, path: s } = A === T.Shared ? c(r, N.current, O) : {
136
- bucket: O,
137
- path: r
133
+ W(!0);
134
+ let r = [], i = t.map((e) => {
135
+ let t = e.nodeType === T.FOLDER, n = u(e.sourceUrl, O), i = t ? n : n.replace(/\/$/, "");
136
+ t && i !== "" && r.push(i.endsWith("/") ? i : `${i}/`);
137
+ let o = a(e.sourceUrl, i), { bucket: s, path: l } = k === w.Shared ? c(i, M.current, D) : {
138
+ bucket: D,
139
+ path: i
138
140
  };
139
141
  return {
140
- bucket: o,
141
- path: s,
142
- name: i,
142
+ bucket: s,
143
+ path: l,
144
+ name: o,
143
145
  nodeType: t ? x.Folder : x.Item
144
146
  };
145
147
  });
146
148
  try {
147
- let { results: t } = await D.deleteFiles(r), i = t.filter((e) => !e.success), a = i.length, o = t.length - a, s = t.find((e) => e.success), c = r.find((e) => e.path === s?.path) ?? r[0];
148
- if (o > 0 && z?.({
149
- variant: w.Success,
149
+ let { results: t } = await E.deleteFiles(i), r = t.filter((e) => !e.success), a = r.length, o = t.length - a, s = t.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
150
+ if (o > 0 && R?.({
151
+ variant: C.Success,
150
152
  reason: e.FilesDeleted,
151
153
  count: o,
152
154
  name: c?.name,
153
- folder: n || k
155
+ folder: n || O
154
156
  }), a > 0) {
155
- let t = i.slice(0, 3).map((e) => r.find((t) => t.path === e.path)?.name ?? e.path), n = a - t.length;
156
- z?.({
157
- variant: w.Error,
157
+ let t = r.slice(0, 3).map((e) => i.find((t) => t.path === e.path)?.name ?? e.path), n = a - t.length;
158
+ R?.({
159
+ variant: C.Error,
158
160
  reason: e.FilesDeletePartiallyFailed,
159
161
  names: t,
160
162
  restCount: n
161
163
  });
162
164
  }
163
165
  } catch {
164
- z?.({
165
- variant: w.Error,
166
+ R?.({
167
+ variant: C.Error,
166
168
  reason: e.DeleteFailed
167
169
  });
168
170
  }
169
- let i = r.filter((e) => e.nodeType === x.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
170
- F([...new Set(r.map((e) => {
171
+ P([...new Set(i.map((e) => {
171
172
  if (e.nodeType === x.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
172
173
  let t = e.path.lastIndexOf("/");
173
174
  return t > 0 ? e.path.slice(0, t + 1) : "";
174
- }))]), i.some((e) => j === e || j.startsWith(e)) && R((e) => e.replace(/[^/]+\/$/, "")), I(), G(!1);
175
+ }))]);
176
+ let o = r.filter((e) => A.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
177
+ o != null && L(h(o)), F(), W(!1);
175
178
  })();
176
179
  }, [
177
- A,
178
- O,
179
180
  k,
180
- j,
181
- z,
182
181
  D,
183
- N,
182
+ O,
183
+ A,
184
+ R,
185
+ E,
186
+ M,
187
+ P,
184
188
  F,
185
- I,
186
- R
189
+ L
187
190
  ]), ce = g((e, n) => {
188
191
  if (!e || e.trim() === "") return { reason: t.Empty };
189
192
  if (e === r) return { reason: t.ReservedName };
190
- if (o(e, H)) return {
193
+ if (o(e, V)) return {
191
194
  reason: t.ForbiddenSymbols,
192
- symbols: C
195
+ symbols: S
193
196
  };
194
197
  if (e.length > 255) return {
195
198
  reason: t.TooLong,
196
199
  maxLength: 255
197
200
  };
198
- let i = M?.items ?? [], a = e.toLowerCase(), s = i.find((e) => e.path !== n.path && e.name.toLowerCase() === a);
201
+ let i = j?.items ?? [], a = e.toLowerCase(), s = i.find((e) => e.path !== n.path && e.name.toLowerCase() === a);
199
202
  return s ? {
200
203
  reason: t.DuplicateName,
201
204
  existingName: s.name
202
205
  } : null;
203
- }, [H, M]), le = g((t, r) => {
204
- if (t.length === 0 || J || X) return;
206
+ }, [V, j]), le = g((t, r) => {
207
+ if (t.length === 0 || q || Y) return;
205
208
  let a = new AbortController();
206
209
  Z.current = a, (async () => {
207
- Y(!0);
208
- let o = d(t, O, k), s = o.map(({ dto: e }) => e);
210
+ J(!0);
211
+ let o = d(t, D, O), s = o.map(({ dto: e }) => e);
209
212
  try {
210
- let { results: t } = await D.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
213
+ let { results: t } = await E.copyFiles(s, a.signal), c = t.filter((e) => !e.success).length, l = t.length - c;
211
214
  if (l > 0) {
212
215
  let e = p(o, t), a = s.every((e) => h(e.sourcePath) === h(e.destinationPath)), c;
213
- c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied, B?.({
216
+ c = a ? l === 1 ? n.FileDuplicated : n.FilesDuplicated : l === 1 ? n.FileCopied : n.FilesCopied, z?.({
214
217
  kind: c,
215
218
  name: e?.destinationName,
216
219
  count: l,
217
220
  isFolder: e?.dto.nodeType === b.Folder,
218
- destinationFolderName: i(r, k)
221
+ destinationFolderName: i(r, O)
219
222
  });
220
223
  }
221
- c > 0 && c < t.length ? z?.({
222
- variant: w.Error,
224
+ c > 0 && c < t.length ? R?.({
225
+ variant: C.Error,
223
226
  reason: e.CopyPartiallyFailed,
224
227
  count: c
225
- }) : c === t.length && z?.({
226
- variant: w.Error,
228
+ }) : c === t.length && R?.({
229
+ variant: C.Error,
227
230
  reason: e.CopyFailed
228
231
  });
229
232
  } catch {
230
- a.signal.aborted || z?.({
231
- variant: w.Error,
233
+ a.signal.aborted || R?.({
234
+ variant: C.Error,
232
235
  reason: e.CopyFailed
233
236
  });
234
237
  } finally {
235
- F([...new Set(s.flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), I(), Y(!1), Z.current = null;
238
+ P([...new Set(s.flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), J(!1), Z.current = null;
236
239
  }
237
240
  })();
238
241
  }, [
242
+ D,
239
243
  O,
240
- k,
244
+ R,
241
245
  z,
242
- B,
243
- D,
244
- J,
245
- X,
246
- F,
247
- I
246
+ E,
247
+ q,
248
+ Y,
249
+ P,
250
+ F
248
251
  ]), ue = g(() => {
249
252
  Z.current?.abort();
250
253
  }, []);
251
254
  return {
252
- isCreatingFolder: te,
253
- isDownloading: ne,
254
- isDeleting: re,
255
- isRenaming: K,
256
- isCopying: J,
257
- isMoving: X,
255
+ isCreatingFolder: ne,
256
+ isDownloading: re,
257
+ isDeleting: ie,
258
+ isRenaming: G,
259
+ isCopying: q,
260
+ isMoving: Y,
258
261
  onCreateFolder: ae,
259
262
  onCreateFolderValidate: $,
260
263
  onDownloadFiles: oe,
261
264
  onDeleteFiles: se,
262
265
  onRenameValidate: ce,
263
266
  onMoveToFiles: g((t, r, o) => {
264
- if (t.length === 0 || J || X || K) return;
265
- let { renameDtos: s, preparedMoveItems: c } = f(t, O, k), l = c.map(({ dto: e }) => e), u = new AbortController();
267
+ if (t.length === 0 || q || Y || G) return;
268
+ let { renameDtos: s, preparedMoveItems: c } = f(t, D, O), l = c.map(({ dto: e }) => e), u = new AbortController();
266
269
  l.length > 0 && (Z.current = u), (async () => {
267
- s.length > 0 && q(!0), l.length > 0 && ie(!0);
270
+ s.length > 0 && K(!0), l.length > 0 && X(!0);
268
271
  let [t, r] = await Promise.all([(async () => {
269
272
  if (s.length === 0) return {
270
273
  results: [],
271
274
  threw: !1
272
275
  };
273
276
  try {
274
- let { results: e } = await D.renameFiles(s);
277
+ let { results: e } = await E.renameFiles(s);
275
278
  return {
276
279
  results: e,
277
280
  threw: !1
@@ -289,7 +292,7 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
289
292
  aborted: !1
290
293
  };
291
294
  try {
292
- let { results: e } = await D.moveFiles(l, u.signal);
295
+ let { results: e } = await E.moveFiles(l, u.signal);
293
296
  return {
294
297
  results: e,
295
298
  threw: !1,
@@ -305,57 +308,57 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
305
308
  })()]), d = t.threw ? s.length : t.results.filter((e) => !e.success).length, f = r.threw && r.aborted, m = f ? 0 : l.length, g = f ? 0 : r.threw ? l.length : r.results.filter((e) => !e.success).length, _ = r.threw ? 0 : r.results.filter((e) => e.success).length, v = s.length + m, y = d + g, b = g > 0;
306
309
  if (_ > 0) {
307
310
  let e = p(c, r.results);
308
- B?.({
311
+ z?.({
309
312
  kind: _ === 1 ? n.FileMoved : n.FilesMoved,
310
313
  name: e?.destinationName,
311
314
  count: _,
312
315
  isFolder: e?.dto.nodeType === ee.Folder,
313
- destinationFolderName: i(o, k)
316
+ destinationFolderName: i(o, O)
314
317
  });
315
318
  }
316
319
  if (s.length === 1 && d === 0) {
317
320
  let [e] = s;
318
- B?.({
321
+ z?.({
319
322
  kind: n.FileRenamed,
320
323
  name: a(e.destinationPath, e.destinationPath),
321
- isFolder: e.nodeType === S.Folder
324
+ isFolder: e.nodeType === te.Folder
322
325
  });
323
326
  }
324
- y > 0 && (y === v ? z?.({
325
- variant: w.Error,
327
+ y > 0 && (y === v ? R?.({
328
+ variant: C.Error,
326
329
  reason: b ? e.MoveFailed : e.RenameFailed
327
- }) : z?.({
328
- variant: w.Error,
330
+ }) : R?.({
331
+ variant: C.Error,
329
332
  reason: b ? e.MovePartiallyFailed : e.RenamePartiallyFailed,
330
333
  count: y
331
334
  }));
332
- let x = s.find((e) => e.nodeType === S.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
335
+ let x = s.find((e) => e.nodeType === te.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
333
336
  if (x != null) {
334
337
  let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
335
- if (j === e || j.startsWith(e)) {
338
+ if (A === e || A.startsWith(e)) {
336
339
  let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
337
- R(j.replace(e, t));
340
+ L(A.replace(e, t));
338
341
  }
339
342
  }
340
- F([...new Set([...s, ...l].flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), I(), q(!1), ie(!1), l.length > 0 && (Z.current = null);
343
+ P([...new Set([...s, ...l].flatMap((e) => [h(e.sourcePath), h(e.destinationPath)]))]), F(), K(!1), X(!1), l.length > 0 && (Z.current = null);
341
344
  })();
342
345
  }, [
346
+ D,
343
347
  O,
344
- k,
345
- j,
346
- B,
348
+ A,
347
349
  z,
348
- D,
349
- J,
350
- X,
351
- K,
350
+ R,
351
+ E,
352
+ q,
353
+ Y,
354
+ G,
355
+ P,
352
356
  F,
353
- I,
354
- R
357
+ L
355
358
  ]),
356
359
  onCopyFiles: le,
357
360
  cancelCopyMove: ue
358
361
  };
359
362
  };
360
363
  //#endregion
361
- export { D as useDialFileMutations };
364
+ export { E as useDialFileMutations };
package/index.d.ts CHANGED
@@ -2881,7 +2881,7 @@ declare interface OoxmlDocxHighlightLocation {
2881
2881
  path: number[];
2882
2882
  /** Inclusive start character offset within the story's matched text. */
2883
2883
  start: number;
2884
- /** Exclusive end character offset, already converted from the wire's inclusive `end`. */
2884
+ /** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
2885
2885
  endExclusive: number;
2886
2886
  /** The cited text, compared against the text resolved over `[start, endExclusive)`. */
2887
2887
  text: string;
@@ -2945,7 +2945,7 @@ declare interface OoxmlPptxHighlightLocation {
2945
2945
  shapeId: string;
2946
2946
  /** Inclusive start character offset within the shape's matched text. */
2947
2947
  start: number;
2948
- /** Exclusive end character offset, already converted from the wire's inclusive `end`. */
2948
+ /** Exclusive end character offset — the wire's `end`, already exclusive, copied through unchanged. */
2949
2949
  endExclusive: number;
2950
2950
  /** The cited text, compared against the text resolved over `[start, endExclusive)`. */
2951
2951
  text: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.2.0-dev.285",
4
+ "version": "1.2.0-dev.288",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -111,7 +111,7 @@
111
111
  }
112
112
  },
113
113
  "dependencies": {
114
- "@epam/ai-dial-chat-api-client": "1.2.0-dev.285",
114
+ "@epam/ai-dial-chat-api-client": "1.2.0-dev.288",
115
115
  "dompurify": "3.4.16",
116
116
  "fflate": "^0.8.3",
117
117
  "lru-cache": "^10.4.3",
@@ -120,21 +120,21 @@
120
120
  },
121
121
  "peerDependencies": {
122
122
  "react": "^19.2.8",
123
- "@epam/ai-dial-attachment-canvas": "1.2.0-dev.285",
124
- "@epam/ai-dial-attachment-input": "1.2.0-dev.285",
125
- "@epam/ai-dial-catalog": "1.2.0-dev.285",
126
- "@epam/ai-dial-chat-overlay": "1.2.0-dev.285",
127
- "@epam/ai-dial-chat-shared": "1.2.0-dev.285",
128
- "@epam/ai-dial-mcp-apps": "1.2.0-dev.285",
129
- "@epam/ai-dial-publish-panel": "1.2.0-dev.285",
130
- "@epam/ai-dial-quotations": "1.2.0-dev.285",
123
+ "@epam/ai-dial-attachment-canvas": "1.2.0-dev.288",
124
+ "@epam/ai-dial-attachment-input": "1.2.0-dev.288",
125
+ "@epam/ai-dial-catalog": "1.2.0-dev.288",
126
+ "@epam/ai-dial-chat-overlay": "1.2.0-dev.288",
127
+ "@epam/ai-dial-chat-shared": "1.2.0-dev.288",
128
+ "@epam/ai-dial-mcp-apps": "1.2.0-dev.288",
129
+ "@epam/ai-dial-publish-panel": "1.2.0-dev.288",
130
+ "@epam/ai-dial-quotations": "1.2.0-dev.288",
131
131
  "@epam/ai-dial-react-file-manager": "^0.3.0-dev.25",
132
- "@epam/ai-dial-scheduled-tasks": "1.2.0-dev.285",
133
- "@epam/ai-dial-share": "1.2.0-dev.285",
134
- "@epam/ai-dial-skill-editor": "1.2.0-dev.285",
135
- "@epam/ai-dial-source-panel": "1.2.0-dev.285",
132
+ "@epam/ai-dial-scheduled-tasks": "1.2.0-dev.288",
133
+ "@epam/ai-dial-share": "1.2.0-dev.288",
134
+ "@epam/ai-dial-skill-editor": "1.2.0-dev.288",
135
+ "@epam/ai-dial-source-panel": "1.2.0-dev.288",
136
136
  "@epam/ai-dial-ui-kit": "^0.15.0-dev.36",
137
- "@epam/ai-dial-usage-dashboard": "1.2.0-dev.285",
137
+ "@epam/ai-dial-usage-dashboard": "1.2.0-dev.288",
138
138
  "@modelcontextprotocol/sdk": "^1.29.0",
139
139
  "@epam/pdf-highlighter-kit": "^0.0.19",
140
140
  "@mcp-ui/client": "^7.1.1"