@epam/ai-dial-quotations 1.1.0-dev.89 → 1.1.0-dev.91

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.
@@ -18,6 +18,21 @@ export interface CitationCardLabels {
18
18
  /** Label for the "Download" button. */
19
19
  download: string;
20
20
  }
21
+ /** Color overrides for `CitationCard`, applied as CSS custom properties with app theme fallbacks. */
22
+ export interface CitationCardColors {
23
+ /** Card border color. Fallback: `--stroke-primary`. */
24
+ cardBorder?: string;
25
+ /** Card background color. Fallback: `--bg-layer-raised`. */
26
+ cardBackground?: string;
27
+ /** Quoted excerpt text color. Fallback: `--text-secondary`. */
28
+ quoteText?: string;
29
+ /** Annotation title text color. Fallback: `--text-primary`. */
30
+ titleText?: string;
31
+ /** Pagination switcher text color. Fallback: `--text-secondary`. */
32
+ switcherText?: string;
33
+ /** Source name text color. Fallback: `--text-primary`. */
34
+ sourceNameText?: string;
35
+ }
21
36
  /** Typography (font utility class) overrides for `CitationCard`. */
22
37
  export interface CitationCardTypography {
23
38
  /** CSS class applied to the source name ellipsis. Defaults to `'dial-tiny-text'`. */
@@ -51,6 +66,8 @@ export interface CitationCardProps {
51
66
  labels: CitationCardLabels;
52
67
  /** Optional typography class overrides. */
53
68
  typography?: CitationCardTypography;
69
+ /** Optional color overrides. */
70
+ colors?: CitationCardColors;
54
71
  }
55
72
  /** Popup card displaying a citation's title, quoted excerpt, and navigation controls. */
56
73
  export declare const CitationCard: FC<CitationCardProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"CitationCard.d.ts","sourceRoot":"","sources":["../../../src/components/CitationCard/CitationCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAa5D,OAAO,EAAE,EAAE,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,+CAA+C;AAC/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CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,KAAK,EAAE,eAAe,CAAC;IACvB,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,2EAA2E;IAC3E,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wEAAwE;IACxE,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,4BAA4B;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,gCAAgC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAmI9C,CAAC;;AAEF,wBAAkC"}
package/index.css ADDED
@@ -0,0 +1,2 @@
1
+ ._card_18wh9_1{border-color:var(--cc-card-border,var(--stroke-primary,#6b7280));background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_18wh9_6{color:var(--cc-quote-text,var(--text-secondary,#6b7280))}._title_18wh9_10{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_18wh9_14{color:var(--cc-switcher-text,var(--text-secondary,#6b7280))}._sourceName_18wh9_18{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}
2
+ /*$vite$:1*/
package/index.js CHANGED
@@ -1,129 +1,142 @@
1
- import { MIMEType as e, MarkdownRenderer as t, mergeClasses as n } from "@epam/ai-dial-chat-shared";
2
- import { DialEllipsisTooltip as r, DialTooltip as i, ElementSize as a, GhostIconButton as o, NeutralButton as s, PrimaryButton as c } from "@epam/ai-dial-ui-kit";
3
- import { IconChevronLeft as l, IconChevronRight as u } from "@tabler/icons-react";
4
- import { createContext as d, memo as f, useCallback as p, useContext as m, useMemo as h, useState as g } from "react";
5
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
6
- //#region src/components/CitationCard/CitationCard.tsx
7
- var y = ({ group: i, activeIndex: s, onIndexChange: d, onPreview: f, onOpenInBrowser: p, headerIcon: m, labels: h, typography: g }) => {
8
- let y = i.annotations.length, b = i.annotations[s] ?? i.primaryAnnotation, x = y > 1, S = i.annotations.some((e) => e.body?.title), C = i.primaryAnnotation.body?.source?.attachment?.type, w = f == null || C === e.HTML || C === e.XHTML, T = g?.sourceNameClassName ?? "dial-tiny-text", E = g?.titleClassName ?? "dial-body-semi-text", D = g?.quoteClassName ?? "dial-small-text", O = g?.switcherClassName ?? "dial-tiny-text";
9
- return /* @__PURE__ */ v("div", {
1
+ import { MIMEType as e, MarkdownRenderer as t, buildCssVars as n, mergeClasses as r } from "@epam/ai-dial-chat-shared";
2
+ import { DialEllipsisTooltip as i, DialTooltip as a, ElementSize as o, GhostIconButton as s, NeutralButton as c, PrimaryButton as l } from "@epam/ai-dial-ui-kit";
3
+ import { IconChevronLeft as u, IconChevronRight as d } from "@tabler/icons-react";
4
+ import { createContext as f, memo as p, useCallback as m, useContext as h, useMemo as g, useState as _ } from "react";
5
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
6
+ var b = {
7
+ card: "_card_18wh9_1",
8
+ quote: "_quote_18wh9_6",
9
+ title: "_title_18wh9_10",
10
+ switcher: "_switcher_18wh9_14",
11
+ sourceName: "_sourceName_18wh9_18"
12
+ }, x = ({ group: a, activeIndex: c, onIndexChange: f, onPreview: p, onOpenInBrowser: m, headerIcon: h, labels: g, typography: _, colors: x }) => {
13
+ let S = a.annotations.length, C = a.annotations[c] ?? a.primaryAnnotation, w = S > 1, T = a.annotations.some((e) => e.body?.title), E = a.primaryAnnotation.body?.source?.attachment?.type, D = p == null || E === e.HTML || E === e.XHTML, O = _?.sourceNameClassName ?? "dial-tiny-text", k = _?.titleClassName ?? "dial-body-semi-text", A = _?.quoteClassName ?? "dial-small-text", j = _?.switcherClassName ?? "dial-tiny-text", M = n({
14
+ "--cc-card-border": x?.cardBorder,
15
+ "--cc-card-bg": x?.cardBackground,
16
+ "--cc-quote-text": x?.quoteText,
17
+ "--cc-title-text": x?.titleText,
18
+ "--cc-switcher-text": x?.switcherText,
19
+ "--cc-source-name-text": x?.sourceNameText
20
+ });
21
+ return /* @__PURE__ */ y("div", {
10
22
  role: "dialog",
11
23
  "aria-modal": "true",
12
- "aria-label": h.ariaLabel,
13
- className: "flex w-[400px] flex-col gap-3 rounded-lg border border-primary bg-layer-0 p-4 shadow-lg",
24
+ "aria-label": g.ariaLabel,
25
+ style: M,
26
+ className: r("flex w-[400px] flex-col gap-3 rounded-lg border p-4 shadow-lg", b.card),
14
27
  children: [
15
- /* @__PURE__ */ v("div", {
28
+ /* @__PURE__ */ y("div", {
16
29
  className: "flex items-center justify-between gap-2",
17
- children: [/* @__PURE__ */ v("div", {
30
+ children: [/* @__PURE__ */ y("div", {
18
31
  className: "flex min-w-0 items-center gap-1",
19
- children: [m, /* @__PURE__ */ _(r, {
20
- text: i.sourceName,
21
- className: n(T, "min-w-0 text-primary")
32
+ children: [h, /* @__PURE__ */ v(i, {
33
+ text: a.sourceName,
34
+ className: r(O, "min-w-0", b.sourceName)
22
35
  })]
23
- }), x && /* @__PURE__ */ v("div", {
36
+ }), w && /* @__PURE__ */ y("div", {
24
37
  className: "flex shrink-0 items-center gap-1",
25
38
  children: [
26
- /* @__PURE__ */ _(o, {
27
- icon: /* @__PURE__ */ _(l, {
39
+ /* @__PURE__ */ v(s, {
40
+ icon: /* @__PURE__ */ v(u, {
28
41
  size: 14,
29
42
  className: "rtl:scale-x-[-1]"
30
43
  }),
31
- size: a.Small,
32
- "aria-label": h.previousCitation,
33
- onClick: () => d((s - 1 + y) % y)
44
+ size: o.Small,
45
+ "aria-label": g.previousCitation,
46
+ onClick: () => f((c - 1 + S) % S)
34
47
  }),
35
- /* @__PURE__ */ _("span", {
36
- className: n(O, "text-secondary"),
37
- children: h.formatSwitcherText(s + 1, y)
48
+ /* @__PURE__ */ v("span", {
49
+ className: r(j, b.switcher),
50
+ children: g.formatSwitcherText(c + 1, S)
38
51
  }),
39
- /* @__PURE__ */ _(o, {
40
- icon: /* @__PURE__ */ _(u, {
52
+ /* @__PURE__ */ v(s, {
53
+ icon: /* @__PURE__ */ v(d, {
41
54
  size: 14,
42
55
  className: "rtl:scale-x-[-1]"
43
56
  }),
44
- size: a.Small,
45
- "aria-label": h.nextCitation,
46
- onClick: () => d((s + 1) % y)
57
+ size: o.Small,
58
+ "aria-label": g.nextCitation,
59
+ onClick: () => f((c + 1) % S)
47
60
  })
48
61
  ]
49
62
  })]
50
63
  }),
51
- (b.body?.title || b.body?.quote || x) && /* @__PURE__ */ v("div", {
64
+ (C.body?.title || C.body?.quote || w) && /* @__PURE__ */ y("div", {
52
65
  className: "flex flex-col gap-3",
53
- children: [(b.body?.title || x && S) && /* @__PURE__ */ _("p", {
54
- className: n(E, "text-primary", x && S && "min-h-[1lh]"),
55
- children: b.body?.title
56
- }), (b.body?.quote || x) && /* @__PURE__ */ _("div", {
57
- className: n(x && "min-h-[3lh]"),
58
- children: b.body?.quote && /* @__PURE__ */ _(t, {
59
- content: b.body.quote,
60
- classNames: { p: n(D, "line-clamp-6 text-secondary") }
66
+ children: [(C.body?.title || w && T) && /* @__PURE__ */ v("p", {
67
+ className: r(k, b.title, w && T && "min-h-[1lh]"),
68
+ children: C.body?.title
69
+ }), (C.body?.quote || w) && /* @__PURE__ */ v("div", {
70
+ className: r(w && "min-h-[3lh]"),
71
+ children: C.body?.quote && /* @__PURE__ */ v(t, {
72
+ content: C.body.quote,
73
+ classNames: { p: r(A, "line-clamp-6", b.quote) }
61
74
  })
62
75
  })]
63
76
  }),
64
- /* @__PURE__ */ v("div", {
77
+ /* @__PURE__ */ y("div", {
65
78
  className: "flex justify-start gap-2",
66
- children: [f && /* @__PURE__ */ _(c, {
67
- label: h.preview,
68
- size: a.Small,
69
- onClick: () => f(b)
70
- }), /* @__PURE__ */ _(c, {
71
- label: w ? h.openInBrowser : h.download,
72
- size: a.Small,
73
- onClick: () => p(b)
79
+ children: [p && /* @__PURE__ */ v(l, {
80
+ label: g.preview,
81
+ size: o.Small,
82
+ onClick: () => p(C)
83
+ }), /* @__PURE__ */ v(l, {
84
+ label: D ? g.openInBrowser : g.download,
85
+ size: o.Small,
86
+ onClick: () => m(C)
74
87
  })]
75
88
  })
76
89
  ]
77
90
  });
78
91
  };
79
- f(y);
92
+ p(x);
80
93
  //#endregion
81
94
  //#region src/components/CitationMarker/CitationMarker.tsx
82
- var b = ({ annotationCount: e, onOpen: t, icon: n, labels: r }) => {
83
- let i = /* @__PURE__ */ v("span", {
95
+ var S = ({ annotationCount: e, onOpen: t, icon: n, labels: r }) => {
96
+ let i = /* @__PURE__ */ y("span", {
84
97
  className: "flex items-center gap-1",
85
- children: [n, /* @__PURE__ */ _("span", {
98
+ children: [n, /* @__PURE__ */ v("span", {
86
99
  className: "dial-caption-text",
87
100
  children: e > 1 ? r.labelWithOverflow : r.label
88
101
  })]
89
102
  });
90
- return /* @__PURE__ */ _(s, {
91
- size: a.Small,
103
+ return /* @__PURE__ */ v(c, {
104
+ size: o.Small,
92
105
  label: i,
93
106
  "aria-label": r.ariaLabel,
94
107
  onClick: t
95
108
  });
96
109
  };
97
- f(b);
110
+ p(S);
98
111
  //#endregion
99
112
  //#region src/context/CitationCardContext.tsx
100
- var x = d(null), S = x.Provider, C = () => {
101
- let e = m(x);
113
+ var C = f(null), w = C.Provider, T = () => {
114
+ let e = h(C);
102
115
  if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
103
116
  return e;
104
- }, w = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: r, headerIcon: a, cardLabels: o, markerLabels: s, cardTypography: c }) => {
105
- let l = C(), u = l.isOpen(e.sourceUrl), d = l.getActiveIndex(e.sourceUrl);
106
- return /* @__PURE__ */ _(i, {
117
+ }, E = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: r, headerIcon: i, cardLabels: o, markerLabels: s, cardTypography: c }) => {
118
+ let l = T(), u = l.isOpen(e.sourceUrl), d = l.getActiveIndex(e.sourceUrl);
119
+ return /* @__PURE__ */ v(a, {
107
120
  open: u,
108
- onOpenChange: p((e) => {
121
+ onOpenChange: m((e) => {
109
122
  e || l.closePopup();
110
123
  }, [l]),
111
124
  placement: "bottom-end",
112
125
  triggerClassName: "ms-1 inline-flex align-middle",
113
126
  contentClassName: "!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none",
114
- tooltip: /* @__PURE__ */ _(y, {
127
+ tooltip: /* @__PURE__ */ v(x, {
115
128
  group: e,
116
129
  activeIndex: d,
117
130
  onIndexChange: (t) => l.setActiveIndex(e.sourceUrl, t),
118
- onPreview: h(() => t ? (e) => {
131
+ onPreview: g(() => t ? (e) => {
119
132
  t(e), l.closePopup();
120
133
  } : void 0, [t, l]),
121
134
  onOpenInBrowser: n,
122
- headerIcon: a,
135
+ headerIcon: i,
123
136
  labels: o,
124
137
  typography: c
125
138
  }),
126
- children: /* @__PURE__ */ _(b, {
139
+ children: /* @__PURE__ */ v(S, {
127
140
  sourceName: e.sourceName,
128
141
  annotationCount: e.annotations.length,
129
142
  onOpen: () => l.openPopup(e.sourceUrl),
@@ -132,16 +145,16 @@ var x = d(null), S = x.Provider, C = () => {
132
145
  })
133
146
  });
134
147
  };
135
- f(w);
148
+ p(E);
136
149
  //#endregion
137
150
  //#region src/utils/annotation.ts
138
- var T = {
151
+ var D = {
139
152
  backgroundColor: "transparent",
140
153
  borderColor: "#124ACE",
141
154
  borderWidth: "2px",
142
155
  opacity: .5,
143
156
  hoverOpacity: .5
144
- }, E = (e) => e.flatMap((e, t) => {
157
+ }, O = (e) => e.flatMap((e, t) => {
145
158
  let n = e.body?.selector;
146
159
  if (n == null) return [];
147
160
  let r = (Array.isArray(n) ? n : [n]).flatMap((e) => {
@@ -158,38 +171,38 @@ var T = {
158
171
  return r.length === 0 ? [] : [{
159
172
  id: String(e.index ?? t),
160
173
  bboxes: r,
161
- style: T
174
+ style: D
162
175
  }];
163
- }), D = (e, t) => String(e.index ?? t), O = (e) => typeof e == "number" ? e : null, k = (e) => {
176
+ }), k = (e, t) => String(e.index ?? t), A = (e) => typeof e == "number" ? e : null, j = (e) => {
164
177
  if (typeof e != "object" || !e) return null;
165
178
  let t = e;
166
179
  if (t.type !== "pdf_region") return null;
167
180
  let n = t.bbox;
168
181
  if (typeof n != "object" || !n) return null;
169
- let r = n, i = O(r.left), a = O(r.top), o = O(r.width), s = O(r.height);
182
+ let r = n, i = A(r.left), a = A(r.top), o = A(r.width), s = A(r.height);
170
183
  return i === null || a === null || o === null || s === null ? null : {
171
184
  type: "pdf_bbox",
172
- page: O(t.page) ?? 1,
185
+ page: A(t.page) ?? 1,
173
186
  x1: i,
174
187
  y1: a,
175
188
  x2: i + o,
176
189
  y2: a + s
177
190
  };
178
- }, A = (t, n) => t.flatMap((t) => {
191
+ }, M = (t, n) => t.flatMap((t) => {
179
192
  if (typeof t != "object" || !t) return [];
180
193
  let r = t, i = r.target;
181
194
  if (typeof i != "object" || !i) return [];
182
195
  let a = i, o = a.source;
183
196
  if (typeof o != "object" || !o) return [];
184
- let s = O(o.attachment_index);
197
+ let s = A(o.attachment_index);
185
198
  if (s === null) return [];
186
199
  let c = n.find((e) => e.index === s);
187
200
  if (c?.url == null) return [];
188
- let l = k(a.selector);
201
+ let l = j(a.selector);
189
202
  if (l === null) return [];
190
203
  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;
191
204
  return [{
192
- index: O(r.index) ?? void 0,
205
+ index: A(r.index) ?? void 0,
193
206
  body: {
194
207
  title: f,
195
208
  quote: p,
@@ -204,28 +217,28 @@ var T = {
204
217
  selector: l
205
218
  }
206
219
  }];
207
- }), j = (e) => {
220
+ }), N = (e) => {
208
221
  let t = e.custom_content?.annotations;
209
222
  if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null);
210
223
  let n = e.custom_fields;
211
224
  if (typeof n != "object" || !n) return [];
212
225
  let r = n.annotations;
213
- return !Array.isArray(r) || r.length === 0 ? [] : A(r, e.custom_content?.attachments ?? []);
214
- }, M = (e, t) => h(() => t ? [] : j(e), [t, e]), N = {
226
+ return !Array.isArray(r) || r.length === 0 ? [] : M(r, e.custom_content?.attachments ?? []);
227
+ }, P = (e, t) => g(() => t ? [] : N(e), [t, e]), F = {
215
228
  openGroupSourceUrl: null,
216
229
  activeIndexByGroup: {}
217
- }, P = () => {
218
- let [e, t] = g(N), n = p((e) => {
230
+ }, I = () => {
231
+ let [e, t] = _(F), n = m((e) => {
219
232
  t((t) => ({
220
233
  ...t,
221
234
  openGroupSourceUrl: e
222
235
  }));
223
- }, []), r = p(() => {
236
+ }, []), r = m(() => {
224
237
  t((e) => ({
225
238
  ...e,
226
239
  openGroupSourceUrl: null
227
240
  }));
228
- }, []), i = p((e, n) => {
241
+ }, []), i = m((e, n) => {
229
242
  t((t) => ({
230
243
  ...t,
231
244
  activeIndexByGroup: {
@@ -234,7 +247,7 @@ var T = {
234
247
  }
235
248
  }));
236
249
  }, []);
237
- return h(() => ({
250
+ return g(() => ({
238
251
  openPopup: n,
239
252
  closePopup: r,
240
253
  setActiveIndex: i,
@@ -246,20 +259,20 @@ var T = {
246
259
  i,
247
260
  e
248
261
  ]);
249
- }, F = (e) => {
262
+ }, L = (e) => {
250
263
  try {
251
264
  return decodeURIComponent(e);
252
265
  } catch {
253
266
  return e;
254
267
  }
255
- }, I = (e) => {
268
+ }, R = (e) => {
256
269
  try {
257
270
  let t = new URL(e);
258
- return t.pathname.split("/").map((e) => F(e)).filter(Boolean).at(-1) ?? t.hostname;
271
+ return t.pathname.split("/").map((e) => L(e)).filter(Boolean).at(-1) ?? t.hostname;
259
272
  } catch {
260
- return e.split("/").map((e) => F(e)).filter(Boolean).at(-1) ?? e;
273
+ return e.split("/").map((e) => L(e)).filter(Boolean).at(-1) ?? e;
261
274
  }
262
- }, L = (e) => {
275
+ }, z = (e) => {
263
276
  let t = /* @__PURE__ */ new Map();
264
277
  for (let n of e) {
265
278
  let e = n.body?.source?.attachment?.url;
@@ -267,13 +280,13 @@ var T = {
267
280
  let r = t.get(e);
268
281
  r ? r.annotations.push(n) : t.set(e, {
269
282
  sourceUrl: e,
270
- sourceName: n.body?.source?.attachment?.title ?? I(e),
283
+ sourceName: n.body?.source?.attachment?.title ?? R(e),
271
284
  annotations: [n],
272
285
  primaryAnnotation: n
273
286
  });
274
287
  }
275
288
  return Array.from(t.values());
276
- }, R = /⟦C(\d+)⟧/g, z = (e, t) => {
289
+ }, B = /⟦C(\d+)⟧/g, V = (e, t) => {
277
290
  let n = t.map((t, n) => {
278
291
  let r = t.primaryAnnotation.target?.selector, i = typeof r == "object" && r && "type" in r && r.type === "text_character_range" ? r.end : e.length;
279
292
  return {
@@ -283,9 +296,9 @@ var T = {
283
296
  }).sort((e, t) => t.pos - e.pos), r = e;
284
297
  for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
285
298
  return r;
286
- }, B = (e, t) => {
299
+ }, H = (e, t) => {
287
300
  if (typeof e == "string") {
288
- let n = e.split(R);
301
+ let n = e.split(B);
289
302
  if (n.length === 1) return e;
290
303
  let r = [];
291
304
  return n.forEach((e, n) => {
@@ -293,17 +306,17 @@ var T = {
293
306
  }), r;
294
307
  }
295
308
  return Array.isArray(e) ? e.flatMap((e) => {
296
- let n = B(e, t);
309
+ let n = H(e, t);
297
310
  return Array.isArray(n) ? n : [n];
298
311
  }) : e;
299
- }, V = (e) => e.url == null && e.reference_url != null, H = /^(.*\.pdf)(?:#page=(\d+))?$/i, U = (e) => {
300
- let t = H.exec(e);
312
+ }, U = (e) => e.url == null && e.reference_url != null, W = /^(.*\.pdf)(?:#page=(\d+))?$/i, G = (e) => {
313
+ let t = W.exec(e);
301
314
  return t ? {
302
315
  baseUrl: t[1],
303
316
  page: t[2] == null ? null : Number(t[2])
304
317
  } : null;
305
- }, W = (t) => L((t ?? []).filter(V).map((t) => {
306
- let n = t.reference_url, r = U(n) != null;
318
+ }, K = (t) => z((t ?? []).filter(U).map((t) => {
319
+ let n = t.reference_url, r = G(n) != null;
307
320
  return { body: {
308
321
  quote: t.data,
309
322
  source: {
@@ -317,4 +330,4 @@ var T = {
317
330
  } };
318
331
  }));
319
332
  //#endregion
320
- export { y as CitationCard, S as CitationCardProvider, w as CitationDropdown, b as CitationMarker, D as annotationHighlightId, E as annotationsToPdfHighlights, W as getReferenceAttachmentGroups, L as groupAnnotationsBySource, z as injectCitationSentinels, V as isReferenceOnlyAttachment, A as normalizeRawAnnotations, U as parsePdfPageReference, B as replaceSentinelsInChildren, j as resolveMessageAnnotations, M as useAnnotations, P as useCitationCard, C as useCitationCardContext };
333
+ export { x as CitationCard, w as CitationCardProvider, E as CitationDropdown, S as CitationMarker, k as annotationHighlightId, O as annotationsToPdfHighlights, K as getReferenceAttachmentGroups, z as groupAnnotationsBySource, V as injectCitationSentinels, U as isReferenceOnlyAttachment, M as normalizeRawAnnotations, G as parsePdfPageReference, H as replaceSentinelsInChildren, N as resolveMessageAnnotations, P as useAnnotations, I as useCitationCard, T as useCitationCardContext };
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.89",
4
+ "version": "1.1.0-dev.91",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -18,7 +18,7 @@
18
18
  "peerDependencies": {
19
19
  "react": "^19.0.0",
20
20
  "@tabler/icons-react": "^3.0.0",
21
- "@epam/ai-dial-chat-shared": "1.1.0-dev.89",
21
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.91",
22
22
  "@epam/ai-dial-ui-kit": "^0.13.0-dev.26",
23
23
  "@epam/pdf-highlighter-kit": ">=0.0.14"
24
24
  },