@epam/ai-dial-quotations 1.1.0-dev.433 → 1.1.0-dev.435
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.d.ts +3 -2
- package/index.d.ts.map +1 -1
- package/index.js +106 -38
- package/models/office-highlight.d.ts +62 -0
- package/models/office-highlight.d.ts.map +1 -0
- package/package.json +2 -2
- package/utils/annotation.d.ts +24 -1
- package/utils/annotation.d.ts.map +1 -1
- package/utils/group-annotations-by-source.d.ts +10 -0
- package/utils/group-annotations-by-source.d.ts.map +1 -1
package/index.d.ts
CHANGED
|
@@ -10,9 +10,10 @@ export { useAnnotations } from './utils/useAnnotations';
|
|
|
10
10
|
export { useCitationCard } from './utils/useCitationCard';
|
|
11
11
|
export { useCitationMarkdownComponents } from './hooks/useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
12
12
|
export type { UseCitationMarkdownComponentsCallbacks } from './hooks/useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
13
|
-
export { groupAnnotations, groupAnnotationsByCitId, groupAnnotationsBySource, } from './utils/group-annotations-by-source';
|
|
13
|
+
export { gatherSameSourceAnnotations, groupAnnotations, groupAnnotationsByCitId, groupAnnotationsBySource, } from './utils/group-annotations-by-source';
|
|
14
14
|
export type { AnnotationGroup } from './utils/group-annotations-by-source';
|
|
15
|
-
export { annotationsToPdfHighlights,
|
|
15
|
+
export { annotationHighlightId, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, normalizeRawAnnotations, resolveMessageAnnotations, } from './utils/annotation';
|
|
16
|
+
export type { DocxOfficeHighlightLocation, ExcelOfficeHighlightLocation, OfficeHighlightLocation, PptxOfficeHighlightLocation, } from './models/office-highlight';
|
|
16
17
|
export { injectCitationSentinels, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
|
|
17
18
|
export { isReferenceOnlyAttachment, parsePdfPageReference, getReferenceAttachmentGroups, } from './utils/reference-attachment';
|
|
18
19
|
export type { PdfPageReference } from './utils/reference-attachment';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AACpH,YAAY,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAC;AAGlI,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACL,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AACpH,YAAY,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAC;AAGlI,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,oCAAoC,EACpC,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/index.js
CHANGED
|
@@ -169,7 +169,7 @@ var j = {
|
|
|
169
169
|
if (t != null) return t;
|
|
170
170
|
let n = e.split(/[?#]/)[0], i = n.lastIndexOf(".");
|
|
171
171
|
if (i !== -1) return M[n.slice(i + 1).toLowerCase()];
|
|
172
|
-
}, P = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "type" in e && typeof e.type == "string", ee = (e) => Array.isArray(e) ? e.filter(P) : P(e) ? e : void 0,
|
|
172
|
+
}, P = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "type" in e && typeof e.type == "string", ee = (e) => Array.isArray(e) ? e.filter(P) : P(e) ? e : void 0, te = (e) => e.flatMap((e, t) => {
|
|
173
173
|
let n = e.body?.selector;
|
|
174
174
|
if (n == null) return [];
|
|
175
175
|
let r = (Array.isArray(n) ? n : [n]).flatMap((e) => {
|
|
@@ -193,38 +193,38 @@ var j = {
|
|
|
193
193
|
bboxes: r,
|
|
194
194
|
style: j
|
|
195
195
|
}];
|
|
196
|
-
}),
|
|
196
|
+
}), ne = (e, t) => String(e.index ?? t), re = (e) => {
|
|
197
197
|
let t = e.body?.selector;
|
|
198
198
|
if (t != null) return (Array.isArray(t) ? t : [t]).find((e) => P(e) && e.type === "pdf_bbox" && typeof e.page == "number" && Number.isInteger(e.page) && e.page >= 1)?.page;
|
|
199
|
-
},
|
|
199
|
+
}, F = (e) => typeof e == "number" ? e : null, ie = (e) => {
|
|
200
200
|
if (typeof e != "object" || !e) return null;
|
|
201
201
|
let t = e;
|
|
202
202
|
if (t.type !== "pdf_region") return null;
|
|
203
203
|
let n = t.bbox;
|
|
204
204
|
if (typeof n != "object" || !n) return null;
|
|
205
|
-
let r = n, i =
|
|
205
|
+
let r = n, i = F(r.left), a = F(r.top), o = F(r.width), s = F(r.height);
|
|
206
206
|
return i === null || a === null || o === null || s === null ? null : {
|
|
207
207
|
type: "pdf_bbox",
|
|
208
|
-
page:
|
|
208
|
+
page: F(t.page) ?? 1,
|
|
209
209
|
x1: i,
|
|
210
210
|
y1: a,
|
|
211
211
|
x2: i + o,
|
|
212
212
|
y2: a + s
|
|
213
213
|
};
|
|
214
|
-
},
|
|
214
|
+
}, ae = (t, n) => {
|
|
215
215
|
let r = t.target;
|
|
216
216
|
if (typeof r != "object" || !r) return null;
|
|
217
217
|
let i = r, a = i.source;
|
|
218
218
|
if (typeof a != "object" || !a) return null;
|
|
219
|
-
let o =
|
|
219
|
+
let o = F(a.attachment_index);
|
|
220
220
|
if (o === null) return null;
|
|
221
221
|
let s = n.find((e) => e.index === o);
|
|
222
222
|
if (s?.url == null) return null;
|
|
223
|
-
let c =
|
|
223
|
+
let c = ie(i.selector);
|
|
224
224
|
if (c === null) return null;
|
|
225
225
|
let l = t.body, u = typeof l == "object" && l ? l : {}, d = typeof u.title == "string" ? u.title : void 0, f = typeof u.quote == "string" ? u.quote : void 0;
|
|
226
226
|
return {
|
|
227
|
-
index:
|
|
227
|
+
index: F(t.index) ?? void 0,
|
|
228
228
|
body: {
|
|
229
229
|
title: d,
|
|
230
230
|
quote: f,
|
|
@@ -239,7 +239,7 @@ var j = {
|
|
|
239
239
|
selector: c
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
|
-
},
|
|
242
|
+
}, oe = (t) => {
|
|
243
243
|
let n = t.target;
|
|
244
244
|
if (typeof n != "object" || !n) return null;
|
|
245
245
|
let r = n.selector;
|
|
@@ -260,7 +260,7 @@ var j = {
|
|
|
260
260
|
if (typeof u != "string") return null;
|
|
261
261
|
let d = typeof s.title == "string" ? s.title : void 0, f = typeof s.quote == "string" ? s.quote : void 0, p = ee(s.selector);
|
|
262
262
|
return {
|
|
263
|
-
index:
|
|
263
|
+
index: F(t.index) ?? void 0,
|
|
264
264
|
target: { selector: a },
|
|
265
265
|
body: {
|
|
266
266
|
title: d,
|
|
@@ -276,7 +276,7 @@ var j = {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
|
-
},
|
|
279
|
+
}, I = (e) => {
|
|
280
280
|
if (e.target?.selector?.type !== "html_tag") return e;
|
|
281
281
|
let t = e.body?.source?.attachment;
|
|
282
282
|
if (t?.url == null) return e;
|
|
@@ -295,24 +295,89 @@ var j = {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
},
|
|
298
|
+
}, L = (e, t) => e.flatMap((e) => {
|
|
299
299
|
if (typeof e != "object" || !e) return [];
|
|
300
|
-
let n = e, r =
|
|
300
|
+
let n = e, r = oe(n);
|
|
301
301
|
if (r) return [r];
|
|
302
|
-
let i =
|
|
302
|
+
let i = ae(n, t);
|
|
303
303
|
return i ? [i] : [];
|
|
304
|
-
}),
|
|
304
|
+
}), R = (e) => {
|
|
305
305
|
let t = e.custom_content?.annotations;
|
|
306
|
-
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(
|
|
306
|
+
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(I);
|
|
307
307
|
let n = e.custom_fields;
|
|
308
308
|
if (typeof n != "object" || !n) return [];
|
|
309
309
|
let r = n.annotations;
|
|
310
|
-
return !Array.isArray(r) || r.length === 0 ? [] :
|
|
311
|
-
},
|
|
310
|
+
return !Array.isArray(r) || r.length === 0 ? [] : L(r, e.custom_content?.attachments ?? []).map(I);
|
|
311
|
+
}, z = (e) => {
|
|
312
|
+
if (e.type !== "docx_text_range") return !1;
|
|
313
|
+
let t = e;
|
|
314
|
+
return typeof t.story == "string" && Array.isArray(t.path) && t.path.every((e) => typeof e == "number") && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
315
|
+
}, B = (e) => {
|
|
316
|
+
if (e.type !== "pptx_text_range") return !1;
|
|
317
|
+
let t = e;
|
|
318
|
+
return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
319
|
+
}, V = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", H = (e) => {
|
|
320
|
+
if (e.type !== "excel_rc_range") return !1;
|
|
321
|
+
let t = e;
|
|
322
|
+
return typeof t.sheet == "string" && V(t.start) && (t.end === void 0 || t.end === null || V(t.end));
|
|
323
|
+
}, se = (e) => {
|
|
324
|
+
let { story: t, path: n, start: r, end: i, text: a } = e;
|
|
325
|
+
if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
326
|
+
type: "docx_text_range",
|
|
327
|
+
story: t,
|
|
328
|
+
path: n,
|
|
329
|
+
start: r,
|
|
330
|
+
endExclusive: i,
|
|
331
|
+
text: a
|
|
332
|
+
};
|
|
333
|
+
}, ce = (e) => {
|
|
334
|
+
let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
|
|
335
|
+
if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
336
|
+
type: "pptx_text_range",
|
|
337
|
+
slide: t,
|
|
338
|
+
shapeId: n,
|
|
339
|
+
start: r,
|
|
340
|
+
endExclusive: i,
|
|
341
|
+
text: a
|
|
342
|
+
};
|
|
343
|
+
}, le = (e) => {
|
|
344
|
+
let { sheet: t, start: n, end: r } = e;
|
|
345
|
+
if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
|
|
346
|
+
if (r == null) return {
|
|
347
|
+
type: "excel_rc_range",
|
|
348
|
+
sheet: t,
|
|
349
|
+
start: n
|
|
350
|
+
};
|
|
351
|
+
if (!(!Number.isInteger(r.row) || !Number.isInteger(r.col) || r.row !== n.row || r.col < n.col)) return {
|
|
352
|
+
type: "excel_rc_range",
|
|
353
|
+
sheet: t,
|
|
354
|
+
start: n,
|
|
355
|
+
end: r
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}, ue = (e) => {
|
|
359
|
+
let t = e.body?.selector;
|
|
360
|
+
return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
361
|
+
if (!P(e)) return [];
|
|
362
|
+
if (z(e)) {
|
|
363
|
+
let t = se(e);
|
|
364
|
+
return t ? [t] : [];
|
|
365
|
+
}
|
|
366
|
+
if (B(e)) {
|
|
367
|
+
let t = ce(e);
|
|
368
|
+
return t ? [t] : [];
|
|
369
|
+
}
|
|
370
|
+
if (H(e)) {
|
|
371
|
+
let t = le(e);
|
|
372
|
+
return t ? [t] : [];
|
|
373
|
+
}
|
|
374
|
+
return [];
|
|
375
|
+
});
|
|
376
|
+
}, de = (e, t) => v(() => t ? [] : R(e), [t, e]), fe = {
|
|
312
377
|
openGroupKey: null,
|
|
313
378
|
activeIndexByGroup: {}
|
|
314
|
-
},
|
|
315
|
-
let [e, t] = y(
|
|
379
|
+
}, pe = () => {
|
|
380
|
+
let [e, t] = y(fe), n = g((e) => {
|
|
316
381
|
t((t) => ({
|
|
317
382
|
...t,
|
|
318
383
|
openGroupKey: e
|
|
@@ -343,7 +408,7 @@ var j = {
|
|
|
343
408
|
i,
|
|
344
409
|
e
|
|
345
410
|
]);
|
|
346
|
-
},
|
|
411
|
+
}, me = /⟦C(\d+)⟧/g, U = (e, t) => {
|
|
347
412
|
let n = t.map((e, t) => ({
|
|
348
413
|
g: e,
|
|
349
414
|
idx: t
|
|
@@ -356,9 +421,9 @@ var j = {
|
|
|
356
421
|
}).sort((e, t) => t.pos - e.pos), r = e;
|
|
357
422
|
for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
|
|
358
423
|
return r;
|
|
359
|
-
},
|
|
424
|
+
}, he = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, ge = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, _e = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, ve = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), W = (e) => e.replace(_e, (e) => ge.test(e) ? e : ve(e)), G = (e) => W(e).replace(he, ""), K = (e, t) => {
|
|
360
425
|
if (typeof e == "string") {
|
|
361
|
-
let n = e.split(
|
|
426
|
+
let n = e.split(me);
|
|
362
427
|
if (n.length === 1) return e;
|
|
363
428
|
let r = [];
|
|
364
429
|
return n.forEach((e, n) => {
|
|
@@ -369,15 +434,15 @@ var j = {
|
|
|
369
434
|
let n = K(e, t);
|
|
370
435
|
return Array.isArray(n) ? n : [n];
|
|
371
436
|
}) : e;
|
|
372
|
-
},
|
|
437
|
+
}, ye = (e) => {
|
|
373
438
|
let t = e.primaryAnnotation.target?.selector;
|
|
374
439
|
return t?.type === "html_tag" ? t.id : void 0;
|
|
375
|
-
},
|
|
440
|
+
}, be = (e, t) => /* @__PURE__ */ S(b, { children: [
|
|
376
441
|
e == null ? "<cit>" : `<cit data-id="${e}">`,
|
|
377
442
|
t,
|
|
378
443
|
"</cit>"
|
|
379
|
-
] }),
|
|
380
|
-
let { onPreview: o, onOpenInBrowser: s, buildLabels: c } = n, l = v(() => r ? G(e) : W(t.length > 0 ?
|
|
444
|
+
] }), xe = (e, t, n, r = !1, a = !1) => {
|
|
445
|
+
let { onPreview: o, onOpenInBrowser: s, buildLabels: c } = n, l = v(() => r ? G(e) : W(t.length > 0 ? U(e, t) : e), [
|
|
381
446
|
e,
|
|
382
447
|
t,
|
|
383
448
|
r
|
|
@@ -387,7 +452,7 @@ var j = {
|
|
|
387
452
|
markdownComponents: v(() => {
|
|
388
453
|
let e = /* @__PURE__ */ new Map();
|
|
389
454
|
for (let n of t) {
|
|
390
|
-
let t =
|
|
455
|
+
let t = ye(n);
|
|
391
456
|
t != null && e.set(t, n);
|
|
392
457
|
}
|
|
393
458
|
let n = (e) => {
|
|
@@ -404,7 +469,7 @@ var j = {
|
|
|
404
469
|
return r ? n(r) : null;
|
|
405
470
|
}, l = { cit: (t) => {
|
|
406
471
|
let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
|
|
407
|
-
return r ? n(r) :
|
|
472
|
+
return r ? n(r) : be(t["data-id"], t.children);
|
|
408
473
|
} };
|
|
409
474
|
return t.length === 0 ? u ? l : {} : {
|
|
410
475
|
...l,
|
|
@@ -434,20 +499,20 @@ var j = {
|
|
|
434
499
|
} catch {
|
|
435
500
|
return e;
|
|
436
501
|
}
|
|
437
|
-
},
|
|
502
|
+
}, Se = (e) => {
|
|
438
503
|
try {
|
|
439
504
|
let t = new URL(e);
|
|
440
505
|
return t.pathname.split("/").map((e) => q(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
441
506
|
} catch {
|
|
442
507
|
return e.split("/").map((e) => q(e)).filter(Boolean).at(-1) ?? e;
|
|
443
508
|
}
|
|
444
|
-
}, J = (e, t) => e.body?.source?.attachment?.title ??
|
|
509
|
+
}, J = (e, t) => e.body?.source?.attachment?.title ?? Se(t), Y = (e) => {
|
|
445
510
|
let t = e.target?.selector;
|
|
446
511
|
return t?.type === "html_tag" ? t : void 0;
|
|
447
|
-
},
|
|
512
|
+
}, Ce = (e) => Y(e) != null, X = (e) => {
|
|
448
513
|
let t = /* @__PURE__ */ new Map();
|
|
449
514
|
for (let n of e) {
|
|
450
|
-
if (
|
|
515
|
+
if (Ce(n)) continue;
|
|
451
516
|
let e = n.body?.source?.attachment?.url;
|
|
452
517
|
if (e == null) continue;
|
|
453
518
|
let r = t.get(e);
|
|
@@ -477,13 +542,16 @@ var j = {
|
|
|
477
542
|
});
|
|
478
543
|
}
|
|
479
544
|
return Array.from(t.values());
|
|
480
|
-
},
|
|
481
|
-
let
|
|
545
|
+
}, we = (e) => [...Z(e), ...X(e)], Te = (e, t) => {
|
|
546
|
+
let n = e.body?.source?.attachment?.url;
|
|
547
|
+
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
548
|
+
}, Q = (e) => e.url == null && e.reference_url != null, Ee = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
|
|
549
|
+
let t = Ee.exec(e);
|
|
482
550
|
return t ? {
|
|
483
551
|
baseUrl: t[1],
|
|
484
552
|
page: t[2] == null ? null : Number(t[2])
|
|
485
553
|
} : null;
|
|
486
|
-
},
|
|
554
|
+
}, De = (t) => X((t ?? []).filter(Q).map((t) => {
|
|
487
555
|
let n = t.reference_url, r = $(n) != null;
|
|
488
556
|
return { body: {
|
|
489
557
|
quote: t.data,
|
|
@@ -498,4 +566,4 @@ var j = {
|
|
|
498
566
|
} };
|
|
499
567
|
}));
|
|
500
568
|
//#endregion
|
|
501
|
-
export { w as CitationCard, D as CitationCardProvider, A as CitationDropdown, T as CitationMarker,
|
|
569
|
+
export { w as CitationCard, D as CitationCardProvider, A as CitationDropdown, T as CitationMarker, ne as annotationHighlightId, ue as annotationToOfficeHighlightLocations, te as annotationsToPdfHighlights, Te as gatherSameSourceAnnotations, re as getAnnotationPdfPage, De as getReferenceAttachmentGroups, we as groupAnnotations, Z as groupAnnotationsByCitId, X as groupAnnotationsBySource, U as injectCitationSentinels, z as isDocxRangeSelector, H as isExcelRcRangeSelector, B as isPptxRangeSelector, Q as isReferenceOnlyAttachment, L as normalizeRawAnnotations, $ as parsePdfPageReference, K as replaceSentinelsInChildren, R as resolveMessageAnnotations, G as stripCitTagsWhileStreaming, de as useAnnotations, pe as useCitationCard, O as useCitationCardContext, xe as useCitationMarkdownComponents };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ExcelCellAddress } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/**
|
|
3
|
+
* A validated, normalised DOCX character-range location. `endExclusive` is
|
|
4
|
+
* the wire's `end` copied through unchanged — confirmed exclusive on the
|
|
5
|
+
* wire, unlike `TextCharacterRangeSelector`'s inclusive `end` (see the
|
|
6
|
+
* `annotation.ts` normaliser and `design.md` D3 for the evidence).
|
|
7
|
+
*/
|
|
8
|
+
export interface DocxOfficeHighlightLocation {
|
|
9
|
+
/** Discriminates this location within `OfficeHighlightLocation`. Mirrors the wire selector's `type`. */
|
|
10
|
+
type: 'docx_text_range';
|
|
11
|
+
/** Name of the DOCX story the range lives in, as an opaque string (only `'body'` is confirmed upstream). */
|
|
12
|
+
story: string;
|
|
13
|
+
/** Source-tree element indices identifying the paragraph, matched element-wise. */
|
|
14
|
+
path: number[];
|
|
15
|
+
/** Zero-based start character offset. */
|
|
16
|
+
start: number;
|
|
17
|
+
/** Zero-based exclusive end character offset. */
|
|
18
|
+
endExclusive: number;
|
|
19
|
+
/** The cited text, expected to equal the text resolved over `[start, endExclusive)`. */
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A validated, normalised PPTX character-range location. `endExclusive` is
|
|
24
|
+
* the wire's `end` copied through unchanged — confirmed exclusive on the
|
|
25
|
+
* wire (see `design.md` D3).
|
|
26
|
+
*/
|
|
27
|
+
export interface PptxOfficeHighlightLocation {
|
|
28
|
+
/** Discriminates this location within `OfficeHighlightLocation`. Mirrors the wire selector's `type`. */
|
|
29
|
+
type: 'pptx_text_range';
|
|
30
|
+
/** 1-based slide number. */
|
|
31
|
+
slide: number;
|
|
32
|
+
/** Shape identifier, compared as a string against the run's own shape id. */
|
|
33
|
+
shapeId: string;
|
|
34
|
+
/** Zero-based start character offset. */
|
|
35
|
+
start: number;
|
|
36
|
+
/** Zero-based exclusive end character offset. */
|
|
37
|
+
endExclusive: number;
|
|
38
|
+
/** The cited text, expected to equal the text resolved over `[start, endExclusive)`. */
|
|
39
|
+
text: string;
|
|
40
|
+
}
|
|
41
|
+
/** A validated, normalised XLSX cell or same-row cell-range location. */
|
|
42
|
+
export interface ExcelOfficeHighlightLocation {
|
|
43
|
+
/** Discriminates this location within `OfficeHighlightLocation`. Mirrors the wire selector's `type`. */
|
|
44
|
+
type: 'excel_rc_range';
|
|
45
|
+
/** Sheet name, matched exactly against the workbook's own sheet names. */
|
|
46
|
+
sheet: string;
|
|
47
|
+
/** First cell of the range. */
|
|
48
|
+
start: ExcelCellAddress;
|
|
49
|
+
/** Last (inclusive) cell of the range, on the same row as `start`. Omitted for a single cell. */
|
|
50
|
+
end?: ExcelCellAddress;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A validated, normalised Office document highlight location, produced by
|
|
54
|
+
* `annotationToOfficeHighlightLocations`. Intentionally not the
|
|
55
|
+
* `@epam/ai-dial-attachment-canvas` `OoxmlHighlightLocation` shape — this lib
|
|
56
|
+
* must not depend on `attachment-canvas` (that lib's own test already
|
|
57
|
+
* depends on this one, via `annotationsToPdfHighlights`, and a lib-to-lib
|
|
58
|
+
* cycle is not permitted). `libs/chat-hooks`, which already depends on both,
|
|
59
|
+
* maps this into `OoxmlHighlight`/`OoxmlHighlightLocation`.
|
|
60
|
+
*/
|
|
61
|
+
export type OfficeHighlightLocation = DocxOfficeHighlightLocation | PptxOfficeHighlightLocation | ExcelOfficeHighlightLocation;
|
|
62
|
+
//# sourceMappingURL=office-highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"office-highlight.d.ts","sourceRoot":"","sources":["../../src/models/office-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,wGAAwG;IACxG,IAAI,EAAE,iBAAiB,CAAC;IACxB,4GAA4G;IAC5G,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,wGAAwG;IACxG,IAAI,EAAE,iBAAiB,CAAC;IACxB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yEAAyE;AACzE,MAAM,WAAW,4BAA4B;IAC3C,wGAAwG;IACxG,IAAI,EAAE,gBAAgB,CAAC;IACvB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,KAAK,EAAE,gBAAgB,CAAC;IACxB,iGAAiG;IACjG,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAC/B,2BAA2B,GAC3B,2BAA2B,GAC3B,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-quotations",
|
|
3
3
|
"description": "Citation and annotation components, hooks, and utilities for AI DIAL conversations",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.435",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"react": "^19.0.0",
|
|
20
20
|
"react-markdown": "^10.1.0",
|
|
21
21
|
"@tabler/icons-react": "^3.0.0",
|
|
22
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
22
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.435",
|
|
23
23
|
"@epam/ai-dial-ui-kit": "*",
|
|
24
24
|
"@epam/pdf-highlighter-kit": ">=0.0.14"
|
|
25
25
|
},
|
package/utils/annotation.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Annotation, Message, MessageAttachment } from '@epam/ai-dial-chat-shared';
|
|
1
|
+
import { Annotation, AnnotationSelector, DocxRangeSelector, ExcelRcRangeSelector, Message, MessageAttachment, PptxRangeSelector } from '@epam/ai-dial-chat-shared';
|
|
2
2
|
import { InputHighlightData } from '@epam/pdf-highlighter-kit';
|
|
3
|
+
import { OfficeHighlightLocation } from '../models/office-highlight';
|
|
3
4
|
/**
|
|
4
5
|
* Maps a list of annotations to `InputHighlightData` entries for the PDF viewer.
|
|
5
6
|
* Annotations whose `body.selector` contains no `pdf_bbox` selectors are skipped.
|
|
@@ -39,4 +40,26 @@ export declare const normalizeRawAnnotations: (rawAnnotations: unknown[], attach
|
|
|
39
40
|
* normalises those entries using the message's `custom_content.attachments`.
|
|
40
41
|
*/
|
|
41
42
|
export declare const resolveMessageAnnotations: (message: Message) => Annotation[];
|
|
43
|
+
/**
|
|
44
|
+
* Returns whether `selector` is a `docx_text_range` selector carrying every
|
|
45
|
+
* field the shape requires — a `_range`-suffixed selector missing any field
|
|
46
|
+
* (or with a wrongly-typed one) does not match.
|
|
47
|
+
*/
|
|
48
|
+
export declare const isDocxRangeSelector: (selector: AnnotationSelector) => selector is DocxRangeSelector;
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether `selector` is a `pptx_text_range` selector carrying every
|
|
51
|
+
* field the shape requires.
|
|
52
|
+
*/
|
|
53
|
+
export declare const isPptxRangeSelector: (selector: AnnotationSelector) => selector is PptxRangeSelector;
|
|
54
|
+
/**
|
|
55
|
+
* Returns whether `selector` is an `excel_rc_range` selector carrying every
|
|
56
|
+
* field the shape requires. `end` may be a cell address, `null`, or absent.
|
|
57
|
+
*/
|
|
58
|
+
export declare const isExcelRcRangeSelector: (selector: AnnotationSelector) => selector is ExcelRcRangeSelector;
|
|
59
|
+
/**
|
|
60
|
+
* Converts an annotation's `body.selector` (scalar or array) to validated
|
|
61
|
+
* `OfficeHighlightLocation` entries, skipping any selector that is not a
|
|
62
|
+
* recognised Office range or that fails validation — never throwing.
|
|
63
|
+
*/
|
|
64
|
+
export declare const annotationToOfficeHighlightLocations: (annotation: Annotation) => OfficeHighlightLocation[];
|
|
42
65
|
//# sourceMappingURL=annotation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/utils/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/utils/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EAEpB,OAAO,EACP,iBAAiB,EAEjB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAEV,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAyC1E;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,aAAa,UAAU,EAAE,KACxB,kBAAkB,EA0BjB,CAAC;AAEL,oHAAoH;AACpH,eAAO,MAAM,qBAAqB,GAChC,YAAY,UAAU,EACtB,eAAe,MAAM,KACpB,MAAmD,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAY,UAAU,KACrB,MAAM,GAAG,SAcX,CAAC;AA4KF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,GAClC,gBAAgB,OAAO,EAAE,EACzB,aAAa,iBAAiB,EAAE,KAC/B,UAAU,EAeT,CAAC;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,OAAO,KAAG,UAAU,EAoBtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,iBAWd,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,iBAUd,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,oBAQd,CAAC;AA8FF;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,GAC/C,YAAY,UAAU,KACrB,uBAAuB,EAsBzB,CAAC"}
|
|
@@ -41,4 +41,14 @@ export declare const groupAnnotationsByCitId: (annotations: Annotation[]) => Ann
|
|
|
41
41
|
* citations without branching on selector type itself.
|
|
42
42
|
*/
|
|
43
43
|
export declare const groupAnnotations: (annotations: Annotation[]) => AnnotationGroup[];
|
|
44
|
+
/**
|
|
45
|
+
* Returns every annotation in `annotations` whose `body.source.attachment.url`
|
|
46
|
+
* equals `clicked`'s, in their original order — gathering across the whole
|
|
47
|
+
* list rather than one `cit`-id group, so annotations behind other markers
|
|
48
|
+
* citing the same file are included too. Keys on URL, never on the display
|
|
49
|
+
* title, since two different files can share a title. Returns `[clicked]`
|
|
50
|
+
* when `clicked` is not itself present in `annotations` (identified by
|
|
51
|
+
* reference identity) or has no source URL.
|
|
52
|
+
*/
|
|
53
|
+
export declare const gatherSameSourceAnnotations: (clicked: Annotation, annotations: Annotation[]) => Annotation[];
|
|
44
54
|
//# sourceMappingURL=group-annotations-by-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAkDD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,UAAU,EAAE,KACxB,eAAe,EAuBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,UAAU,EAAE,KACxB,eAAe,EAwBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,UAAU,EAAE,KACxB,eAAe,EAGjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAkDD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,UAAU,EAAE,KACxB,eAAe,EAuBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,UAAU,EAAE,KACxB,eAAe,EAwBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,UAAU,EAAE,KACxB,eAAe,EAGjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,UAAU,EACnB,aAAa,UAAU,EAAE,KACxB,UAAU,EAKZ,CAAC"}
|