@epam/ai-dial-quotations 1.1.0-dev.286 → 1.1.0-dev.287
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/components/CitationDropdown/CitationDropdown.d.ts.map +1 -1
- package/index.css +1 -1
- package/index.js +55 -55
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAQ,SAAS,EAAwB,MAAM,OAAO,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8HAA8H;AAC9H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAuEtD,CAAC;;AAEF,wBAAsC"}
|
package/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
._card_1kph1_1{background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_1kph1_5{color:var(--cc-quote-text,var(--text-secondary,#57647a))}._title_1kph1_9{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_1kph1_13{color:var(--cc-switcher-text,var(--text-secondary,#57647a))}._sourceName_1kph1_17{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}
|
|
1
|
+
._card_1kph1_1{background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_1kph1_5{color:var(--cc-quote-text,var(--text-secondary,#57647a))}._title_1kph1_9{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_1kph1_13{color:var(--cc-switcher-text,var(--text-secondary,#57647a))}._sourceName_1kph1_17{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}._content_xzs0h_1>svg{fill:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc));stroke:#0000}
|
|
2
2
|
/*$vite$:1*/
|
package/index.js
CHANGED
|
@@ -113,47 +113,47 @@ var C = f(null), w = C.Provider, T = () => {
|
|
|
113
113
|
let e = h(C);
|
|
114
114
|
if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
|
|
115
115
|
return e;
|
|
116
|
-
}, E = ({ group: e, onPreview: t, onOpenInBrowser: n, icon:
|
|
117
|
-
let
|
|
116
|
+
}, E = { content: "_content_xzs0h_1" }, D = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: i, headerIcon: a, cardLabels: o, markerLabels: s, cardTypography: c, markerLabelClassName: u }) => {
|
|
117
|
+
let d = T(), f = d.isOpen(e.sourceUrl), p = d.getActiveIndex(e.sourceUrl), h = m((e) => {
|
|
118
|
+
e || d.closePopup();
|
|
119
|
+
}, [d]), _ = g(() => t ? (e) => {
|
|
120
|
+
t(e), d.closePopup();
|
|
121
|
+
} : void 0, [t, d]);
|
|
118
122
|
return /* @__PURE__ */ v(l, {
|
|
119
|
-
open:
|
|
120
|
-
onOpenChange:
|
|
121
|
-
e || u.closePopup();
|
|
122
|
-
}, [u]),
|
|
123
|
+
open: f,
|
|
124
|
+
onOpenChange: h,
|
|
123
125
|
triggerClassName: "ms-1 inline-flex align-middle",
|
|
124
|
-
contentClassName: "!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none
|
|
126
|
+
contentClassName: r("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", E.content),
|
|
125
127
|
tooltip: /* @__PURE__ */ v(x, {
|
|
126
128
|
group: e,
|
|
127
|
-
activeIndex:
|
|
128
|
-
onIndexChange: (t) =>
|
|
129
|
-
onPreview:
|
|
130
|
-
t(e), u.closePopup();
|
|
131
|
-
} : void 0, [t, u]),
|
|
129
|
+
activeIndex: p,
|
|
130
|
+
onIndexChange: (t) => d.setActiveIndex(e.sourceUrl, t),
|
|
131
|
+
onPreview: _,
|
|
132
132
|
onOpenInBrowser: n,
|
|
133
|
-
headerIcon:
|
|
134
|
-
labels:
|
|
135
|
-
typography:
|
|
133
|
+
headerIcon: a,
|
|
134
|
+
labels: o,
|
|
135
|
+
typography: c
|
|
136
136
|
}),
|
|
137
137
|
children: /* @__PURE__ */ v(S, {
|
|
138
138
|
sourceName: e.sourceName,
|
|
139
139
|
annotationCount: e.annotations.length,
|
|
140
|
-
onOpen: () =>
|
|
141
|
-
icon:
|
|
142
|
-
labels:
|
|
143
|
-
labelClassName:
|
|
140
|
+
onOpen: () => d.openPopup(e.sourceUrl),
|
|
141
|
+
icon: i,
|
|
142
|
+
labels: s,
|
|
143
|
+
labelClassName: u
|
|
144
144
|
})
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
|
-
p(
|
|
147
|
+
p(D);
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/utils/annotation.ts
|
|
150
|
-
var
|
|
150
|
+
var O = {
|
|
151
151
|
backgroundColor: "transparent",
|
|
152
152
|
borderColor: "var(--stroke-accent, #1D4ED8)",
|
|
153
153
|
borderWidth: "2px",
|
|
154
154
|
opacity: .5,
|
|
155
155
|
hoverOpacity: .5
|
|
156
|
-
},
|
|
156
|
+
}, k = (e) => e.flatMap((e, t) => {
|
|
157
157
|
let n = e.body?.selector;
|
|
158
158
|
if (n == null) return [];
|
|
159
159
|
let r = (Array.isArray(n) ? n : [n]).flatMap((e) => {
|
|
@@ -170,38 +170,38 @@ var D = {
|
|
|
170
170
|
return r.length === 0 ? [] : [{
|
|
171
171
|
id: String(e.index ?? t),
|
|
172
172
|
bboxes: r,
|
|
173
|
-
style:
|
|
173
|
+
style: O
|
|
174
174
|
}];
|
|
175
|
-
}),
|
|
175
|
+
}), A = (e, t) => String(e.index ?? t), j = (e) => typeof e == "number" ? e : null, M = (e) => {
|
|
176
176
|
if (typeof e != "object" || !e) return null;
|
|
177
177
|
let t = e;
|
|
178
178
|
if (t.type !== "pdf_region") return null;
|
|
179
179
|
let n = t.bbox;
|
|
180
180
|
if (typeof n != "object" || !n) return null;
|
|
181
|
-
let r = n, i =
|
|
181
|
+
let r = n, i = j(r.left), a = j(r.top), o = j(r.width), s = j(r.height);
|
|
182
182
|
return i === null || a === null || o === null || s === null ? null : {
|
|
183
183
|
type: "pdf_bbox",
|
|
184
|
-
page:
|
|
184
|
+
page: j(t.page) ?? 1,
|
|
185
185
|
x1: i,
|
|
186
186
|
y1: a,
|
|
187
187
|
x2: i + o,
|
|
188
188
|
y2: a + s
|
|
189
189
|
};
|
|
190
|
-
},
|
|
190
|
+
}, N = (t, n) => t.flatMap((t) => {
|
|
191
191
|
if (typeof t != "object" || !t) return [];
|
|
192
192
|
let r = t, i = r.target;
|
|
193
193
|
if (typeof i != "object" || !i) return [];
|
|
194
194
|
let a = i, o = a.source;
|
|
195
195
|
if (typeof o != "object" || !o) return [];
|
|
196
|
-
let s =
|
|
196
|
+
let s = j(o.attachment_index);
|
|
197
197
|
if (s === null) return [];
|
|
198
198
|
let c = n.find((e) => e.index === s);
|
|
199
199
|
if (c?.url == null) return [];
|
|
200
|
-
let l =
|
|
200
|
+
let l = M(a.selector);
|
|
201
201
|
if (l === null) return [];
|
|
202
202
|
let u = r.body, d = typeof u == "object" && u ? u : {}, f = typeof d.title == "string" ? d.title : void 0, p = typeof d.quote == "string" ? d.quote : void 0;
|
|
203
203
|
return [{
|
|
204
|
-
index:
|
|
204
|
+
index: j(r.index) ?? void 0,
|
|
205
205
|
body: {
|
|
206
206
|
title: f,
|
|
207
207
|
quote: p,
|
|
@@ -216,18 +216,18 @@ var D = {
|
|
|
216
216
|
selector: l
|
|
217
217
|
}
|
|
218
218
|
}];
|
|
219
|
-
}),
|
|
219
|
+
}), P = (e) => {
|
|
220
220
|
let t = e.custom_content?.annotations;
|
|
221
221
|
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null);
|
|
222
222
|
let n = e.custom_fields;
|
|
223
223
|
if (typeof n != "object" || !n) return [];
|
|
224
224
|
let r = n.annotations;
|
|
225
|
-
return !Array.isArray(r) || r.length === 0 ? [] :
|
|
226
|
-
},
|
|
225
|
+
return !Array.isArray(r) || r.length === 0 ? [] : N(r, e.custom_content?.attachments ?? []);
|
|
226
|
+
}, F = (e, t) => g(() => t ? [] : P(e), [t, e]), I = {
|
|
227
227
|
openGroupSourceUrl: null,
|
|
228
228
|
activeIndexByGroup: {}
|
|
229
|
-
},
|
|
230
|
-
let [e, t] = _(
|
|
229
|
+
}, L = () => {
|
|
230
|
+
let [e, t] = _(I), n = m((e) => {
|
|
231
231
|
t((t) => ({
|
|
232
232
|
...t,
|
|
233
233
|
openGroupSourceUrl: e
|
|
@@ -258,7 +258,7 @@ var D = {
|
|
|
258
258
|
i,
|
|
259
259
|
e
|
|
260
260
|
]);
|
|
261
|
-
},
|
|
261
|
+
}, R = /⟦C(\d+)⟧/g, z = (e, t) => {
|
|
262
262
|
let n = t.map((t, n) => {
|
|
263
263
|
let r = t.primaryAnnotation.target?.selector, i = typeof r == "object" && r && "type" in r && r.type === "text_character_range" ? r.end : e.length;
|
|
264
264
|
return {
|
|
@@ -268,9 +268,9 @@ var D = {
|
|
|
268
268
|
}).sort((e, t) => t.pos - e.pos), r = e;
|
|
269
269
|
for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
|
|
270
270
|
return r;
|
|
271
|
-
},
|
|
271
|
+
}, B = (e, t) => {
|
|
272
272
|
if (typeof e == "string") {
|
|
273
|
-
let n = e.split(
|
|
273
|
+
let n = e.split(R);
|
|
274
274
|
if (n.length === 1) return e;
|
|
275
275
|
let r = [];
|
|
276
276
|
return n.forEach((e, n) => {
|
|
@@ -278,20 +278,20 @@ var D = {
|
|
|
278
278
|
}), r;
|
|
279
279
|
}
|
|
280
280
|
return Array.isArray(e) ? e.flatMap((e) => {
|
|
281
|
-
let n =
|
|
281
|
+
let n = B(e, t);
|
|
282
282
|
return Array.isArray(n) ? n : [n];
|
|
283
283
|
}) : e;
|
|
284
|
-
},
|
|
284
|
+
}, V = (e, t, n, i = !1) => {
|
|
285
285
|
let { onPreview: a, onOpenInBrowser: o, buildLabels: s } = n;
|
|
286
286
|
return {
|
|
287
|
-
processedContent: g(() => t.length > 0 ?
|
|
287
|
+
processedContent: g(() => t.length > 0 ? z(e, t) : e, [e, t]),
|
|
288
288
|
markdownComponents: g(() => {
|
|
289
289
|
if (t.length === 0) return {};
|
|
290
290
|
let e = (e) => {
|
|
291
291
|
let n = t[e];
|
|
292
292
|
if (!n) return null;
|
|
293
293
|
let { cardLabels: r, markerLabels: i } = s(n);
|
|
294
|
-
return /* @__PURE__ */ v(
|
|
294
|
+
return /* @__PURE__ */ v(D, {
|
|
295
295
|
group: n,
|
|
296
296
|
onPreview: (e) => a(e, n),
|
|
297
297
|
onOpenInBrowser: o,
|
|
@@ -303,12 +303,12 @@ var D = {
|
|
|
303
303
|
p: ({ children: t, ...n }) => /* @__PURE__ */ v("p", {
|
|
304
304
|
...n,
|
|
305
305
|
className: r(i ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
|
|
306
|
-
children:
|
|
306
|
+
children: B(t, e)
|
|
307
307
|
}),
|
|
308
308
|
li: ({ children: t, ...n }) => /* @__PURE__ */ v("li", {
|
|
309
309
|
...n,
|
|
310
310
|
className: "mb-1.5 last:mb-0",
|
|
311
|
-
children:
|
|
311
|
+
children: B(t, e)
|
|
312
312
|
})
|
|
313
313
|
};
|
|
314
314
|
}, [
|
|
@@ -319,20 +319,20 @@ var D = {
|
|
|
319
319
|
i
|
|
320
320
|
])
|
|
321
321
|
};
|
|
322
|
-
},
|
|
322
|
+
}, H = (e) => {
|
|
323
323
|
try {
|
|
324
324
|
return decodeURIComponent(e);
|
|
325
325
|
} catch {
|
|
326
326
|
return e;
|
|
327
327
|
}
|
|
328
|
-
},
|
|
328
|
+
}, U = (e) => {
|
|
329
329
|
try {
|
|
330
330
|
let t = new URL(e);
|
|
331
|
-
return t.pathname.split("/").map((e) =>
|
|
331
|
+
return t.pathname.split("/").map((e) => H(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
332
332
|
} catch {
|
|
333
|
-
return e.split("/").map((e) =>
|
|
333
|
+
return e.split("/").map((e) => H(e)).filter(Boolean).at(-1) ?? e;
|
|
334
334
|
}
|
|
335
|
-
},
|
|
335
|
+
}, W = (e) => {
|
|
336
336
|
let t = /* @__PURE__ */ new Map();
|
|
337
337
|
for (let n of e) {
|
|
338
338
|
let e = n.body?.source?.attachment?.url;
|
|
@@ -340,20 +340,20 @@ var D = {
|
|
|
340
340
|
let r = t.get(e);
|
|
341
341
|
r ? r.annotations.push(n) : t.set(e, {
|
|
342
342
|
sourceUrl: e,
|
|
343
|
-
sourceName: n.body?.source?.attachment?.title ??
|
|
343
|
+
sourceName: n.body?.source?.attachment?.title ?? U(e),
|
|
344
344
|
annotations: [n],
|
|
345
345
|
primaryAnnotation: n
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
348
|
return Array.from(t.values());
|
|
349
|
-
},
|
|
350
|
-
let t =
|
|
349
|
+
}, G = (e) => e.url == null && e.reference_url != null, K = /^(.*\.pdf)(?:#page=(\d+))?$/i, q = (e) => {
|
|
350
|
+
let t = K.exec(e);
|
|
351
351
|
return t ? {
|
|
352
352
|
baseUrl: t[1],
|
|
353
353
|
page: t[2] == null ? null : Number(t[2])
|
|
354
354
|
} : null;
|
|
355
|
-
},
|
|
356
|
-
let n = t.reference_url, r =
|
|
355
|
+
}, J = (t) => W((t ?? []).filter(G).map((t) => {
|
|
356
|
+
let n = t.reference_url, r = q(n) != null;
|
|
357
357
|
return { body: {
|
|
358
358
|
quote: t.data,
|
|
359
359
|
source: {
|
|
@@ -367,4 +367,4 @@ var D = {
|
|
|
367
367
|
} };
|
|
368
368
|
}));
|
|
369
369
|
//#endregion
|
|
370
|
-
export { x as CitationCard, w as CitationCardProvider,
|
|
370
|
+
export { x as CitationCard, w as CitationCardProvider, D as CitationDropdown, S as CitationMarker, A as annotationHighlightId, k as annotationsToPdfHighlights, J as getReferenceAttachmentGroups, W as groupAnnotationsBySource, z as injectCitationSentinels, G as isReferenceOnlyAttachment, N as normalizeRawAnnotations, q as parsePdfPageReference, B as replaceSentinelsInChildren, P as resolveMessageAnnotations, F as useAnnotations, L as useCitationCard, T as useCitationCardContext, V as useCitationMarkdownComponents };
|
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.287",
|
|
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.287",
|
|
23
23
|
"@epam/ai-dial-ui-kit": "*",
|
|
24
24
|
"@epam/pdf-highlighter-kit": ">=0.0.14"
|
|
25
25
|
},
|