@silurus/ooxml 0.81.0 → 0.82.1

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.
Files changed (61) hide show
  1. package/README.md +4 -8
  2. package/dist/assets/render-worker-Cy-QsDge.js +10 -0
  3. package/dist/assets/{render-worker-DtU8oQZ7.js → render-worker-Dw_wQRIh.js} +1 -1
  4. package/dist/assets/{render-worker-C2ACcLes.js → render-worker-aHayzR7v.js} +4 -4
  5. package/dist/{canvas-viewer-mechanics-CqxKRGCp.js → canvas-viewer-mechanics-CS_qbr6T.js} +1 -1
  6. package/dist/chart-ex.mjs +4 -4
  7. package/dist/comment-occurrence-C34fWs_F.js +6 -0
  8. package/dist/comment-ui-runtime-C1RV_3iu.js +112 -0
  9. package/dist/comment-ui-runtime-DTGN3Vyy.js +2 -0
  10. package/dist/comment-ui-runtime-DgCZpPR0.js +171 -0
  11. package/dist/comments-Cf9W7r3M.js +241 -0
  12. package/dist/{document-pull-client-Ux4a_ax8.js → document-pull-client-B1WOjA0z.js} +2206 -2193
  13. package/dist/{docx-SEyQ4gS-.js → docx-HoZXZUPA.js} +674 -249
  14. package/dist/docx.mjs +6 -5
  15. package/dist/docx_parser_bg.wasm +0 -0
  16. package/dist/dom-interaction-boundary-C8F6HO5x.js +119 -0
  17. package/dist/highlight-rect-MaCt0om0.js +13 -0
  18. package/dist/index.mjs +3 -3
  19. package/dist/{line-distribute-BBGvvwLt.js → line-distribute-iXsUCIH-.js} +2 -2
  20. package/dist/{line-metrics-Baz31mML.js → line-metrics-B3syvDn2.js} +52 -52
  21. package/dist/math.mjs +2 -2
  22. package/dist/node.mjs +10 -10
  23. package/dist/{plot-area-frame-Dg1VIpUU.js → plot-area-frame-DHV02PJU.js} +591 -590
  24. package/dist/{pptx-5lQrMvMR.js → pptx-DEUP4Yq5.js} +537 -243
  25. package/dist/pptx.mjs +6 -6
  26. package/dist/pptx_parser_bg.wasm +0 -0
  27. package/dist/read-only-comment-decoration-DcFevX_Q.js +96 -0
  28. package/dist/read-only-comment-margin-DrUX-YrP.js +189 -0
  29. package/dist/region-map.mjs +2 -2
  30. package/dist/{render-DEHjijQD.js → render-BC8p7vZQ.js} +1 -1
  31. package/dist/{render-worker-host-B1nbV_k7.js → render-worker-host-BNnXCtAu.js} +1 -1
  32. package/dist/{render-worker-host-Bze5M6k5.js → render-worker-host-CmPBviYJ.js} +1 -1
  33. package/dist/{render-worker-host-Dg_74V64.js → render-worker-host-DhnkTyjj.js} +1 -1
  34. package/dist/{renderer-DuopJE1K.js → renderer-CYr9YTXM.js} +436 -435
  35. package/dist/{resource-measurement-DRLp4nFt.js → resource-measurement-CsW4_eYt.js} +2 -2
  36. package/dist/{session-CNVc3VJ4.js → session-Da7LEQUB.js} +3 -3
  37. package/dist/{slide-pull-client-CzutXnGc.js → slide-pull-client-Bg9DusLX.js} +413 -300
  38. package/dist/source-key-BklvnEyQ.js +42 -0
  39. package/dist/{three-d-BYiWCNlz.js → three-d-7MaVzQuZ.js} +48 -47
  40. package/dist/three-d.mjs +324 -323
  41. package/dist/types/chart-ex.d.ts +2 -2
  42. package/dist/types/docx.d.ts +183 -19
  43. package/dist/types/index.d.ts +343 -26
  44. package/dist/types/math.d.ts +1 -1
  45. package/dist/types/node.d.ts +428 -348
  46. package/dist/types/pptx.d.ts +132 -11
  47. package/dist/types/region-map.d.ts +2 -2
  48. package/dist/types/three-d.d.ts +2 -2
  49. package/dist/types/xlsx.d.ts +78 -10
  50. package/dist/units-BzZ0gAxs.js +4 -0
  51. package/dist/{worksheet-pull-client-Cxj3Ej0s.js → worksheet-pull-client-CYtwXP5D.js} +3 -3
  52. package/dist/{xlsx-Bl3TIEVu.js → xlsx-DMWeXT-c.js} +429 -218
  53. package/dist/xlsx.mjs +6 -6
  54. package/dist/xlsx_parser_bg.wasm +0 -0
  55. package/package.json +2 -1
  56. package/dist/assets/render-worker-Cx5uR77k.js +0 -10
  57. package/dist/highlight-rect-BqcZMHUE.js +0 -48
  58. /package/dist/{mathjax-DJa-Q93p.js → mathjax-DwIrafQ6.js} +0 -0
  59. /package/dist/{renderer-module-contract-0bO_5SC0.js → renderer-module-contract-DLbb7zY0.js} +0 -0
  60. /package/dist/{transfer-D0U6Uhn4.js → transfer-R6NjgBKD.js} +0 -0
  61. /package/dist/{visible-index-DbDuGMCE.js → visible-index-BFE3PWiY.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Jt as e } from "./line-metrics-Baz31mML.js";
1
+ import { Jt as e } from "./line-metrics-B3syvDn2.js";
2
2
  //#region packages/core/src/errors/cfb-sniff.ts
3
3
  var t = [
4
4
  208,
package/dist/chart-ex.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { $t as e, Bt as t, Ft as n, Gt as r, Ht as i, It as a, J as o, K as s, Lt as c, Ot as l, Pt as u, Qt as d, Zt as f, ct as p, en as m, f as h, r as g, t as _, u as v } from "./plot-area-frame-Dg1VIpUU.js";
2
- import { T as y, w as b } from "./three-d-BYiWCNlz.js";
3
- import { A as x, C as S, D as C, E as w, F as T, I as E, L as D, M as O, N as k, O as A, P as j, R as M, S as N, T as ee, _ as te, a as P, b as ne, c as re, d as F, f as I, g as ie, h as L, i as R, j as z, l as B, m as V, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as fe, w as pe, x as me, y as he } from "./renderer-DuopJE1K.js";
4
- import { t as ge } from "./renderer-module-contract-0bO_5SC0.js";
1
+ import { $t as e, Bt as t, Ft as n, Gt as r, Ht as i, It as a, J as o, K as s, Lt as c, Ot as l, Pt as u, Qt as d, Zt as f, ct as p, en as m, f as h, r as g, t as _, u as v } from "./plot-area-frame-DHV02PJU.js";
2
+ import { T as y, w as b } from "./three-d-7MaVzQuZ.js";
3
+ import { A as x, C as S, D as C, E as w, F as T, I as E, L as D, M as O, N as k, O as A, P as j, R as M, S as N, T as ee, _ as te, a as P, b as ne, c as re, d as F, f as I, g as ie, h as L, i as R, j as z, l as B, m as V, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as fe, w as pe, x as me, y as he } from "./renderer-CYr9YTXM.js";
4
+ import { t as ge } from "./renderer-module-contract-DLbb7zY0.js";
5
5
  function H(e) {
6
6
  return e != null && Number.isFinite(e) ? e : null;
7
7
  }
@@ -0,0 +1,6 @@
1
+ //#region packages/pptx/src/comment-occurrence.ts
2
+ function e(e, t, n) {
3
+ return `slide:${n}:${e.id ?? `classic:${e.authorId ?? "unknown"}:${e.index ?? t}`}`;
4
+ }
5
+ //#endregion
6
+ export { e as t };
@@ -0,0 +1,112 @@
1
+ import { i as e } from "./units-BzZ0gAxs.js";
2
+ import { t } from "./highlight-rect-MaCt0om0.js";
3
+ import { t as n } from "./comment-occurrence-C34fWs_F.js";
4
+ import { i as r, n as i, o as a, r as o, t as s } from "./read-only-comment-margin-DrUX-YrP.js";
5
+ import { i as c, n as l, r as u, t as d } from "./read-only-comment-decoration-DcFevX_Q.js";
6
+ //#region packages/pptx/src/comment-margin.ts
7
+ function f(e, t, n) {
8
+ return {
9
+ messageKey: `${t}:reply:${e.id ?? n}`,
10
+ sourceId: e.id,
11
+ author: e.author,
12
+ date: e.date,
13
+ text: e.text,
14
+ status: e.status
15
+ };
16
+ }
17
+ function p(a, o, l, u, d, p, m, h, g, _, v, y, b = !1, x, S) {
18
+ r(a.ownerDocument), o && (o.dataset.ooxmlCommentZoom = String(_)), a.replaceChildren();
19
+ let C = l.map((e, t) => ({
20
+ comment: e,
21
+ index: t,
22
+ id: n(e, t, d)
23
+ })).filter(({ comment: e }) => b || e.status !== "resolved" && e.status !== "closed"), w = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), E = new Map(u.map((e) => [e.elementId, e])), D = a.parentElement;
24
+ for (let [n, r] of C.entries()) {
25
+ let { comment: o, id: s } = r, c = (o.anchors ?? []).flatMap((e) => {
26
+ if (e.type !== "drawingElement" && e.type !== "textRange" || !e.elementId) return [];
27
+ let t = E.get(e.elementId);
28
+ return t ? [t] : [];
29
+ });
30
+ if (h === s) for (let e of c) {
31
+ let n = a.ownerDocument.createElement("div");
32
+ n.dataset.ooxmlCommentTarget = s, n.style.cssText = `left:${t(e.bounds.x, p)};top:${t(e.bounds.y, m)};width:${t(e.bounds.width, p)};height:${t(e.bounds.height, m)};border-width:${2 * _}px;transform:rotate(${e.bounds.rotation}deg);`, a.appendChild(n);
33
+ }
34
+ let l = c[0]?.bounds, u = Number.isFinite(o.x) && Number.isFinite(o.y);
35
+ if (!u && !l) continue;
36
+ let d = Math.max(0, Math.min(l ? l.x + (u ? o.x : l.width) : o.x, p)), f = Math.max(0, Math.min(l ? l.y + (u ? o.y : 0) : o.y, m));
37
+ if (w.set(s, Object.freeze({
38
+ x: d / e * _ - 24 * _ / 2,
39
+ y: f / e * _ - 24 * _ / 2,
40
+ width: 24 * _,
41
+ height: 24 * _
42
+ })), h === s && c.length === 0 && !y) {
43
+ let e = a.ownerDocument.createElement("div");
44
+ e.dataset.ooxmlCommentTarget = s, e.style.cssText = `left:${t(d, p)};top:${t(f, m)};width:${24 * _}px;height:${24 * _}px;border-width:${2 * _}px;border-radius:50%;transform:translate(-50%,-50%);`, a.appendChild(e);
45
+ }
46
+ if (y) {
47
+ let e = i(a.ownerDocument, {
48
+ occurrenceKey: s,
49
+ visibleIndex: n,
50
+ author: o.author,
51
+ active: h === s,
52
+ zoom: _,
53
+ onSetActive: g
54
+ });
55
+ e.style.left = t(d, p), e.style.top = t(f, m), a.appendChild(e), T.set(s, e);
56
+ }
57
+ }
58
+ let O = C.map(({ comment: e, id: t }) => ({
59
+ occurrenceKey: t,
60
+ root: {
61
+ messageKey: `${t}:root`,
62
+ sourceId: e.id,
63
+ author: e.author,
64
+ date: e.date,
65
+ text: e.text,
66
+ status: e.status
67
+ },
68
+ replies: e.replies?.map((e, n) => f(e, t, n)) ?? []
69
+ })), k = o ? s(o, O, {
70
+ activeId: h,
71
+ zoom: _,
72
+ logicalWidth: v,
73
+ onSetActive: g,
74
+ onGeometryChange: x,
75
+ onScrollGeometryChange: S,
76
+ preferredTopById: new Map(O.map((e) => {
77
+ let t = w.get(e.occurrenceKey);
78
+ return [e.occurrenceKey, t?.y ?? 0];
79
+ }))
80
+ }) : /* @__PURE__ */ new Map();
81
+ for (let e of C) {
82
+ let t = k.get(e.id), n = T.get(e.id);
83
+ t?.id && n && n.setAttribute("aria-controls", t.id);
84
+ }
85
+ if (!x && !S) return Object.freeze({
86
+ threads: Object.freeze(O.map((e) => {
87
+ let t = w.get(e.occurrenceKey);
88
+ return Object.freeze({
89
+ occurrenceKey: e.occurrenceKey,
90
+ active: h === e.occurrenceKey,
91
+ anchorRects: Object.freeze(t ? [t] : [])
92
+ });
93
+ })),
94
+ scrollTop: o?.scrollTop ?? 0
95
+ });
96
+ let A = o && D ? c(o, D) : void 0, j = Object.freeze(O.map((e) => {
97
+ let t = k.get(e.occurrenceKey), n = t && D ? c(t, D) : void 0, r = w.get(e.occurrenceKey);
98
+ return Object.freeze({
99
+ occurrenceKey: e.occurrenceKey,
100
+ active: h === e.occurrenceKey,
101
+ anchorRects: Object.freeze(r ? [r] : []),
102
+ ...n ? { cardRect: n } : {}
103
+ });
104
+ }));
105
+ return Object.freeze({
106
+ threads: j,
107
+ ...A ? { cardClipBounds: A } : {},
108
+ scrollTop: o?.scrollTop ?? 0
109
+ });
110
+ }
111
+ //#endregion
112
+ export { p as buildPptxCommentMargin, d as buildReadOnlyCommentDecoration, l as disposeReadOnlyCommentDecoration, o as disposeReadOnlyCommentMargin, a as previewReadOnlyCommentMargin, u as projectReadOnlyCommentMarginScroll };
@@ -0,0 +1,2 @@
1
+ import { a as e } from "./read-only-comment-margin-DrUX-YrP.js";
2
+ export { e as paintReadOnlyCommentCard };
@@ -0,0 +1,171 @@
1
+ import { t as e } from "./highlight-rect-MaCt0om0.js";
2
+ import { o as t } from "./source-key-BklvnEyQ.js";
3
+ import { n } from "./comments-Cf9W7r3M.js";
4
+ import { i as r, n as i, o as a, r as o, s, t as c } from "./read-only-comment-margin-DrUX-YrP.js";
5
+ import { i as l, n as u, r as d, t as f } from "./read-only-comment-decoration-DcFevX_Q.js";
6
+ //#region packages/docx/src/comment-margin.ts
7
+ function p(e, r) {
8
+ let i = /* @__PURE__ */ new Set();
9
+ for (let e of r) e.source && i.add(t(e.source));
10
+ if (i.size === 0) return [];
11
+ let a = [];
12
+ for (let o of e) {
13
+ if (!(i.has(t(o.source)) || i.has(t(o.reference.source)) || o.geometryFallback !== void 0 && i.has(t(o.geometryFallback.source)))) continue;
14
+ let e = n(o, r);
15
+ e.length > 0 && a.push({
16
+ anchor: o,
17
+ runs: e
18
+ });
19
+ }
20
+ return a;
21
+ }
22
+ function m(e, t) {
23
+ let n = new Map(e.map((e) => [e.id, e])), r = e.filter((e) => e.parentId === void 0), i = /* @__PURE__ */ new Map();
24
+ for (let t of e) {
25
+ if (t.parentId === void 0) continue;
26
+ let e = t, r = new Set([e.id]);
27
+ for (; e.parentId !== void 0;) {
28
+ let i = n.get(e.parentId);
29
+ if (!i || r.has(i.id)) {
30
+ e = t;
31
+ break;
32
+ }
33
+ r.add(i.id), e = i;
34
+ }
35
+ if (e.parentId !== void 0 || e === t) continue;
36
+ let a = i.get(e.id) ?? [];
37
+ i.has(e.id) || i.set(e.id, a), a.push(t);
38
+ }
39
+ return r.filter((e) => t || e.resolved !== !0).map((e) => ({
40
+ root: e,
41
+ replies: Object.freeze(i.get(e.id) ?? [])
42
+ }));
43
+ }
44
+ function h(e, t, n) {
45
+ return {
46
+ messageKey: n === 0 ? `${t}:root` : `${t}:reply:${e.id || n - 1}`,
47
+ sourceId: e.id,
48
+ author: e.author,
49
+ date: e.date,
50
+ text: e.paragraphs?.join("\n") ?? e.text,
51
+ status: e.resolved ? "resolved" : "active"
52
+ };
53
+ }
54
+ function g(t, n, r, i, a, o) {
55
+ let s = t.ownerDocument.createElement("div");
56
+ return s.style.cssText = `--ooxml-comment-author-accent:${o};left:${e(n.x, r)};top:${e(n.y, i)};width:${e(n.w, r)};height:${e(n.h, i)};`, s.dataset.ooxmlCommentHighlight = "", s.dataset.active = String(a), n.transform && (s.style.transform = n.transform), t.appendChild(s), s;
57
+ }
58
+ function _(e) {
59
+ let t = e.highlightBounds;
60
+ return {
61
+ ...e,
62
+ x: t?.x ?? e.x,
63
+ y: t?.y ?? e.y,
64
+ w: t?.width ?? e.w,
65
+ h: t?.height ?? e.h
66
+ };
67
+ }
68
+ function v(e) {
69
+ let t = [];
70
+ for (let n of e) {
71
+ let e = t.at(-1);
72
+ if (e && e.y === n.y && e.h === n.h && e.transform === n.transform) {
73
+ let r = Math.min(e.x, n.x), i = Math.max(e.x + e.w, n.x + n.w);
74
+ t[t.length - 1] = {
75
+ ...e,
76
+ x: r,
77
+ w: i - r
78
+ };
79
+ continue;
80
+ }
81
+ t.push({ ...n });
82
+ }
83
+ return t;
84
+ }
85
+ function y(e, t, n, a, o, u, d, f, y, b, x, S = !1, C, w) {
86
+ r(e.ownerDocument), t && (t.dataset.ooxmlCommentZoom = String(y)), e.innerHTML = "";
87
+ let T = m(a.comments, S), E = new Map(T.map((e) => [e.root.id, s(e.root.author)])), D = new Set(T.map((e) => e.root.id)), O = /* @__PURE__ */ new Map();
88
+ for (let e of a.anchors) D.has(e.commentId) && !O.has(e.commentId) && O.set(e.commentId, e);
89
+ let k = p(a.anchors, n), A = new Set(k.map(({ anchor: e }) => e)), j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), N = e.parentElement;
90
+ for (let { anchor: t, runs: n } of k) {
91
+ if (!D.has(t.commentId)) continue;
92
+ let r = d === t.commentId;
93
+ for (let i of v(n.map(_))) {
94
+ let n = g(e, i, o, u, r, E.get(t.commentId) ?? s(void 0)), a = i.transform && N ? l(n, N) : Object.freeze({
95
+ x: i.x,
96
+ y: i.y,
97
+ width: i.w,
98
+ height: i.h
99
+ }), c = j.get(t.commentId) ?? [];
100
+ j.has(t.commentId) || j.set(t.commentId, c);
101
+ let d = a ?? Object.freeze({
102
+ x: i.x,
103
+ y: i.y,
104
+ width: i.w,
105
+ height: i.h
106
+ });
107
+ c.push(d), M.has(t.commentId) || M.set(t.commentId, Object.freeze({
108
+ rect: d,
109
+ ...i.direction ? { direction: i.direction } : {}
110
+ }));
111
+ }
112
+ }
113
+ let P = T.flatMap((e) => {
114
+ let t = O.get(e.root.id);
115
+ return !t || !A.has(t) ? [] : [{
116
+ occurrenceKey: e.root.id,
117
+ root: h(e.root, e.root.id, 0),
118
+ replies: e.replies.map((t, n) => h(t, e.root.id, n + 1))
119
+ }];
120
+ }), F = t ? c(t, P, {
121
+ activeId: d,
122
+ zoom: y,
123
+ logicalWidth: b,
124
+ onSetActive: f,
125
+ onGeometryChange: C,
126
+ onScrollGeometryChange: w,
127
+ preferredTopById: new Map(P.map((e) => {
128
+ let t = j.get(e.occurrenceKey)?.[0];
129
+ return [e.occurrenceKey, t?.y ?? 0];
130
+ }))
131
+ }) : /* @__PURE__ */ new Map();
132
+ if (x) for (let [t, n] of P.entries()) {
133
+ let r = M.get(n.occurrenceKey);
134
+ if (!r) continue;
135
+ let a = i(e.ownerDocument, {
136
+ occurrenceKey: n.occurrenceKey,
137
+ visibleIndex: t,
138
+ author: n.root.author,
139
+ active: d === n.occurrenceKey,
140
+ zoom: y,
141
+ onSetActive: f
142
+ }), s = 24 * y / 2, c = 4 * y, l = e.ownerDocument.defaultView?.getComputedStyle?.(e).direction, p = (r.direction ?? l) === "rtl" ? r.rect.x - c - s : r.rect.x + r.rect.width + c + s, m = Math.max(s, Math.min(p, o - s)), h = Math.max(s, Math.min(r.rect.y + r.rect.height / 2, u - s));
143
+ a.style.left = `${m / o * 100}%`, a.style.top = `${h / u * 100}%`;
144
+ let g = F.get(n.occurrenceKey);
145
+ g?.id && a.setAttribute("aria-controls", g.id), e.appendChild(a);
146
+ }
147
+ if (!C && !w) return Object.freeze({
148
+ threads: Object.freeze(P.map((e) => Object.freeze({
149
+ occurrenceKey: e.occurrenceKey,
150
+ active: d === e.occurrenceKey,
151
+ anchorRects: Object.freeze(j.get(e.occurrenceKey) ?? [])
152
+ }))),
153
+ scrollTop: t?.scrollTop ?? 0
154
+ });
155
+ let I = t && N ? l(t, N) : void 0, L = Object.freeze(P.map((e) => {
156
+ let t = F.get(e.occurrenceKey), n = t && N ? l(t, N) : void 0;
157
+ return Object.freeze({
158
+ occurrenceKey: e.occurrenceKey,
159
+ active: d === e.occurrenceKey,
160
+ anchorRects: Object.freeze(j.get(e.occurrenceKey) ?? []),
161
+ ...n ? { cardRect: n } : {}
162
+ });
163
+ }));
164
+ return Object.freeze({
165
+ threads: L,
166
+ ...I ? { cardClipBounds: I } : {},
167
+ scrollTop: t?.scrollTop ?? 0
168
+ });
169
+ }
170
+ //#endregion
171
+ export { y as buildDocxCommentMargin, f as buildReadOnlyCommentDecoration, u as disposeReadOnlyCommentDecoration, o as disposeReadOnlyCommentMargin, a as previewReadOnlyCommentMargin, d as projectReadOnlyCommentMarginScroll };
@@ -0,0 +1,241 @@
1
+ import { o as e } from "./source-key-BklvnEyQ.js";
2
+ //#region packages/docx/src/review-id.ts
3
+ function t(e) {
4
+ if (e === void 0) return;
5
+ let t = e.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "");
6
+ if (/^[+-]?\d+$/.test(t)) try {
7
+ return BigInt(t).toString();
8
+ } catch {
9
+ return;
10
+ }
11
+ }
12
+ //#endregion
13
+ //#region packages/docx/src/comments.ts
14
+ function n(e) {
15
+ return Object.freeze({
16
+ ...e,
17
+ path: Object.freeze([...e.path])
18
+ });
19
+ }
20
+ function r(e) {
21
+ return Object.freeze({
22
+ source: n(e.source),
23
+ runIndex: e.boundary,
24
+ affinity: e.boundary < e.runCount ? "following" : "preceding"
25
+ });
26
+ }
27
+ function i(e, t) {
28
+ let n = e.runs, r = 0;
29
+ for (let e = 0; e < Math.min(t, n.length); e += 1) n[e]?.type !== "unavailableDrawing" && (r += 1);
30
+ return r;
31
+ }
32
+ function a(e, t, i, a, o = t.boundary) {
33
+ return Object.freeze({
34
+ commentId: e,
35
+ source: n(t.source),
36
+ startRunIndex: t.boundary,
37
+ endRunIndex: o,
38
+ reference: r(i),
39
+ ...a === void 0 ? {} : { geometryFallback: Object.freeze({
40
+ source: n(a.source),
41
+ sourceRunIndex: a.boundary
42
+ }) }
43
+ });
44
+ }
45
+ function o(t, n) {
46
+ let r = t.flatMap(({ paragraph: t, source: r }, a) => {
47
+ let o = i(t, t.runs.length);
48
+ return [...n.get(e(r)) ?? []].sort((e, t) => e - t).map((e) => ({
49
+ paragraphIndex: a,
50
+ source: r,
51
+ boundary: e,
52
+ runCount: o
53
+ }));
54
+ });
55
+ return {
56
+ locations: r,
57
+ paragraphIndices: new Set(r.map(({ paragraphIndex: e }) => e))
58
+ };
59
+ }
60
+ function s(e, t) {
61
+ return e.paragraphIndex - t.paragraphIndex || e.boundary - t.boundary;
62
+ }
63
+ function c(e, t) {
64
+ let n = 0, r = e.length;
65
+ for (; n < r;) {
66
+ let i = n + Math.floor((r - n) / 2);
67
+ s(e[i], t) < 0 ? n = i + 1 : r = i;
68
+ }
69
+ return n;
70
+ }
71
+ function l(e, t) {
72
+ if (t.paragraphIndices.has(e.paragraphIndex)) return;
73
+ let n = c(t.locations, e), i = t.locations[n], a = n > 0 ? t.locations[n - 1] : void 0;
74
+ return r(e).affinity === "following" ? i ?? a : a ?? i;
75
+ }
76
+ function u(e, n, r) {
77
+ let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
78
+ for (let e of n) {
79
+ let n = t(e);
80
+ n === void 0 || c.has(n) || (s.has(n) ? (s.delete(n), c.add(n)) : s.set(n, e));
81
+ }
82
+ let u = /* @__PURE__ */ new Map();
83
+ for (let [n, { paragraph: r, source: a }] of e.entries()) for (let e of r.commentMarks ?? []) {
84
+ let o = t(e.id);
85
+ if (o === void 0) continue;
86
+ let s = u.get(o) ?? {
87
+ starts: [],
88
+ ends: [],
89
+ references: []
90
+ };
91
+ u.set(o, s);
92
+ let c = {
93
+ paragraphIndex: n,
94
+ source: a,
95
+ boundary: i(r, e.runIndex),
96
+ runCount: i(r, r.runs.length)
97
+ };
98
+ e.kind === "rangeStart" ? s.starts.push(c) : e.kind === "rangeEnd" ? s.ends.push(c) : e.kind === "reference" && s.references.push(c);
99
+ }
100
+ let d = [], f = o(e, r);
101
+ for (let [t, n] of u) {
102
+ let r = s.get(t);
103
+ if (r === void 0 || n.references.length !== 1) continue;
104
+ let o = n.references[0];
105
+ if (n.starts.length > 1 || n.ends.length > 1) continue;
106
+ let c = n.starts.length === 1 ? n.starts[0] : void 0, u = n.ends.length === 1 ? n.ends[0] : void 0;
107
+ if (c && u && (c.paragraphIndex < u.paragraphIndex || c.paragraphIndex === u.paragraphIndex && c.boundary <= u.boundary)) {
108
+ let t = l(c.paragraphIndex === u.paragraphIndex && c.boundary === u.boundary ? c : o, f);
109
+ for (let n = c.paragraphIndex; n <= u.paragraphIndex; n += 1) {
110
+ let s = e[n], l = n === c.paragraphIndex ? c.boundary : 0, f = n === u.paragraphIndex ? u.boundary : i(s.paragraph, s.paragraph.runs.length);
111
+ d.push(a(r, {
112
+ paragraphIndex: n,
113
+ source: s.source,
114
+ boundary: l,
115
+ runCount: i(s.paragraph, s.paragraph.runs.length)
116
+ }, o, t, Math.max(l, f)));
117
+ }
118
+ continue;
119
+ }
120
+ let p = c && n.ends.length === 0 ? c : u && n.starts.length === 0 ? u : void 0;
121
+ if (c && u) continue;
122
+ let m = p ?? o, h = l(m, f);
123
+ d.push(a(r, m, o, h));
124
+ }
125
+ return d;
126
+ }
127
+ function d(e, t, n = /* @__PURE__ */ new Map()) {
128
+ let r = new Set(e.map(({ id: e }) => e)), i = /* @__PURE__ */ new Map();
129
+ for (let e of t.blocks.sources) {
130
+ let n = t.blocks.resolve(e);
131
+ if (n.type !== "paragraph") continue;
132
+ let r = `${e.story}\u0000${e.storyInstance}`, a = i.get(r) ?? [];
133
+ i.has(r) || i.set(r, a), a.push({
134
+ paragraph: n,
135
+ source: e
136
+ });
137
+ }
138
+ return [...i.values()].flatMap((e) => u(e, r, n));
139
+ }
140
+ function f(e, t, n = /* @__PURE__ */ new Map()) {
141
+ return (e?.length ?? 0) === 0 ? [] : d(e ?? [], t, n);
142
+ }
143
+ function p(e, t) {
144
+ return e !== void 0 && e.story === t.story && e.storyInstance === t.storyInstance && e.path.length === t.path.length && e.path.every((e, n) => e === t.path[n]);
145
+ }
146
+ function m(e, t) {
147
+ let n = t.filter((t) => t.sourceRunIndex !== void 0 && p(t.source, e.source)), r = n.filter((t) => t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
148
+ if (r.length > 0) return r;
149
+ if (e.startRunIndex === e.endRunIndex && n.length > 0) {
150
+ let t = n.reduce((t, n) => {
151
+ let r = n.sourceRunIndex;
152
+ return r < e.startRunIndex ? t : t === void 0 || r < t ? r : t;
153
+ }, void 0), r = n.reduce((t, n) => {
154
+ let r = n.sourceRunIndex;
155
+ return r >= e.startRunIndex ? t : t === void 0 || r > t ? r : t;
156
+ }, void 0), i = t ?? r;
157
+ if (i !== void 0) return n.filter((e) => e.sourceRunIndex === i);
158
+ }
159
+ let i = t.filter((t) => t.sourceRunIndex !== void 0 && p(t.source, e.reference.source)), a = i.reduce((t, n) => {
160
+ let r = n.sourceRunIndex;
161
+ return r < e.reference.runIndex ? t : t === void 0 || r < t ? r : t;
162
+ }, void 0), o = i.reduce((t, n) => {
163
+ let r = n.sourceRunIndex;
164
+ return r >= e.reference.runIndex ? t : t === void 0 || r > t ? r : t;
165
+ }, void 0), s = e.reference.affinity === "following" ? a ?? o : o ?? a;
166
+ if (s !== void 0) return i.filter((e) => e.sourceRunIndex === s);
167
+ let c = e.geometryFallback;
168
+ return c === void 0 ? [] : t.filter((e) => e.sourceRunIndex === c.sourceRunIndex && p(e.source, c.source));
169
+ }
170
+ function h(e, t) {
171
+ return t.some((t) => t.sourceRunIndex !== void 0 && p(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex) ? "range" : t.some((t) => p(t.source, e.source) || p(t.source, e.reference.source)) ? "point" : "fallback";
172
+ }
173
+ function g(e) {
174
+ let t = e.map((e) => {
175
+ let t = e.highlightBounds;
176
+ return {
177
+ x: t?.x ?? e.x,
178
+ y: t?.y ?? e.y,
179
+ width: t?.width ?? e.w,
180
+ height: t?.height ?? e.h,
181
+ ...e.transform ? { transform: e.transform } : {}
182
+ };
183
+ }).filter(({ width: e, height: t }) => e > 0 && t > 0).sort((e, t) => e.y - t.y || e.x - t.x), n = [];
184
+ for (let e of t) {
185
+ let t = n.at(-1);
186
+ if (t && t.y === e.y && t.height === e.height && t.transform === e.transform) {
187
+ let r = Math.min(t.x, e.x), i = Math.max(t.x + t.width, e.x + e.width);
188
+ n[n.length - 1] = Object.freeze({
189
+ ...t,
190
+ x: r,
191
+ width: i - r
192
+ });
193
+ } else n.push(Object.freeze({ ...e }));
194
+ }
195
+ return Object.freeze(n);
196
+ }
197
+ function _(t, n, r, i = {}) {
198
+ let a = new Map(t.map((e) => [e.id, e])), o = t.filter((e) => e.parentId === void 0), s = new Map(o.map((e) => [e.id, e])), c = /* @__PURE__ */ new Map(), l = new Map(o.map((e) => [e.id, e.id]));
199
+ for (let e of t) {
200
+ if (e.parentId === void 0) continue;
201
+ let t = new Set([e.id]), n = e;
202
+ for (; n.parentId !== void 0;) {
203
+ let r = a.get(n.parentId);
204
+ if (!r || t.has(r.id)) {
205
+ n = e;
206
+ break;
207
+ }
208
+ t.add(r.id), n = r;
209
+ }
210
+ if (!s.has(n.id) || n === e) continue;
211
+ l.set(e.id, n.id);
212
+ let r = c.get(n.id) ?? [];
213
+ c.has(n.id) || c.set(n.id, r), r.push(e);
214
+ }
215
+ let u = /* @__PURE__ */ new Set();
216
+ for (let t of r) t.source && u.add(e(t.source));
217
+ let d = /* @__PURE__ */ new Map();
218
+ for (let t of n) {
219
+ let n = l.get(t.commentId);
220
+ if (n === void 0 || !(u.has(e(t.source)) || u.has(e(t.reference.source)) || t.geometryFallback !== void 0 && u.has(e(t.geometryFallback.source)))) continue;
221
+ let i = m(t, r);
222
+ if (i.length === 0) continue;
223
+ let a = d.get(n) ?? [];
224
+ d.has(n) || d.set(n, a), a.push(Object.freeze({
225
+ anchor: t,
226
+ kind: h(t, i),
227
+ rects: g(i)
228
+ }));
229
+ }
230
+ return Object.freeze(o.flatMap((e) => {
231
+ if (i.includeResolved === !1 && e.resolved === !0) return [];
232
+ let t = d.get(e.id);
233
+ return t?.length ? [Object.freeze({
234
+ root: e,
235
+ replies: Object.freeze([...c.get(e.id) ?? []]),
236
+ anchors: Object.freeze([...t])
237
+ })] : [];
238
+ }));
239
+ }
240
+ //#endregion
241
+ export { t as i, m as n, _ as r, f as t };