@epam/ai-dial-quotations 1.1.0-dev.298 → 1.1.0-dev.300

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.
@@ -39,6 +39,8 @@ export interface CitationCardTypography {
39
39
  titleClassName?: string;
40
40
  /** CSS class applied to the quoted excerpt. Defaults to `'dial-small-text'`. */
41
41
  quoteClassName?: string;
42
+ /** CSS class applied to bold spans inside the quoted excerpt. Defaults to `'dial-small-semi-text'` — the semibold step matching the default `quoteClassName`. */
43
+ quoteStrongClassName?: string;
42
44
  /** CSS class applied to the pagination switcher text. Defaults to `'dial-tiny-text'`. */
43
45
  switcherClassName?: string;
44
46
  }
@@ -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;AAc5D,OAAO,EAAE,EAAE,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAG/E,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,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"}
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;AAe5D,OAAO,EAAE,EAAE,EAAQ,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAG/E,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iKAAiK;IACjK,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,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,CAqJ9C,CAAC;;AAEF,wBAAkC"}
package/index.js CHANGED
@@ -1,159 +1,166 @@
1
1
  import { MIMEType as e, MarkdownRenderer as t, buildCssVars as n, mergeClasses as r } from "@epam/ai-dial-chat-shared";
2
- import { ElementSize as i, EllipsisTooltip as a, GhostIconButton as o, NeutralButton as s, PrimaryButton as c, Tooltip 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 = {
2
+ import { DIAL_KIT_ICON_STROKE as i, ElementSize as a, EllipsisTooltip as o, GhostIconButton as s, NeutralButton as c, PrimaryButton as l, Tooltip as u } from "@epam/ai-dial-ui-kit";
3
+ import { IconChevronLeft as d, IconChevronRight as f } from "@tabler/icons-react";
4
+ import { createContext as p, memo as m, useCallback as h, useContext as g, useMemo as _, useState as v } from "react";
5
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
6
+ var x = {
7
7
  card: "_card_1kph1_1",
8
8
  quote: "_quote_1kph1_5",
9
9
  title: "_title_1kph1_9",
10
10
  switcher: "_switcher_1kph1_13",
11
11
  sourceName: "_sourceName_1kph1_17"
12
- }, x = ({ group: s, activeIndex: l, onIndexChange: f, onPreview: p, onOpenInBrowser: m, headerIcon: h, labels: g, typography: _, colors: x }) => {
13
- let S = s.annotations.length, C = s.annotations[l] ?? s.primaryAnnotation, w = S > 1, T = s.annotations.some((e) => e.body?.title), E = s.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-bg": x?.cardBackground,
15
- "--cc-quote-text": x?.quoteText,
16
- "--cc-title-text": x?.titleText,
17
- "--cc-switcher-text": x?.switcherText,
18
- "--cc-source-name-text": x?.sourceNameText
12
+ }, S = ({ group: c, activeIndex: u, onIndexChange: p, onPreview: m, onOpenInBrowser: h, headerIcon: g, labels: _, typography: v, colors: S }) => {
13
+ let C = c.annotations.length, w = c.annotations[u] ?? c.primaryAnnotation, T = C > 1, E = c.primaryAnnotation.body?.source?.attachment?.type, D = m == null || E === e.HTML || E === e.XHTML, O = v?.sourceNameClassName ?? "dial-tiny-text", k = v?.titleClassName ?? "dial-body-semi-text", A = v?.quoteClassName ?? "dial-small-text", j = v?.quoteStrongClassName ?? "dial-small-semi-text", M = v?.switcherClassName ?? "dial-tiny-text", N = n({
14
+ "--cc-card-bg": S?.cardBackground,
15
+ "--cc-quote-text": S?.quoteText,
16
+ "--cc-title-text": S?.titleText,
17
+ "--cc-switcher-text": S?.switcherText,
18
+ "--cc-source-name-text": S?.sourceNameText
19
19
  });
20
- return /* @__PURE__ */ y("div", {
20
+ return /* @__PURE__ */ b("div", {
21
21
  role: "dialog",
22
22
  "aria-modal": "true",
23
- "aria-label": g.ariaLabel,
24
- style: M,
25
- className: r("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", b.card),
23
+ "aria-label": _.ariaLabel,
24
+ style: N,
25
+ className: r("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", x.card),
26
26
  children: [
27
- /* @__PURE__ */ y("div", {
27
+ /* @__PURE__ */ b("div", {
28
28
  className: "flex items-center justify-between gap-2",
29
- children: [/* @__PURE__ */ y("div", {
29
+ children: [/* @__PURE__ */ b("div", {
30
30
  className: "flex min-w-0 items-center gap-1",
31
- children: [h, /* @__PURE__ */ v(a, {
32
- text: s.sourceName,
33
- className: r(O, "min-w-0", b.sourceName)
31
+ children: [g, /* @__PURE__ */ y(o, {
32
+ text: c.sourceName,
33
+ className: r(O, "min-w-0", x.sourceName)
34
34
  })]
35
- }), w && /* @__PURE__ */ y("div", {
35
+ }), T && /* @__PURE__ */ b("div", {
36
36
  className: "flex shrink-0 items-center gap-1",
37
37
  children: [
38
- /* @__PURE__ */ v(o, {
39
- icon: /* @__PURE__ */ v(u, {
38
+ /* @__PURE__ */ y(s, {
39
+ icon: /* @__PURE__ */ y(d, {
40
40
  size: 14,
41
- className: "rtl:scale-x-[-1]"
41
+ className: "rtl:scale-x-[-1]",
42
+ stroke: i
42
43
  }),
43
- size: i.Small,
44
- "aria-label": g.previousCitation,
45
- onClick: () => f((l - 1 + S) % S)
44
+ size: a.Small,
45
+ "aria-label": _.previousCitation,
46
+ onClick: () => p((u - 1 + C) % C)
46
47
  }),
47
- /* @__PURE__ */ v("span", {
48
- className: r(j, b.switcher),
49
- children: g.formatSwitcherText(l + 1, S)
48
+ /* @__PURE__ */ y("span", {
49
+ className: r(M, x.switcher),
50
+ children: _.formatSwitcherText(u + 1, C)
50
51
  }),
51
- /* @__PURE__ */ v(o, {
52
- icon: /* @__PURE__ */ v(d, {
52
+ /* @__PURE__ */ y(s, {
53
+ icon: /* @__PURE__ */ y(f, {
53
54
  size: 14,
54
- className: "rtl:scale-x-[-1]"
55
+ className: "rtl:scale-x-[-1]",
56
+ stroke: i
55
57
  }),
56
- size: i.Small,
57
- "aria-label": g.nextCitation,
58
- onClick: () => f((l + 1) % S)
58
+ size: a.Small,
59
+ "aria-label": _.nextCitation,
60
+ onClick: () => p((u + 1) % C)
59
61
  })
60
62
  ]
61
63
  })]
62
64
  }),
63
- (C.body?.title || C.body?.quote || w) && /* @__PURE__ */ y("div", {
65
+ (w.body?.title || w.body?.quote || T) && /* @__PURE__ */ b("div", {
64
66
  className: "flex flex-col gap-3",
65
- children: [(C.body?.title || w && T) && /* @__PURE__ */ v("p", {
66
- className: r(k, b.title, "break-words", w && T && "min-h-[1lh]"),
67
- children: C.body?.title
68
- }), (C.body?.quote || w) && /* @__PURE__ */ v("div", {
69
- className: r(w && "min-h-[3lh]"),
70
- children: C.body?.quote && /* @__PURE__ */ v(t, {
71
- content: C.body.quote,
72
- classNames: { p: r(A, "line-clamp-6", b.quote) }
67
+ children: [w.body?.title && /* @__PURE__ */ y("p", {
68
+ className: r(k, x.title, "break-words"),
69
+ children: w.body.title
70
+ }), (w.body?.quote || T) && /* @__PURE__ */ y("div", {
71
+ className: r(A, x.quote, "line-clamp-6 break-words", T && "min-h-[3lh]"),
72
+ children: w.body?.quote && /* @__PURE__ */ y(t, {
73
+ content: w.body.quote,
74
+ classNames: {
75
+ p: r(A, x.quote),
76
+ ul: r(A, "ps-3"),
77
+ ol: r(A, "ps-3"),
78
+ strong: j
79
+ }
73
80
  })
74
81
  })]
75
82
  }),
76
- /* @__PURE__ */ y("div", {
83
+ /* @__PURE__ */ b("div", {
77
84
  className: "flex justify-start gap-2",
78
- children: [p && /* @__PURE__ */ v(c, {
79
- label: g.preview,
80
- size: i.Small,
81
- onClick: () => p(C)
82
- }), /* @__PURE__ */ v(c, {
83
- label: D ? g.openInBrowser : g.download,
84
- size: i.Small,
85
- onClick: () => m(C)
85
+ children: [m && /* @__PURE__ */ y(l, {
86
+ label: _.preview,
87
+ size: a.Small,
88
+ onClick: () => m(w)
89
+ }), /* @__PURE__ */ y(l, {
90
+ label: D ? _.openInBrowser : _.download,
91
+ size: a.Small,
92
+ onClick: () => h(w)
86
93
  })]
87
94
  })
88
95
  ]
89
96
  });
90
97
  };
91
- p(x);
98
+ m(S);
92
99
  //#endregion
93
100
  //#region src/components/CitationMarker/CitationMarker.tsx
94
- var S = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => {
95
- let o = /* @__PURE__ */ y("span", {
101
+ var C = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: i = "dial-caption-text" }) => {
102
+ let o = /* @__PURE__ */ b("span", {
96
103
  className: "flex items-center gap-1",
97
- children: [n, /* @__PURE__ */ v("span", {
98
- className: a,
104
+ children: [n, /* @__PURE__ */ y("span", {
105
+ className: i,
99
106
  children: e > 1 ? r.labelWithOverflow : r.label
100
107
  })]
101
108
  });
102
- return /* @__PURE__ */ v(s, {
103
- size: i.Small,
109
+ return /* @__PURE__ */ y(c, {
110
+ size: a.Small,
104
111
  label: o,
105
112
  "aria-label": r.ariaLabel,
106
113
  onClick: t
107
114
  });
108
115
  };
109
- p(S);
116
+ m(C);
110
117
  //#endregion
111
118
  //#region src/context/CitationCardContext.tsx
112
- var C = f(null), w = C.Provider, T = () => {
113
- let e = h(C);
119
+ var w = p(null), T = w.Provider, E = () => {
120
+ let e = g(w);
114
121
  if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
115
122
  return e;
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) => {
123
+ }, D = { content: "_content_xzs0h_1" }, O = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: i, headerIcon: a, cardLabels: o, markerLabels: s, cardTypography: c, markerLabelClassName: l }) => {
124
+ let d = E(), f = d.isOpen(e.sourceUrl), p = d.getActiveIndex(e.sourceUrl), m = h((e) => {
118
125
  e || d.closePopup();
119
- }, [d]), _ = g(() => t ? (e) => {
126
+ }, [d]), g = _(() => t ? (e) => {
120
127
  t(e), d.closePopup();
121
128
  } : void 0, [t, d]);
122
- return /* @__PURE__ */ v(l, {
129
+ return /* @__PURE__ */ y(u, {
123
130
  open: f,
124
- onOpenChange: h,
131
+ onOpenChange: m,
125
132
  triggerClassName: "ms-1 inline-flex align-middle",
126
- contentClassName: r("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", E.content),
127
- tooltip: /* @__PURE__ */ v(x, {
133
+ contentClassName: r("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", D.content),
134
+ tooltip: /* @__PURE__ */ y(S, {
128
135
  group: e,
129
136
  activeIndex: p,
130
137
  onIndexChange: (t) => d.setActiveIndex(e.sourceUrl, t),
131
- onPreview: _,
138
+ onPreview: g,
132
139
  onOpenInBrowser: n,
133
140
  headerIcon: a,
134
141
  labels: o,
135
142
  typography: c
136
143
  }),
137
- children: /* @__PURE__ */ v(S, {
144
+ children: /* @__PURE__ */ y(C, {
138
145
  sourceName: e.sourceName,
139
146
  annotationCount: e.annotations.length,
140
147
  onOpen: () => d.openPopup(e.sourceUrl),
141
148
  icon: i,
142
149
  labels: s,
143
- labelClassName: u
150
+ labelClassName: l
144
151
  })
145
152
  });
146
153
  };
147
- p(D);
154
+ m(O);
148
155
  //#endregion
149
156
  //#region src/utils/annotation.ts
150
- var O = {
157
+ var k = {
151
158
  backgroundColor: "transparent",
152
159
  borderColor: "var(--stroke-accent, #1D4ED8)",
153
160
  borderWidth: "2px",
154
161
  opacity: .5,
155
162
  hoverOpacity: .5
156
- }, k = (e) => e.flatMap((e, t) => {
163
+ }, A = (e) => e.flatMap((e, t) => {
157
164
  let n = e.body?.selector;
158
165
  if (n == null) return [];
159
166
  let r = (Array.isArray(n) ? n : [n]).flatMap((e) => {
@@ -170,38 +177,38 @@ var O = {
170
177
  return r.length === 0 ? [] : [{
171
178
  id: String(e.index ?? t),
172
179
  bboxes: r,
173
- style: O
180
+ style: k
174
181
  }];
175
- }), A = (e, t) => String(e.index ?? t), j = (e) => typeof e == "number" ? e : null, M = (e) => {
182
+ }), j = (e, t) => String(e.index ?? t), M = (e) => typeof e == "number" ? e : null, N = (e) => {
176
183
  if (typeof e != "object" || !e) return null;
177
184
  let t = e;
178
185
  if (t.type !== "pdf_region") return null;
179
186
  let n = t.bbox;
180
187
  if (typeof n != "object" || !n) return null;
181
- let r = n, i = j(r.left), a = j(r.top), o = j(r.width), s = j(r.height);
188
+ let r = n, i = M(r.left), a = M(r.top), o = M(r.width), s = M(r.height);
182
189
  return i === null || a === null || o === null || s === null ? null : {
183
190
  type: "pdf_bbox",
184
- page: j(t.page) ?? 1,
191
+ page: M(t.page) ?? 1,
185
192
  x1: i,
186
193
  y1: a,
187
194
  x2: i + o,
188
195
  y2: a + s
189
196
  };
190
- }, N = (t, n) => t.flatMap((t) => {
197
+ }, P = (t, n) => t.flatMap((t) => {
191
198
  if (typeof t != "object" || !t) return [];
192
199
  let r = t, i = r.target;
193
200
  if (typeof i != "object" || !i) return [];
194
201
  let a = i, o = a.source;
195
202
  if (typeof o != "object" || !o) return [];
196
- let s = j(o.attachment_index);
203
+ let s = M(o.attachment_index);
197
204
  if (s === null) return [];
198
205
  let c = n.find((e) => e.index === s);
199
206
  if (c?.url == null) return [];
200
- let l = M(a.selector);
207
+ let l = N(a.selector);
201
208
  if (l === null) return [];
202
209
  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
210
  return [{
204
- index: j(r.index) ?? void 0,
211
+ index: M(r.index) ?? void 0,
205
212
  body: {
206
213
  title: f,
207
214
  quote: p,
@@ -216,28 +223,28 @@ var O = {
216
223
  selector: l
217
224
  }
218
225
  }];
219
- }), P = (e) => {
226
+ }), F = (e) => {
220
227
  let t = e.custom_content?.annotations;
221
228
  if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null);
222
229
  let n = e.custom_fields;
223
230
  if (typeof n != "object" || !n) return [];
224
231
  let r = n.annotations;
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 = {
232
+ return !Array.isArray(r) || r.length === 0 ? [] : P(r, e.custom_content?.attachments ?? []);
233
+ }, I = (e, t) => _(() => t ? [] : F(e), [t, e]), L = {
227
234
  openGroupSourceUrl: null,
228
235
  activeIndexByGroup: {}
229
- }, L = () => {
230
- let [e, t] = _(I), n = m((e) => {
236
+ }, R = () => {
237
+ let [e, t] = v(L), n = h((e) => {
231
238
  t((t) => ({
232
239
  ...t,
233
240
  openGroupSourceUrl: e
234
241
  }));
235
- }, []), r = m(() => {
242
+ }, []), r = h(() => {
236
243
  t((e) => ({
237
244
  ...e,
238
245
  openGroupSourceUrl: null
239
246
  }));
240
- }, []), i = m((e, n) => {
247
+ }, []), i = h((e, n) => {
241
248
  t((t) => ({
242
249
  ...t,
243
250
  activeIndexByGroup: {
@@ -246,7 +253,7 @@ var O = {
246
253
  }
247
254
  }));
248
255
  }, []);
249
- return g(() => ({
256
+ return _(() => ({
250
257
  openPopup: n,
251
258
  closePopup: r,
252
259
  setActiveIndex: i,
@@ -258,7 +265,7 @@ var O = {
258
265
  i,
259
266
  e
260
267
  ]);
261
- }, R = /⟦C(\d+)⟧/g, z = (e, t) => {
268
+ }, z = /⟦C(\d+)⟧/g, B = (e, t) => {
262
269
  let n = t.map((t, n) => {
263
270
  let r = t.primaryAnnotation.target?.selector, i = typeof r == "object" && r && "type" in r && r.type === "text_character_range" ? r.end : e.length;
264
271
  return {
@@ -268,9 +275,9 @@ var O = {
268
275
  }).sort((e, t) => t.pos - e.pos), r = e;
269
276
  for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
270
277
  return r;
271
- }, B = (e, t) => {
278
+ }, V = (e, t) => {
272
279
  if (typeof e == "string") {
273
- let n = e.split(R);
280
+ let n = e.split(z);
274
281
  if (n.length === 1) return e;
275
282
  let r = [];
276
283
  return n.forEach((e, n) => {
@@ -278,20 +285,20 @@ var O = {
278
285
  }), r;
279
286
  }
280
287
  return Array.isArray(e) ? e.flatMap((e) => {
281
- let n = B(e, t);
288
+ let n = V(e, t);
282
289
  return Array.isArray(n) ? n : [n];
283
290
  }) : e;
284
- }, V = (e, t, n, i = !1) => {
291
+ }, H = (e, t, n, i = !1) => {
285
292
  let { onPreview: a, onOpenInBrowser: o, buildLabels: s } = n;
286
293
  return {
287
- processedContent: g(() => t.length > 0 ? z(e, t) : e, [e, t]),
288
- markdownComponents: g(() => {
294
+ processedContent: _(() => t.length > 0 ? B(e, t) : e, [e, t]),
295
+ markdownComponents: _(() => {
289
296
  if (t.length === 0) return {};
290
297
  let e = (e) => {
291
298
  let n = t[e];
292
299
  if (!n) return null;
293
300
  let { cardLabels: r, markerLabels: i } = s(n);
294
- return /* @__PURE__ */ v(D, {
301
+ return /* @__PURE__ */ y(O, {
295
302
  group: n,
296
303
  onPreview: (e) => a(e, n),
297
304
  onOpenInBrowser: o,
@@ -300,15 +307,15 @@ var O = {
300
307
  }, `citation-${n.sourceUrl}`);
301
308
  };
302
309
  return {
303
- p: ({ children: t, ...n }) => /* @__PURE__ */ v("p", {
310
+ p: ({ children: t, ...n }) => /* @__PURE__ */ y("p", {
304
311
  ...n,
305
312
  className: r(i ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
306
- children: B(t, e)
313
+ children: V(t, e)
307
314
  }),
308
- li: ({ children: t, ...n }) => /* @__PURE__ */ v("li", {
315
+ li: ({ children: t, ...n }) => /* @__PURE__ */ y("li", {
309
316
  ...n,
310
317
  className: "mb-1.5 last:mb-0",
311
- children: B(t, e)
318
+ children: V(t, e)
312
319
  })
313
320
  };
314
321
  }, [
@@ -319,20 +326,20 @@ var O = {
319
326
  i
320
327
  ])
321
328
  };
322
- }, H = (e) => {
329
+ }, U = (e) => {
323
330
  try {
324
331
  return decodeURIComponent(e);
325
332
  } catch {
326
333
  return e;
327
334
  }
328
- }, U = (e) => {
335
+ }, W = (e) => {
329
336
  try {
330
337
  let t = new URL(e);
331
- return t.pathname.split("/").map((e) => H(e)).filter(Boolean).at(-1) ?? t.hostname;
338
+ return t.pathname.split("/").map((e) => U(e)).filter(Boolean).at(-1) ?? t.hostname;
332
339
  } catch {
333
- return e.split("/").map((e) => H(e)).filter(Boolean).at(-1) ?? e;
340
+ return e.split("/").map((e) => U(e)).filter(Boolean).at(-1) ?? e;
334
341
  }
335
- }, W = (e) => {
342
+ }, G = (e) => {
336
343
  let t = /* @__PURE__ */ new Map();
337
344
  for (let n of e) {
338
345
  let e = n.body?.source?.attachment?.url;
@@ -340,20 +347,20 @@ var O = {
340
347
  let r = t.get(e);
341
348
  r ? r.annotations.push(n) : t.set(e, {
342
349
  sourceUrl: e,
343
- sourceName: n.body?.source?.attachment?.title ?? U(e),
350
+ sourceName: n.body?.source?.attachment?.title ?? W(e),
344
351
  annotations: [n],
345
352
  primaryAnnotation: n
346
353
  });
347
354
  }
348
355
  return Array.from(t.values());
349
- }, G = (e) => e.url == null && e.reference_url != null, K = /^(.*\.pdf)(?:#page=(\d+))?$/i, q = (e) => {
350
- let t = K.exec(e);
356
+ }, K = (e) => e.url == null && e.reference_url != null, q = /^(.*\.pdf)(?:#page=(\d+))?$/i, J = (e) => {
357
+ let t = q.exec(e);
351
358
  return t ? {
352
359
  baseUrl: t[1],
353
360
  page: t[2] == null ? null : Number(t[2])
354
361
  } : null;
355
- }, J = (t) => W((t ?? []).filter(G).map((t) => {
356
- let n = t.reference_url, r = q(n) != null;
362
+ }, Y = (t) => G((t ?? []).filter(K).map((t) => {
363
+ let n = t.reference_url, r = J(n) != null;
357
364
  return { body: {
358
365
  quote: t.data,
359
366
  source: {
@@ -367,4 +374,4 @@ var O = {
367
374
  } };
368
375
  }));
369
376
  //#endregion
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 };
377
+ export { S as CitationCard, T as CitationCardProvider, O as CitationDropdown, C as CitationMarker, j as annotationHighlightId, A as annotationsToPdfHighlights, Y as getReferenceAttachmentGroups, G as groupAnnotationsBySource, B as injectCitationSentinels, K as isReferenceOnlyAttachment, P as normalizeRawAnnotations, J as parsePdfPageReference, V as replaceSentinelsInChildren, F as resolveMessageAnnotations, I as useAnnotations, R as useCitationCard, E as useCitationCardContext, H 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.298",
4
+ "version": "1.1.0-dev.300",
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.298",
22
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.300",
23
23
  "@epam/ai-dial-ui-kit": "*",
24
24
  "@epam/pdf-highlighter-kit": ">=0.0.14"
25
25
  },