@epam/ai-dial-attachment-canvas 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ooxml-highlight-geometry.d.ts","sourceRoot":"","sources":["../../src/utils/ooxml-highlight-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AAErC,+FAA+F;AAC/F,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAEvE,qEAAqE;AACrE,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0FAA0F;AAC1F,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2DAA2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xPresentation } from '@silurus/ooxml/pptx';
3
+ import { XlsxViewer } from '@silurus/ooxml/xlsx';
4
+ import { OoxmlHighlight, OoxmlHighlightLocation } from '../models/attachment-canvas';
5
+ import { OoxmlHighlightRect } from './ooxml-highlight-geometry';
6
+ /**
7
+ * One rectangle to draw, tagged with the highlight it belongs to. Kept in
8
+ * this dynamically-loaded module (not `OoxmlContent.tsx`) alongside the
9
+ * factories that produce it, so importing the type costs nothing in the
10
+ * eager entry — see the bundle-size budget test in
11
+ * `tests/package-boundary/bundle-budgets.spec.ts`.
12
+ */
13
+ export interface TaggedHighlightRect extends OoxmlHighlightRect {
14
+ /** Id of the `OoxmlHighlight` this rectangle came from. */
15
+ highlightId: string;
16
+ }
17
+ /**
18
+ * Per-format glue between document coordinates and the overlay.
19
+ *
20
+ * Created alongside the viewer so both read the same parse, and discarded with
21
+ * it. `measure` returns rectangles in the overlay's coordinate space, which is
22
+ * the viewer container's own box.
23
+ */
24
+ export interface OoxmlHighlightSurface {
25
+ /** Rectangles for every highlight that currently resolves. */
26
+ measure(highlights: readonly OoxmlHighlight[]): Promise<TaggedHighlightRect[]>;
27
+ /** Brings one cited location into view, whether or not it resolves to a rectangle. */
28
+ navigate(location: OoxmlHighlightLocation): Promise<void>;
29
+ }
30
+ /** Creates the DOCX highlight surface over an already-loaded document. */
31
+ export declare const createDocxHighlightSurface: (container: HTMLElement, docxDocument: DocxDocument, viewer: {
32
+ getScale(): number;
33
+ scrollToPage(index: number): void;
34
+ }, isDisposed: () => boolean) => OoxmlHighlightSurface;
35
+ /** Creates the PPTX highlight surface over an already-loaded presentation. */
36
+ export declare const createPptxHighlightSurface: (container: HTMLElement, presentation: PptxPresentation, viewer: {
37
+ getScale(): number;
38
+ scrollToSlide(index: number): void;
39
+ }, isDisposed: () => boolean) => OoxmlHighlightSurface;
40
+ /** Creates the XLSX highlight surface over the self-loading viewer. */
41
+ export declare const createXlsxHighlightSurface: (container: HTMLElement, viewer: XlsxViewer, isDisposed: () => boolean) => OoxmlHighlightSurface;
42
+ //# sourceMappingURL=ooxml-highlight-surfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ooxml-highlight-surfaces.d.ts","sourceRoot":"","sources":["../../src/utils/ooxml-highlight-surfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAEV,cAAc,EACd,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAIL,KAAK,kBAAkB,EAQxB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,8DAA8D;IAC9D,OAAO,CACL,UAAU,EAAE,SAAS,cAAc,EAAE,GACpC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAClC,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAsDD,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,GACrC,WAAW,WAAW,EACtB,cAAc,YAAY,EAC1B,QAAQ;IAAE,QAAQ,IAAI,MAAM,CAAC;IAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACjE,YAAY,MAAM,OAAO,KACxB,qBA0HF,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,GACrC,WAAW,WAAW,EACtB,cAAc,gBAAgB,EAC9B,QAAQ;IAAE,QAAQ,IAAI,MAAM,CAAC;IAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAClE,YAAY,MAAM,OAAO,KACxB,qBA8DF,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,GACrC,WAAW,WAAW,EACtB,QAAQ,UAAU,EAClB,YAAY,MAAM,OAAO,KACxB,qBAuDD,CAAC"}
@@ -1,171 +0,0 @@
1
- import { MIMEType as e, ensureDownloadFilename as t, mergeClasses as n, triggerAnchorDownload as r, triggerBlobDownload as i } from "@epam/ai-dial-chat-shared";
2
- import { Button as a, Spinner as o } from "@epam/ai-dial-ui-kit";
3
- import { Component as s, Suspense as c } from "react";
4
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
- //#region src/types/attachment-canvas.ts
6
- var d = /* @__PURE__ */ function(e) {
7
- return e.PlainText = "plain_text", e.Image = "image", e.Audio = "audio", e.Markdown = "markdown", e.MarkdownTable = "markdown_table", e.Json = "json", e.Pdf = "pdf", e.Ooxml = "ooxml", e.Code = "code", e.Html = "html", e.Visualizer = "visualizer", e.McpApp = "mcp_app", e.Unsupported = "unsupported", e.Error = "error", e;
8
- }({}), f = /* @__PURE__ */ function(e) {
9
- return e.Docx = "docx", e.Xlsx = "xlsx", e.Pptx = "pptx", e.Csv = "csv", e;
10
- }({}), p = /* @__PURE__ */ function(e) {
11
- return e.LoadFailed = "load_failed", e.Forbidden = "forbidden", e;
12
- }({}), m = {
13
- [f.Docx]: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
14
- [f.Xlsx]: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
15
- [f.Pptx]: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
16
- [f.Csv]: e.CSV
17
- }, h = (e) => {
18
- switch (e.type) {
19
- case d.PlainText:
20
- case d.Markdown:
21
- case d.Json:
22
- case d.Image:
23
- case d.Audio:
24
- case d.Pdf:
25
- case d.Ooxml:
26
- case d.Code: return !0;
27
- case d.Html: return e.url != null;
28
- case d.MarkdownTable:
29
- case d.Visualizer:
30
- case d.McpApp: return !1;
31
- case d.Unsupported: return e.url != null;
32
- case d.Error: return e.errorType !== p.Forbidden && e.url != null;
33
- }
34
- }, g = async (e) => {
35
- let t = await fetch(e);
36
- if (!t.ok) throw Error(`HTTP ${t.status}`);
37
- return t.blob();
38
- }, _ = (t) => {
39
- switch (t.type) {
40
- case d.Image: return {
41
- url: t.url,
42
- mimeType: void 0
43
- };
44
- case d.Audio: return {
45
- url: t.url,
46
- mimeType: t.mimeType
47
- };
48
- case d.Pdf: return {
49
- url: t.url,
50
- mimeType: e.PDF
51
- };
52
- case d.Ooxml: return {
53
- url: t.url,
54
- mimeType: m[t.format]
55
- };
56
- case d.Html: return {
57
- url: t.url,
58
- mimeType: e.HTML
59
- };
60
- case d.Unsupported:
61
- case d.Error: return {
62
- url: t.url,
63
- mimeType: void 0
64
- };
65
- case d.PlainText:
66
- case d.Code: return {
67
- url: void 0,
68
- mimeType: e.Plain
69
- };
70
- case d.Markdown:
71
- case d.MarkdownTable: return {
72
- url: void 0,
73
- mimeType: e.Markdown
74
- };
75
- case d.Json: return {
76
- url: void 0,
77
- mimeType: e.JSON
78
- };
79
- default: return {
80
- url: void 0,
81
- mimeType: void 0
82
- };
83
- }
84
- }, v = (n, a) => {
85
- let { url: o, mimeType: s } = _(n), c = t(a ?? "attachment", o, s);
86
- switch (n.type) {
87
- case d.PlainText:
88
- if (n.text === "") return;
89
- i(new Blob([n.text], { type: e.Plain }), c);
90
- return;
91
- case d.Markdown:
92
- if (n.text === "") return;
93
- i(new Blob([n.text], { type: e.Markdown }), c);
94
- return;
95
- case d.Json:
96
- i(new Blob([JSON.stringify(n.value, null, 2)], { type: e.JSON }), c);
97
- return;
98
- case d.Image:
99
- case d.Audio:
100
- case d.Pdf:
101
- case d.Ooxml:
102
- r(n.url, c);
103
- return;
104
- case d.Code:
105
- if (n.text === "") return;
106
- i(new Blob([n.text], { type: e.Plain }), c);
107
- return;
108
- case d.Html:
109
- if (n.url == null) return;
110
- r(n.url, c);
111
- return;
112
- case d.MarkdownTable:
113
- case d.Visualizer:
114
- case d.McpApp: return;
115
- case d.Unsupported:
116
- if (n.url == null) return;
117
- r(n.url, c);
118
- return;
119
- case d.Error:
120
- if (!h(n) || n.url == null) return;
121
- r(n.url, c);
122
- return;
123
- }
124
- }, y = ({ loadingLabel: e, pendingContent: t }) => /* @__PURE__ */ u("div", {
125
- role: "status",
126
- "aria-live": "polite",
127
- className: "flex h-full items-center justify-center",
128
- children: [t ?? /* @__PURE__ */ l(o, {}), /* @__PURE__ */ l("span", {
129
- className: "sr-only",
130
- children: e
131
- })]
132
- }), b = ({ errorLabel: e, retryLabel: t, onRetry: r, errorContent: i }) => /* @__PURE__ */ u("div", {
133
- className: "flex h-full flex-col items-center justify-center gap-3 p-4",
134
- children: [i, /* @__PURE__ */ u("div", {
135
- role: "alert",
136
- className: "flex flex-col items-center gap-3 text-center",
137
- children: [/* @__PURE__ */ l("p", {
138
- className: n("dial-body-text", "text-secondary"),
139
- children: e
140
- }), /* @__PURE__ */ l(a, {
141
- label: t,
142
- "aria-label": t,
143
- onClick: r
144
- })]
145
- })]
146
- }), x = class extends s {
147
- state = { hasError: !1 };
148
- static getDerivedStateFromError() {
149
- return { hasError: !0 };
150
- }
151
- componentDidUpdate(e) {
152
- e.retryKey !== this.props.retryKey && this.state.hasError && this.setState({ hasError: !1 });
153
- }
154
- render() {
155
- let { children: e, onRetry: t, pendingContent: n, errorContent: r, labels: { loadingLabel: i = "Loading…", errorLabel: a = "Failed to load content", retryLabel: o = "Retry" } = {} } = this.props;
156
- return this.state.hasError ? /* @__PURE__ */ l(b, {
157
- errorLabel: a,
158
- retryLabel: o,
159
- onRetry: t,
160
- errorContent: r
161
- }) : /* @__PURE__ */ l(c, {
162
- fallback: /* @__PURE__ */ l(y, {
163
- loadingLabel: i,
164
- pendingContent: n
165
- }),
166
- children: e
167
- });
168
- }
169
- };
170
- //#endregion
171
- export { g as a, p as c, v as i, f as l, b as n, h as o, y as r, d as s, x as t };