@forevka/wordcanvas 0.7.0 → 0.7.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.
- package/README.md +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-D8rUOKfg.js} +9603 -9451
- package/dist-lib/assets/worker-wXuuyshQ.js +2258 -0
- package/dist-lib/{blockFactory-Bcy0U40y.js → blockFactory-CUI4Rqiq.js} +50 -42
- package/dist-lib/{browser-5Sv4CuNy.js → browser-DkKxreJM.js} +404 -383
- package/dist-lib/builder.js +364 -109
- package/dist-lib/editorApp-DLXMmtu5.js +8023 -0
- package/dist-lib/export.js +3820 -3768
- package/dist-lib/generate-toc.js +4 -4
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/pipeline-CbxmCE84.js +1705 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-g1hFKSNs.js +3935 -0
- package/dist-lib/toc-B6VpkJge.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-6WxRNKCc.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-CFqpDK0k.js} +1 -1
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-22JHAERT.js} +95 -23
- package/dist-node/chunk-22JHAERT.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-6AJJMHKY.js} +1 -1
- package/dist-node/chunk-6AJJMHKY.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-CDN6WU2P.js} +89 -26
- package/dist-node/chunk-CDN6WU2P.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-RNB336F3.js} +116 -5
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-RNB336F3.js.map} +2 -2
- package/dist-node/{engine-FRCX7PXF.js → engine-5FGDJD2H.js} +3 -3
- package/dist-node/export.js +92 -31
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +5 -5
- package/dist-node/import.js +3 -3
- package/dist-node/recalc-docx.js +4 -4
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +231 -225
- package/types/recalc-docx.d.ts +27 -27
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5FGDJD2H.js.map} +0 -0
package/dist-lib/import.js
CHANGED
|
@@ -1,1540 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
const Je = /* @__PURE__ */ new Set([
|
|
5
|
-
"TOC",
|
|
6
|
-
"PAGE",
|
|
7
|
-
"NUMPAGES",
|
|
8
|
-
"PAGEREF",
|
|
9
|
-
"HYPERLINK",
|
|
10
|
-
"REF",
|
|
11
|
-
"SEQ",
|
|
12
|
-
"STYLEREF",
|
|
13
|
-
"DATE",
|
|
14
|
-
"TIME",
|
|
15
|
-
"CREATEDATE",
|
|
16
|
-
"SAVEDATE",
|
|
17
|
-
"PRINTDATE",
|
|
18
|
-
"EDITTIME",
|
|
19
|
-
"FILENAME",
|
|
20
|
-
"FILESIZE",
|
|
21
|
-
"AUTHOR",
|
|
22
|
-
"LASTSAVEDBY",
|
|
23
|
-
"TITLE",
|
|
24
|
-
"SUBJECT",
|
|
25
|
-
"KEYWORDS",
|
|
26
|
-
"COMMENTS",
|
|
27
|
-
"NUMWORDS",
|
|
28
|
-
"NUMCHARS",
|
|
29
|
-
"TOA",
|
|
30
|
-
"INDEX",
|
|
31
|
-
"XE",
|
|
32
|
-
"TC",
|
|
33
|
-
"TA",
|
|
34
|
-
"RD",
|
|
35
|
-
"FORMTEXT",
|
|
36
|
-
"FORMCHECKBOX",
|
|
37
|
-
"FORMDROPDOWN",
|
|
38
|
-
"SYMBOL",
|
|
39
|
-
"QUOTE",
|
|
40
|
-
"IF",
|
|
41
|
-
"DOCPROPERTY",
|
|
42
|
-
"DOCVARIABLE",
|
|
43
|
-
"MERGEFIELD",
|
|
44
|
-
"ADDRESSBLOCK",
|
|
45
|
-
"GREETINGLINE",
|
|
46
|
-
"FILLIN",
|
|
47
|
-
"ASK",
|
|
48
|
-
"SET",
|
|
49
|
-
"GOTOBUTTON",
|
|
50
|
-
"MACROBUTTON",
|
|
51
|
-
"EQ",
|
|
52
|
-
"LISTNUM",
|
|
53
|
-
"BIBLIOGRAPHY",
|
|
54
|
-
"CITATION",
|
|
55
|
-
"SECTION",
|
|
56
|
-
"SECTIONPAGES",
|
|
57
|
-
"AUTONUM",
|
|
58
|
-
"AUTONUMLGL",
|
|
59
|
-
"AUTONUMOUT",
|
|
60
|
-
"INCLUDETEXT",
|
|
61
|
-
"INCLUDEPICTURE",
|
|
62
|
-
"LINK",
|
|
63
|
-
"NOTEREF"
|
|
64
|
-
]);
|
|
65
|
-
function et(e) {
|
|
66
|
-
return Je.has(e.trim().toUpperCase());
|
|
67
|
-
}
|
|
68
|
-
function tt(e) {
|
|
69
|
-
const t = [], n = /"([^"]*)"|(\S+)/g;
|
|
70
|
-
let o;
|
|
71
|
-
for (; (o = n.exec(e)) !== null; ) t.push(o[1] !== void 0 ? o[1] : o[2]);
|
|
72
|
-
return t;
|
|
73
|
-
}
|
|
74
|
-
function Ne(e) {
|
|
75
|
-
const t = tt(e);
|
|
76
|
-
return { name: t.length > 0 ? t[0].toUpperCase() : "", args: t.slice(1), raw: e };
|
|
77
|
-
}
|
|
78
|
-
function nt(e) {
|
|
79
|
-
const t = Ne(e).name;
|
|
80
|
-
return t.length > 0 && !et(t);
|
|
81
|
-
}
|
|
82
|
-
const N = (e) => e / 15, ot = (e) => e * 2 / 3, Me = (e) => e / 9525, st = (e) => e / 240, S = (e) => Math.round(e * 100) / 100, ke = (e) => ({
|
|
83
|
-
top: S(N(e.top)),
|
|
84
|
-
right: S(N(e.right)),
|
|
85
|
-
bottom: S(N(e.bottom)),
|
|
86
|
-
left: S(N(e.left))
|
|
87
|
-
}), it = [
|
|
88
|
-
["top", "w:top"],
|
|
89
|
-
["left", "w:left"],
|
|
90
|
-
["bottom", "w:bottom"],
|
|
91
|
-
["right", "w:right"],
|
|
92
|
-
["insideH", "w:insideH"],
|
|
93
|
-
["insideV", "w:insideV"]
|
|
94
|
-
];
|
|
95
|
-
function Ie(e) {
|
|
96
|
-
if (!e) return;
|
|
97
|
-
const t = {};
|
|
98
|
-
for (const [n, o] of it) {
|
|
99
|
-
const s = u(e, o);
|
|
100
|
-
if (!s) continue;
|
|
101
|
-
const a = { val: k(s, "w:val") ?? "single" }, r = T(s, "w:sz");
|
|
102
|
-
r !== void 0 && (a.sizeEighthPt = r);
|
|
103
|
-
const i = k(s, "w:color");
|
|
104
|
-
i && (a.color = i), t[n] = a;
|
|
105
|
-
}
|
|
106
|
-
return Object.keys(t).length > 0 ? t : void 0;
|
|
107
|
-
}
|
|
108
|
-
function Se(e) {
|
|
109
|
-
if (!e) return;
|
|
110
|
-
const t = k(e, "w:fill");
|
|
111
|
-
if (t && t !== "auto") return `#${t.toLowerCase()}`;
|
|
112
|
-
const n = k(e, "w:val"), o = k(e, "w:color");
|
|
113
|
-
if (n && n !== "clear" && n !== "nil" && o && o !== "auto")
|
|
114
|
-
return `#${o.toLowerCase()}`;
|
|
115
|
-
}
|
|
116
|
-
function rt(e, t) {
|
|
117
|
-
return e ? t ? { ...e, ...t } : e : t;
|
|
118
|
-
}
|
|
119
|
-
function at(e, t) {
|
|
120
|
-
const n = (f, p, d) => (
|
|
121
|
-
// Cell edges are named directly; the table/style layers use the named edge
|
|
122
|
-
// on the boundary and the inside edge between cells.
|
|
123
|
-
e.cell?.[f] ?? e.table?.[d ? f : p] ?? e.style?.[d ? f : p]
|
|
124
|
-
), o = {}, s = ue(n("top", "insideH", t.top));
|
|
125
|
-
s && (o.top = s);
|
|
126
|
-
const a = ue(n("bottom", "insideH", t.bottom));
|
|
127
|
-
a && (o.bottom = a);
|
|
128
|
-
const r = ue(n("left", "insideV", t.left));
|
|
129
|
-
r && (o.left = r);
|
|
130
|
-
const i = ue(n("right", "insideV", t.right));
|
|
131
|
-
return i && (o.right = i), o;
|
|
132
|
-
}
|
|
133
|
-
function ue(e) {
|
|
134
|
-
if (!e || e.val === "nil" || e.val === "none") return;
|
|
135
|
-
const t = S(Math.max(0.5, (e.sizeEighthPt ?? 4) / 6)), o = { color: !e.color || e.color === "auto" ? "#000000" : `#${e.color.toLowerCase()}`, widthPx: t }, s = ct(e.val);
|
|
136
|
-
return s !== "single" && (o.style = s), o;
|
|
137
|
-
}
|
|
138
|
-
function ct(e) {
|
|
139
|
-
return e === "double" ? "double" : /dash/i.test(e) ? "dashed" : /dot/i.test(e) ? "dotted" : "single";
|
|
140
|
-
}
|
|
141
|
-
function ie(e) {
|
|
142
|
-
const t = {}, n = V(e, "w:rStyle");
|
|
143
|
-
n && (t.styleId = n);
|
|
144
|
-
const o = ne(u(e, "w:b"));
|
|
145
|
-
o !== void 0 && (t.bold = o);
|
|
146
|
-
const s = ne(u(e, "w:i"));
|
|
147
|
-
s !== void 0 && (t.italic = s);
|
|
148
|
-
const a = ne(u(e, "w:strike"));
|
|
149
|
-
a !== void 0 && (t.strikethrough = a);
|
|
150
|
-
const r = u(e, "w:u");
|
|
151
|
-
r && (t.underline = k(r, "w:val") !== "none");
|
|
152
|
-
const i = u(e, "w:color");
|
|
153
|
-
if (i) {
|
|
154
|
-
const w = k(i, "w:val");
|
|
155
|
-
w && (t.color = w);
|
|
156
|
-
const B = k(i, "w:themeColor");
|
|
157
|
-
B && (t.colorTheme = B);
|
|
158
|
-
}
|
|
159
|
-
const f = T(u(e, "w:sz"), "w:val");
|
|
160
|
-
f !== void 0 && (t.sizeHalfPoints = f);
|
|
161
|
-
const p = u(e, "w:rFonts");
|
|
162
|
-
if (p) {
|
|
163
|
-
const w = k(p, "w:ascii");
|
|
164
|
-
w && (t.fontAscii = w);
|
|
165
|
-
const B = k(p, "w:asciiTheme");
|
|
166
|
-
B && (t.fontThemeAscii = B);
|
|
167
|
-
}
|
|
168
|
-
const d = V(e, "w:highlight");
|
|
169
|
-
d && d !== "none" && (t.highlight = d);
|
|
170
|
-
const c = V(e, "w:vertAlign");
|
|
171
|
-
c && (t.vertAlign = c);
|
|
172
|
-
const g = ne(u(e, "w:vanish"));
|
|
173
|
-
return g !== void 0 && (t.vanish = g), t;
|
|
174
|
-
}
|
|
175
|
-
const lt = {
|
|
176
|
-
left: "left",
|
|
177
|
-
start: "left",
|
|
178
|
-
center: "center",
|
|
179
|
-
right: "right",
|
|
180
|
-
end: "right",
|
|
181
|
-
both: "justify",
|
|
182
|
-
distribute: "justify"
|
|
183
|
-
};
|
|
184
|
-
function ve(e, t) {
|
|
185
|
-
const n = {}, o = V(e, "w:pStyle");
|
|
186
|
-
o && (n.styleId = o);
|
|
187
|
-
const s = V(e, "w:jc"), a = s !== void 0 ? lt[s] : void 0;
|
|
188
|
-
a && (n.align = a);
|
|
189
|
-
const r = u(e, "w:spacing");
|
|
190
|
-
if (r) {
|
|
191
|
-
const y = T(r, "w:before");
|
|
192
|
-
y !== void 0 && (n.spaceBeforeTwips = y);
|
|
193
|
-
const U = T(r, "w:after");
|
|
194
|
-
U !== void 0 && (n.spaceAfterTwips = U);
|
|
195
|
-
const $ = T(r, "w:line"), P = k(r, "w:lineRule") ?? "auto";
|
|
196
|
-
$ !== void 0 && (P === "auto" ? n.lineHeight = st($) : t.add("line-rule-exact", "Exact/atLeast line spacing was ignored (model is multiplier-only)."));
|
|
197
|
-
}
|
|
198
|
-
const i = u(e, "w:ind");
|
|
199
|
-
if (i) {
|
|
200
|
-
const y = T(i, "w:left") ?? T(i, "w:start");
|
|
201
|
-
y !== void 0 && (n.indentLeftTwips = y);
|
|
202
|
-
const U = T(i, "w:right") ?? T(i, "w:end");
|
|
203
|
-
U !== void 0 && (n.indentRightTwips = U);
|
|
204
|
-
const $ = T(i, "w:firstLine"), P = T(i, "w:hanging");
|
|
205
|
-
$ !== void 0 ? n.indentFirstLineTwips = $ : P !== void 0 && (n.indentFirstLineTwips = -P);
|
|
206
|
-
}
|
|
207
|
-
const f = ne(u(e, "w:keepNext"));
|
|
208
|
-
f !== void 0 && (n.keepWithNext = f);
|
|
209
|
-
const p = ne(u(e, "w:keepLines"));
|
|
210
|
-
p !== void 0 && (n.keepLinesTogether = p);
|
|
211
|
-
const d = u(e, "w:tabs");
|
|
212
|
-
if (d) {
|
|
213
|
-
const y = [];
|
|
214
|
-
for (const U of X(d, "w:tab")) {
|
|
215
|
-
const $ = T(U, "w:pos"), P = k(U, "w:val");
|
|
216
|
-
if ($ === void 0 || P === "clear" || P === "bar") continue;
|
|
217
|
-
const K = { posTwips: $ };
|
|
218
|
-
P && (K.val = P);
|
|
219
|
-
const z = k(U, "w:leader");
|
|
220
|
-
z && (K.leader = z), y.push(K);
|
|
221
|
-
}
|
|
222
|
-
y.length > 0 && (n.tabStops = y);
|
|
223
|
-
}
|
|
224
|
-
const c = ne(u(e, "w:pageBreakBefore"));
|
|
225
|
-
c !== void 0 && (n.pageBreakBefore = c);
|
|
226
|
-
const g = V(e, "w:outlineLvl");
|
|
227
|
-
if (g !== void 0) {
|
|
228
|
-
const y = Number(g);
|
|
229
|
-
Number.isFinite(y) && y >= 0 && y <= 8 && (n.outlineLevel = y);
|
|
230
|
-
}
|
|
231
|
-
const w = u(e, "w:numPr");
|
|
232
|
-
if (w) {
|
|
233
|
-
const y = V(w, "w:numId");
|
|
234
|
-
y !== void 0 && (n.list = y === "0" ? null : { numId: y, level: T(u(w, "w:ilvl"), "w:val") ?? 0 });
|
|
235
|
-
}
|
|
236
|
-
const B = u(e, "w:rPr");
|
|
237
|
-
B && (n.markRunProps = ie(B));
|
|
238
|
-
const C = u(e, "w:sectPr");
|
|
239
|
-
if (C) {
|
|
240
|
-
n.sectionBreak = V(C, "w:type") === "continuous" ? "continuous" : "page";
|
|
241
|
-
const y = u(C, "w:pgSz"), U = T(y, "w:w"), $ = T(y, "w:h");
|
|
242
|
-
U !== void 0 && $ !== void 0 && (n.sectionPgSize = { w: U, h: $ });
|
|
243
|
-
const P = u(C, "w:pgMar");
|
|
244
|
-
if (P) {
|
|
245
|
-
const Y = T(P, "w:top"), Q = T(P, "w:right"), q = T(P, "w:bottom"), te = T(P, "w:left");
|
|
246
|
-
Y !== void 0 && Q !== void 0 && q !== void 0 && te !== void 0 && (n.sectionMarginTwips = { top: Y, right: Q, bottom: q, left: te });
|
|
247
|
-
}
|
|
248
|
-
const K = u(C, "w:cols"), z = T(K, "w:num");
|
|
249
|
-
if (z !== void 0 && z > 1) {
|
|
250
|
-
n.sectionColumns = { count: z };
|
|
251
|
-
const Y = T(K, "w:space");
|
|
252
|
-
Y !== void 0 && (n.sectionColumns.spaceTwips = Y);
|
|
253
|
-
}
|
|
254
|
-
const ee = T(u(C, "w:pgNumType"), "w:start");
|
|
255
|
-
ee !== void 0 && (n.sectionPageNumberStart = ee), (X(C, "w:headerReference").length > 0 || X(C, "w:footerReference").length > 0) && (n.sectionHasBands = !0);
|
|
256
|
-
}
|
|
257
|
-
return n;
|
|
258
|
-
}
|
|
259
|
-
const xe = () => ({ depth: 0, topInstr: "", openId: null, markBlock: null, next: { n: 0 }, registry: {} });
|
|
260
|
-
function Ee(e) {
|
|
261
|
-
const t = e.fieldTrack;
|
|
262
|
-
if (t.openId !== null || !nt(t.topInstr)) return;
|
|
263
|
-
const n = `field${t.next.n++}`;
|
|
264
|
-
t.registry[n] = { id: n, instruction: t.topInstr, name: Ne(t.topInstr).name, kind: "custom" }, t.openId = n, t.markBlock = n;
|
|
265
|
-
}
|
|
266
|
-
function Le(e) {
|
|
267
|
-
let t = 0;
|
|
268
|
-
for (const n of e)
|
|
269
|
-
n.kind === "run" ? t += n.text.length : n.kind === "break" && (t += 1);
|
|
270
|
-
return t;
|
|
271
|
-
}
|
|
272
|
-
function dt(e, t, n) {
|
|
273
|
-
const o = Z(J(e, t), "w:document"), s = o && u(o, "w:body");
|
|
274
|
-
if (!s)
|
|
275
|
-
throw new se("MALFORMED_XML", `${t} has no w:document/w:body root.`);
|
|
276
|
-
const a = {}, r = { warnings: n, fieldTokens: !1, sdts: a, nextSdt: { n: 0 }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null, trackFields: !0, fieldTrack: xe() }, i = [];
|
|
277
|
-
re(G(s), i, r);
|
|
278
|
-
const f = u(s, "w:sectPr"), p = f ? yt(f) : null, d = r.fieldTrack.registry;
|
|
279
|
-
return Object.keys(d).length > 0 ? { blocks: i, section: p, sdts: a, fields: d } : { blocks: i, section: p, sdts: a };
|
|
280
|
-
}
|
|
281
|
-
function ft(e, t, n, o = {}) {
|
|
282
|
-
const s = J(e, t), a = Z(s, "w:hdr") ?? Z(s, "w:ftr");
|
|
283
|
-
if (!a)
|
|
284
|
-
throw new se("MALFORMED_XML", `${t} has no w:hdr/w:ftr root.`);
|
|
285
|
-
const r = { warnings: n, fieldTokens: !0, sdts: o, nextSdt: { n: Object.keys(o).length }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null, trackFields: !1, fieldTrack: xe() }, i = [];
|
|
286
|
-
return re(G(a), i, r), i;
|
|
287
|
-
}
|
|
288
|
-
const ut = /* @__PURE__ */ new Set(["_GoBack", "_Toc_Placeholder"]);
|
|
289
|
-
function De(e) {
|
|
290
|
-
const t = k(e, "w:name");
|
|
291
|
-
return t && !ut.has(t) ? t : null;
|
|
292
|
-
}
|
|
293
|
-
function re(e, t, n) {
|
|
294
|
-
for (const o of e)
|
|
295
|
-
switch (n.trackFields && (n.fieldTrack.markBlock = n.fieldTrack.openId), o.tagName) {
|
|
296
|
-
case "w:p": {
|
|
297
|
-
const s = pt(o, n);
|
|
298
|
-
n.trackFields && n.fieldTrack.markBlock && (s.fieldId = n.fieldTrack.markBlock), t.push(s);
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
case "w:tbl": {
|
|
302
|
-
const s = vt(o, n);
|
|
303
|
-
n.trackFields && n.fieldTrack.markBlock && (s.fieldId = n.fieldTrack.markBlock), t.push(s);
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
case "w:sdt": {
|
|
307
|
-
const s = u(o, "w:sdtContent");
|
|
308
|
-
if (!s) break;
|
|
309
|
-
const a = Ue(u(o, "w:sdtPr"));
|
|
310
|
-
if (!a) {
|
|
311
|
-
n.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), re(G(s), t, n);
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
const r = `sdt${n.nextSdt.n++}`;
|
|
315
|
-
n.sdts[r] = a;
|
|
316
|
-
const i = [];
|
|
317
|
-
re(G(s), i, n);
|
|
318
|
-
for (const f of i) je(f, r);
|
|
319
|
-
t.push(...i);
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
case "w:bookmarkStart": {
|
|
323
|
-
const s = De(o), a = k(o, "w:id");
|
|
324
|
-
s && (n.pendingBookmarks.push(s), a && n.pendingMarkers.push({ id: a, name: s, kind: "start", offset: 0 }));
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
case "w:bookmarkEnd": {
|
|
328
|
-
const s = k(o, "w:id");
|
|
329
|
-
s && n.pendingMarkers.push({ id: s, kind: "end", offset: 0 });
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
function pt(e, t) {
|
|
335
|
-
const n = u(e, "w:pPr"), o = n ? ve(n, t.warnings) : {}, s = [], a = t.pendingBookmarks;
|
|
336
|
-
t.pendingBookmarks = [], t.currentBookmarks = a;
|
|
337
|
-
const r = t.pendingMarkers;
|
|
338
|
-
t.pendingMarkers = [], t.currentMarkers = r;
|
|
339
|
-
const i = { depth: 0, instr: "", suppressResult: !1 };
|
|
340
|
-
oe(G(e), s, t, i), t.currentBookmarks = null, t.currentMarkers = null;
|
|
341
|
-
const f = { kind: "paragraph", props: o, inlines: s };
|
|
342
|
-
return a.length > 0 && (f.bookmarks = a), r.length > 0 && (f.bookmarkMarkers = r), f;
|
|
343
|
-
}
|
|
344
|
-
function Te(e) {
|
|
345
|
-
if (/\bNUMPAGES\b/.test(e)) return "{pages}";
|
|
346
|
-
if (/\bPAGE\b/.test(e)) return "{page}";
|
|
347
|
-
}
|
|
348
|
-
function ht(e) {
|
|
349
|
-
const t = e.match(/\bPAGEREF\s+("[^"]+"|\S+)/) ?? e.match(/\bHYPERLINK\s+\\l\s+("[^"]+"|\S+)/);
|
|
350
|
-
return t ? t[1].replace(/^"|"$/g, "") : void 0;
|
|
351
|
-
}
|
|
352
|
-
function oe(e, t, n, o) {
|
|
353
|
-
for (const s of e)
|
|
354
|
-
switch (s.tagName) {
|
|
355
|
-
case "w:r":
|
|
356
|
-
mt(s, t, n, o);
|
|
357
|
-
break;
|
|
358
|
-
case "w:hyperlink": {
|
|
359
|
-
const a = k(s, "r:id"), r = k(s, "w:anchor"), i = t.length;
|
|
360
|
-
if (oe(G(s), t, n, o), a || r)
|
|
361
|
-
for (let f = i; f < t.length; f++) {
|
|
362
|
-
const p = t[f];
|
|
363
|
-
p.kind === "run" && (a ? p.props.linkRelId = a : r && (p.props.linkAnchor = r));
|
|
364
|
-
}
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
case "w:sdt": {
|
|
368
|
-
const a = u(s, "w:sdtContent");
|
|
369
|
-
if (!a) break;
|
|
370
|
-
const r = Ue(u(s, "w:sdtPr"));
|
|
371
|
-
if (!r) {
|
|
372
|
-
n.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), oe(G(a), t, n, o);
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
const i = `sdt${n.nextSdt.n++}`;
|
|
376
|
-
n.sdts[i] = r;
|
|
377
|
-
const f = [];
|
|
378
|
-
oe(G(a), f, n, o);
|
|
379
|
-
for (const p of f)
|
|
380
|
-
p.kind === "run" && (p.sdtId = i);
|
|
381
|
-
t.push(...f);
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
case "w:fldSimple": {
|
|
385
|
-
const a = k(s, "w:instr") ?? "", r = n.fieldTokens ? Te(a) : void 0;
|
|
386
|
-
r ? t.push({ kind: "run", text: r, props: gt(s) }) : oe(G(s), t, n, o);
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
case "w:smartTag":
|
|
390
|
-
case "w:ins":
|
|
391
|
-
oe(G(s), t, n, o);
|
|
392
|
-
break;
|
|
393
|
-
case "w:del":
|
|
394
|
-
break;
|
|
395
|
-
case "w:bookmarkStart": {
|
|
396
|
-
const a = De(s), r = k(s, "w:id");
|
|
397
|
-
a && n.currentBookmarks && n.currentBookmarks.push(a), a && r && n.currentMarkers && n.currentMarkers.push({ id: r, name: a, kind: "start", offset: Le(t) });
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
case "w:bookmarkEnd": {
|
|
401
|
-
const a = k(s, "w:id");
|
|
402
|
-
a && n.currentMarkers && n.currentMarkers.push({ id: a, kind: "end", offset: Le(t) });
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function gt(e) {
|
|
408
|
-
const t = we(e, "w:r"), n = t && u(t, "w:rPr");
|
|
409
|
-
return n ? ie(n) : {};
|
|
410
|
-
}
|
|
411
|
-
function mt(e, t, n, o) {
|
|
412
|
-
const s = u(e, "w:rPr"), a = s ? ie(s) : {};
|
|
413
|
-
let r = "";
|
|
414
|
-
const i = () => {
|
|
415
|
-
r.length > 0 && (o.pagerefAnchor && a.linkAnchor === void 0 && a.linkRelId === void 0 && (a.linkAnchor = o.pagerefAnchor), t.push({ kind: "run", text: r, props: a })), r = "";
|
|
416
|
-
}, f = (p) => {
|
|
417
|
-
for (const d of p)
|
|
418
|
-
switch (d.tagName) {
|
|
419
|
-
case "w:t":
|
|
420
|
-
o.suppressResult || (r += ge(d));
|
|
421
|
-
break;
|
|
422
|
-
case "w:tab":
|
|
423
|
-
o.suppressResult || (r += " ");
|
|
424
|
-
break;
|
|
425
|
-
case "w:br": {
|
|
426
|
-
i();
|
|
427
|
-
const c = k(d, "w:type");
|
|
428
|
-
c === "page" ? t.push({ kind: "break", page: !0 }) : c === "column" ? t.push({ kind: "break", column: !0 }) : t.push({ kind: "break" });
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
case "w:cr":
|
|
432
|
-
i(), t.push({ kind: "break" });
|
|
433
|
-
break;
|
|
434
|
-
case "w:noBreakHyphen":
|
|
435
|
-
r += "‑";
|
|
436
|
-
break;
|
|
437
|
-
case "w:drawing": {
|
|
438
|
-
i();
|
|
439
|
-
const c = kt(d, n);
|
|
440
|
-
c && t.push(c);
|
|
441
|
-
break;
|
|
442
|
-
}
|
|
443
|
-
case "w:pict": {
|
|
444
|
-
i();
|
|
445
|
-
const c = bt(d, n);
|
|
446
|
-
c && t.push(c);
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
case "w:object":
|
|
450
|
-
n.warnings.add("objects-skipped", "Embedded OLE objects are not imported.");
|
|
451
|
-
break;
|
|
452
|
-
case "w:instrText":
|
|
453
|
-
if (o.depth > 0) {
|
|
454
|
-
o.instr += ge(d);
|
|
455
|
-
const c = ht(o.instr);
|
|
456
|
-
c && (o.pagerefAnchor = c);
|
|
457
|
-
}
|
|
458
|
-
n.trackFields && n.fieldTrack.depth === 1 && (n.fieldTrack.topInstr += ge(d));
|
|
459
|
-
break;
|
|
460
|
-
case "w:fldChar":
|
|
461
|
-
wt(d, a, t, n, o);
|
|
462
|
-
break;
|
|
463
|
-
case "mc:AlternateContent": {
|
|
464
|
-
const c = u(d, "mc:Choice") ?? u(d, "mc:Fallback");
|
|
465
|
-
c && f(G(c));
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
468
|
-
case "w:footnoteReference": {
|
|
469
|
-
const c = k(d, "w:id");
|
|
470
|
-
c !== void 0 && (i(), t.push({ kind: "run", text: "", props: { ...a, footnoteId: c } }));
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
f(G(e)), i();
|
|
476
|
-
}
|
|
477
|
-
function wt(e, t, n, o, s) {
|
|
478
|
-
const a = o.fieldTrack;
|
|
479
|
-
switch (k(e, "w:fldCharType")) {
|
|
480
|
-
case "begin":
|
|
481
|
-
s.depth++, s.depth === 1 && (s.instr = "", s.suppressResult = !1, s.pagerefAnchor = void 0), o.trackFields && (a.depth++, a.depth === 1 && (a.topInstr = "", a.openId = null));
|
|
482
|
-
break;
|
|
483
|
-
case "separate": {
|
|
484
|
-
if (o.trackFields && a.depth === 1 && Ee(o), s.depth !== 1) break;
|
|
485
|
-
const r = o.fieldTokens ? Te(s.instr) : void 0;
|
|
486
|
-
r && (n.push({ kind: "run", text: r, props: t }), s.suppressResult = !0);
|
|
487
|
-
break;
|
|
488
|
-
}
|
|
489
|
-
case "end":
|
|
490
|
-
if (o.trackFields && a.depth > 0 && (a.depth === 1 && (Ee(o), a.openId = null, a.topInstr = ""), a.depth--), s.depth > 0 && s.depth--, s.depth === 0) {
|
|
491
|
-
if (!s.suppressResult) {
|
|
492
|
-
const r = o.fieldTokens ? Te(s.instr) : void 0;
|
|
493
|
-
r && n.push({ kind: "run", text: r, props: t });
|
|
494
|
-
}
|
|
495
|
-
s.instr = "", s.suppressResult = !1, s.pagerefAnchor = void 0;
|
|
496
|
-
}
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
function kt(e, t) {
|
|
501
|
-
const n = u(e, "wp:anchor"), o = u(e, "wp:inline") ?? n;
|
|
502
|
-
if (!o) return;
|
|
503
|
-
const s = we(o, "a:blip"), a = s && k(s, "r:embed");
|
|
504
|
-
if (!a) {
|
|
505
|
-
t.warnings.add("images-skipped", "A drawing without an embedded image reference was skipped.");
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
const r = u(o, "wp:extent"), i = { kind: "image", relId: a, anchored: !!n }, f = T(r, "cx");
|
|
509
|
-
f !== void 0 && (i.widthEmu = f);
|
|
510
|
-
const p = T(r, "cy");
|
|
511
|
-
if (p !== void 0 && (i.heightEmu = p), n) {
|
|
512
|
-
const d = u(n, "wp:wrapSquare") ?? u(n, "wp:wrapTight") ?? u(n, "wp:wrapThrough");
|
|
513
|
-
i.anchorWrap = d ? "square" : "block", d || t.warnings.add(
|
|
514
|
-
"images-anchored",
|
|
515
|
-
"Some floating images (overlapping or top-and-bottom wrap) were placed in the text flow."
|
|
516
|
-
);
|
|
517
|
-
const c = u(n, "wp:positionH"), g = c && u(c, "wp:align"), w = g && ge(g);
|
|
518
|
-
(w === "left" || w === "right" || w === "center") && (i.anchorAlign = w);
|
|
519
|
-
}
|
|
520
|
-
return i;
|
|
521
|
-
}
|
|
522
|
-
function bt(e, t) {
|
|
523
|
-
const n = we(e, "v:imagedata"), o = n && k(n, "r:id");
|
|
524
|
-
if (!o) {
|
|
525
|
-
t.warnings.add("images-skipped", "A legacy picture without an image reference was skipped.");
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
const s = { kind: "image", relId: o, anchored: !1 }, a = we(e, "v:shape"), r = (a && k(a, "style")) ?? "", i = (d) => {
|
|
529
|
-
const c = r.match(new RegExp(`(?:^|;)\\s*${d}:([\\d.]+)pt`));
|
|
530
|
-
return c ? Number(c[1]) * 12700 : void 0;
|
|
531
|
-
}, f = i("width");
|
|
532
|
-
f !== void 0 && (s.widthEmu = f);
|
|
533
|
-
const p = i("height");
|
|
534
|
-
return p !== void 0 && (s.heightEmu = p), s;
|
|
535
|
-
}
|
|
536
|
-
function He(e) {
|
|
537
|
-
if (!e) return;
|
|
538
|
-
const t = (i) => T(u(e, i), "w:w"), n = {}, o = t("w:top");
|
|
539
|
-
o !== void 0 && (n.top = o);
|
|
540
|
-
const s = t("w:right");
|
|
541
|
-
s !== void 0 && (n.right = s);
|
|
542
|
-
const a = t("w:bottom");
|
|
543
|
-
a !== void 0 && (n.bottom = a);
|
|
544
|
-
const r = t("w:left");
|
|
545
|
-
return r !== void 0 && (n.left = r), Object.keys(n).length > 0 ? n : void 0;
|
|
546
|
-
}
|
|
547
|
-
function vt(e, t) {
|
|
548
|
-
const n = [];
|
|
549
|
-
for (const r of X(e, "w:tr")) {
|
|
550
|
-
const i = [];
|
|
551
|
-
for (const f of X(r, "w:tc"))
|
|
552
|
-
i.push(Tt(f, t));
|
|
553
|
-
n.push({ cells: i });
|
|
554
|
-
}
|
|
555
|
-
const o = { kind: "table", rows: n }, s = u(e, "w:tblGrid");
|
|
556
|
-
if (s) {
|
|
557
|
-
const r = X(s, "w:gridCol").map((i) => T(i, "w:w")).filter((i) => i !== void 0 && i > 0);
|
|
558
|
-
r.length > 0 && (o.colWidthsTwips = r);
|
|
559
|
-
}
|
|
560
|
-
const a = u(e, "w:tblPr");
|
|
561
|
-
if (a) {
|
|
562
|
-
const r = V(a, "w:tblStyle");
|
|
563
|
-
r && (o.styleId = r), u(a, "w:tblBorders") && (o.bordersSpecified = !0);
|
|
564
|
-
const i = Ie(u(a, "w:tblBorders"));
|
|
565
|
-
i && (o.borders = i);
|
|
566
|
-
const f = Se(u(a, "w:shd"));
|
|
567
|
-
f && (o.shd = f);
|
|
568
|
-
const p = He(u(a, "w:tblCellMar"));
|
|
569
|
-
p && (o.cellMarginTwips = p);
|
|
570
|
-
}
|
|
571
|
-
return o;
|
|
572
|
-
}
|
|
573
|
-
function Tt(e, t) {
|
|
574
|
-
const n = u(e, "w:tcPr"), o = (n && T(u(n, "w:gridSpan"), "w:val")) ?? 1, s = n && u(n, "w:vMerge"), a = !!s && (k(s, "w:val") ?? "continue") === "continue", r = [];
|
|
575
|
-
re(G(e), r, t);
|
|
576
|
-
const i = { blocks: r, gridSpan: o, vMergeContinue: a };
|
|
577
|
-
if (n) {
|
|
578
|
-
u(n, "w:tcBorders") && (i.bordersSpecified = !0);
|
|
579
|
-
const f = Ie(u(n, "w:tcBorders"));
|
|
580
|
-
f && (i.borders = f);
|
|
581
|
-
const p = Se(u(n, "w:shd"));
|
|
582
|
-
p && (i.shd = p);
|
|
583
|
-
const d = He(u(n, "w:tcMar"));
|
|
584
|
-
d && (i.marginTwips = d);
|
|
585
|
-
}
|
|
586
|
-
return i;
|
|
587
|
-
}
|
|
588
|
-
function Ue(e) {
|
|
589
|
-
if (!e) return null;
|
|
590
|
-
const t = { type: "richText" }, n = u(e, "w:alias"), o = n && k(n, "w:val");
|
|
591
|
-
o && (t.alias = o);
|
|
592
|
-
const s = u(e, "w:tag"), a = s && k(s, "w:val");
|
|
593
|
-
a && (t.tag = a), u(e, "w:text") && (t.type = "plainText");
|
|
594
|
-
const r = u(e, "w:dropDownList") ?? u(e, "w:comboBox");
|
|
595
|
-
r && (t.type = r.tagName === "w:dropDownList" ? "dropDown" : "comboBox", t.listItems = X(r, "w:listItem").map((c) => ({
|
|
596
|
-
display: k(c, "w:displayText") ?? k(c, "w:value") ?? "",
|
|
597
|
-
value: k(c, "w:value") ?? k(c, "w:displayText") ?? ""
|
|
598
|
-
})));
|
|
599
|
-
const i = u(e, "w:date");
|
|
600
|
-
if (i) {
|
|
601
|
-
t.type = "date";
|
|
602
|
-
const c = u(i, "w:dateFormat"), g = c && k(c, "w:val");
|
|
603
|
-
g && (t.dateFormat = g);
|
|
604
|
-
}
|
|
605
|
-
const f = u(e, "w14:checkbox");
|
|
606
|
-
if (f) {
|
|
607
|
-
t.type = "checkbox";
|
|
608
|
-
const c = u(f, "w14:checked"), g = c && k(c, "w14:val");
|
|
609
|
-
t.checked = g === "1" || g === "true";
|
|
610
|
-
}
|
|
611
|
-
u(e, "w:showingPlcHdr") && (t.placeholder = !0);
|
|
612
|
-
const p = u(e, "w:lock"), d = p && k(p, "w:val");
|
|
613
|
-
return (d === "contentLocked" || d === "sdtContentLocked") && (t.lockContent = !0), (d === "sdtLocked" || d === "sdtContentLocked") && (t.lockControl = !0), t;
|
|
614
|
-
}
|
|
615
|
-
function je(e, t) {
|
|
616
|
-
if (e.kind === "paragraph") {
|
|
617
|
-
for (const n of e.inlines)
|
|
618
|
-
n.kind === "run" && n.sdtId === void 0 && (n.sdtId = t);
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
for (const n of e.rows)
|
|
622
|
-
for (const o of n.cells) for (const s of o.blocks) je(s, t);
|
|
623
|
-
}
|
|
624
|
-
function yt(e, t) {
|
|
625
|
-
const n = {}, o = u(e, "w:pgSz"), s = T(o, "w:w");
|
|
626
|
-
s !== void 0 && (n.pageWidthTwips = s);
|
|
627
|
-
const a = T(o, "w:h");
|
|
628
|
-
a !== void 0 && (n.pageHeightTwips = a);
|
|
629
|
-
const r = u(e, "w:pgMar");
|
|
630
|
-
if (r) {
|
|
631
|
-
const c = T(r, "w:top"), g = T(r, "w:right"), w = T(r, "w:bottom"), B = T(r, "w:left");
|
|
632
|
-
c !== void 0 && g !== void 0 && w !== void 0 && B !== void 0 && (n.marginTwips = { top: c, right: g, bottom: w, left: B });
|
|
633
|
-
const C = T(r, "w:header");
|
|
634
|
-
C !== void 0 && (n.headerDistTwips = C);
|
|
635
|
-
const y = T(r, "w:footer");
|
|
636
|
-
y !== void 0 && (n.footerDistTwips = y);
|
|
637
|
-
}
|
|
638
|
-
const i = Ae(X(e, "w:headerReference"));
|
|
639
|
-
i && (n.headerRefs = i);
|
|
640
|
-
const f = Ae(X(e, "w:footerReference"));
|
|
641
|
-
f && (n.footerRefs = f), u(e, "w:titlePg") && (n.titlePg = !0);
|
|
642
|
-
const p = u(e, "w:cols");
|
|
643
|
-
if (p) {
|
|
644
|
-
const c = T(p, "w:num") ?? 1;
|
|
645
|
-
if (c > 1) {
|
|
646
|
-
n.columns = { count: c };
|
|
647
|
-
const g = T(p, "w:space");
|
|
648
|
-
g !== void 0 && (n.columns.spaceTwips = g);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
const d = T(u(e, "w:pgNumType"), "w:start");
|
|
652
|
-
return d !== void 0 && (n.pageNumberStart = d), n;
|
|
653
|
-
}
|
|
654
|
-
function Ae(e) {
|
|
655
|
-
if (e.length === 0) return;
|
|
656
|
-
const t = {};
|
|
657
|
-
for (const n of e) {
|
|
658
|
-
const o = k(n, "r:id");
|
|
659
|
-
if (!o) continue;
|
|
660
|
-
const s = k(n, "w:type") ?? "default";
|
|
661
|
-
s === "first" ? t.first = o : s === "even" ? t.even = o : t.default = o;
|
|
662
|
-
}
|
|
663
|
-
return Object.keys(t).length > 0 ? t : void 0;
|
|
664
|
-
}
|
|
665
|
-
function Pt(e, t, n, o = {}) {
|
|
666
|
-
const s = /* @__PURE__ */ new Map(), a = Z(J(e, t), "w:footnotes");
|
|
667
|
-
if (!a) return s;
|
|
668
|
-
const r = {
|
|
669
|
-
warnings: n,
|
|
670
|
-
fieldTokens: !1,
|
|
671
|
-
sdts: o,
|
|
672
|
-
nextSdt: { n: Object.keys(o).length },
|
|
673
|
-
pendingBookmarks: [],
|
|
674
|
-
currentBookmarks: null,
|
|
675
|
-
pendingMarkers: [],
|
|
676
|
-
currentMarkers: null,
|
|
677
|
-
trackFields: !1,
|
|
678
|
-
fieldTrack: xe()
|
|
679
|
-
};
|
|
680
|
-
for (const i of X(a, "w:footnote")) {
|
|
681
|
-
const f = k(i, "w:id");
|
|
682
|
-
if (f === void 0 || k(i, "w:type")) continue;
|
|
683
|
-
const d = [];
|
|
684
|
-
re(G(i), d, r), s.set(f, d);
|
|
685
|
-
}
|
|
686
|
-
return s;
|
|
687
|
-
}
|
|
688
|
-
const It = () => {
|
|
689
|
-
}, _e = {
|
|
690
|
-
fontFamily: "Times New Roman, serif",
|
|
691
|
-
fontSizePx: 16,
|
|
692
|
-
// 12pt
|
|
693
|
-
bold: !1,
|
|
694
|
-
italic: !1,
|
|
695
|
-
underline: !1,
|
|
696
|
-
strikethrough: !1,
|
|
697
|
-
color: "#000000"
|
|
698
|
-
}, St = {
|
|
699
|
-
align: "left",
|
|
700
|
-
lineHeight: 1,
|
|
701
|
-
spaceBeforePx: 0,
|
|
702
|
-
spaceAfterPx: 0,
|
|
703
|
-
indentFirstLinePx: 0,
|
|
704
|
-
indentLeftPx: 0
|
|
705
|
-
}, xt = { top: 0, right: 108, bottom: 0, left: 108 }, le = {
|
|
706
|
-
pageWidthPx: 816,
|
|
707
|
-
pageHeightPx: 1056,
|
|
708
|
-
marginPx: { top: 96, right: 96, bottom: 96, left: 96 }
|
|
709
|
-
};
|
|
710
|
-
function Rt(e, t, n = {}, o = /* @__PURE__ */ new Map(), s = () => ({}), a) {
|
|
711
|
-
let r = 0;
|
|
712
|
-
const i = () => `i${r++}`, f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), c = [], g = (l) => {
|
|
713
|
-
let h = d.get(l);
|
|
714
|
-
return h === void 0 && (h = String(d.size + 1), d.set(l, h), c.push(l)), h;
|
|
715
|
-
}, w = /* @__PURE__ */ new Map(), B = (l) => {
|
|
716
|
-
const h = w.get(l);
|
|
717
|
-
if (h) return h;
|
|
718
|
-
const R = o.get(l);
|
|
719
|
-
if (!R) return;
|
|
720
|
-
const L = Lt(R);
|
|
721
|
-
return w.set(l, L), L;
|
|
722
|
-
}, C = be(t.run(void 0, {})), y = Be(t.para({})), U = () => ({
|
|
723
|
-
kind: "paragraph",
|
|
724
|
-
id: i(),
|
|
725
|
-
revision: 0,
|
|
726
|
-
runs: [{ text: "", style: { ...C } }],
|
|
727
|
-
style: { ...y }
|
|
728
|
-
}), $ = (l, h) => {
|
|
729
|
-
if (!h) return 0;
|
|
730
|
-
const R = B(h.numId);
|
|
731
|
-
if (!R)
|
|
732
|
-
return e.add("list-missing", "A list reference had no matching definition — markers were dropped."), 0;
|
|
733
|
-
l.list = { listId: h.numId, level: h.level };
|
|
734
|
-
const L = R.levels[Math.min(h.level, R.levels.length - 1)], v = L ? L.indentLeftPx : 0;
|
|
735
|
-
return l.indentLeftPx = Math.max(0, S(l.indentLeftPx - v)), l.indentFirstLinePx = 0, v;
|
|
736
|
-
}, P = (l) => {
|
|
737
|
-
const h = l.sectionPgSize;
|
|
738
|
-
return !!h && !!a && (h.w !== a.w || h.h !== a.h);
|
|
739
|
-
}, K = (l) => P(l) || !!l.sectionColumns || l.sectionPageNumberStart !== void 0, z = (l) => {
|
|
740
|
-
const h = {};
|
|
741
|
-
return l.sectionPgSize && (h.pageWidthPx = S(N(l.sectionPgSize.w)), h.pageHeightPx = S(N(l.sectionPgSize.h))), l.sectionMarginTwips && (h.marginPx = ke(l.sectionMarginTwips)), l.sectionColumns && (h.columns = { count: l.sectionColumns.count, gapPx: S(N(l.sectionColumns.spaceTwips ?? 720)) }), l.sectionPageNumberStart !== void 0 && (h.pageNumberStart = l.sectionPageNumberStart), h;
|
|
742
|
-
}, ee = (l) => {
|
|
743
|
-
for (let h = l.length - 1; h >= 0; h--) if (l[h].kind === "paragraph") return l[h];
|
|
744
|
-
}, Y = (l, h, R = It) => {
|
|
745
|
-
const L = [];
|
|
746
|
-
let v = !1, x = !1, D = !1, I = !1;
|
|
747
|
-
const O = (E) => E.some((b) => b.kind !== "paragraph" || b.runs.some((m) => m.text.trim().length > 0 && !m.style.hidden));
|
|
748
|
-
let F = 0, _ = null;
|
|
749
|
-
const j = (E) => {
|
|
750
|
-
for (const b of E)
|
|
751
|
-
if (b.kind === "paragraph" && b.runs.some((m) => m.text.trim().length > 0 && !m.style.hidden)) return b;
|
|
752
|
-
}, A = (E) => {
|
|
753
|
-
for (let b = E + 1; b < l.length; b++) {
|
|
754
|
-
const m = l[b];
|
|
755
|
-
if (m.kind !== "paragraph") return !1;
|
|
756
|
-
if (m.inlines.some(
|
|
757
|
-
(H) => H.kind === "run" && H.text.trim().length > 0 && !H.props.vanish
|
|
758
|
-
))
|
|
759
|
-
return t.isHeading(m.props.styleId) ? !0 : (m.bookmarks ?? []).some((H) => /toc/i.test(H));
|
|
760
|
-
}
|
|
761
|
-
return !1;
|
|
762
|
-
};
|
|
763
|
-
for (let E = 0; E < l.length; E++) {
|
|
764
|
-
const b = l[E], m = b.kind === "paragraph" ? q(b, h, R) : [ce(b, h, R)];
|
|
765
|
-
if (b.fieldId) for (const M of m) M.fieldId = b.fieldId;
|
|
766
|
-
if (v && m.length > 0) {
|
|
767
|
-
const M = m[0];
|
|
768
|
-
M.kind === "paragraph" && M.runs.every((W) => W.text.length === 0 || W.style.hidden) || ((b.kind === "paragraph" && t.isHeading(b.props.styleId) || x) && (M.kind === "paragraph" ? M.style.pageBreakBefore = !0 : m.unshift({ ...U(), style: { ...y, pageBreakBefore: !0 } })), v = !1, x = !1);
|
|
769
|
-
}
|
|
770
|
-
if (b.kind === "paragraph" && b.props.sectionBreak === "page") {
|
|
771
|
-
const M = b.props;
|
|
772
|
-
if (K(M)) {
|
|
773
|
-
let H = ee(m);
|
|
774
|
-
H || (H = U(), m.push(H)), H.style.sectionBreak = { type: "nextPage", props: z(M) }, v = !1;
|
|
775
|
-
} else
|
|
776
|
-
M.sectionHasBands && e.add(
|
|
777
|
-
"section-bands-flattened",
|
|
778
|
-
"Per-section headers/footers on geometry-preserving section breaks were not applied (the document section's are used)."
|
|
779
|
-
), v = !0, x = !D && I || A(E), F > 0 && _ && A(F - 1) && (_.style.pageBreakBefore = !0);
|
|
780
|
-
D = !0;
|
|
781
|
-
}
|
|
782
|
-
b.kind === "paragraph" && b.props.sectionBreak !== void 0 ? (F = E + 1, _ = null) : _ || (_ = j(m) ?? null), L.push(...m), D || (I ||= O(m));
|
|
783
|
-
}
|
|
784
|
-
return Q(L), L;
|
|
785
|
-
}, Q = (l) => {
|
|
786
|
-
const h = (v) => v.kind === "image" || v.kind === "table", R = (v) => v.kind === "paragraph" && v.runs.every((x) => x.text.trim().length === 0 || x.style.hidden), L = (v) => v.kind === "paragraph" ? v.runs.reduce((x, D) => x + D.text.length, 0) : 0;
|
|
787
|
-
for (let v = 0; v < l.length; v++) {
|
|
788
|
-
const x = l[v];
|
|
789
|
-
if (x.kind !== "paragraph" || !x.style.namedStyle || !t.isHeading(x.style.namedStyle)) continue;
|
|
790
|
-
const D = [];
|
|
791
|
-
let I = 0, O = -1;
|
|
792
|
-
for (let F = v + 1; F < l.length && F <= v + 6; F++) {
|
|
793
|
-
const _ = l[F];
|
|
794
|
-
if (h(_)) {
|
|
795
|
-
O = F;
|
|
796
|
-
break;
|
|
797
|
-
}
|
|
798
|
-
if (_.kind !== "paragraph") break;
|
|
799
|
-
if (!R(_)) {
|
|
800
|
-
if (I >= 2 || L(_) > 300) break;
|
|
801
|
-
I++, D.push(_);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (!(O < 0)) {
|
|
805
|
-
x.style.keepWithNext = !0;
|
|
806
|
-
for (const F of D) F.style.keepWithNext = !0;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
function q(l, h, R) {
|
|
811
|
-
const L = t.para(l.props), v = Be(L), x = $(v, L.list), D = be(t.run(l.props.styleId, l.props.markRunProps ?? {})), I = [];
|
|
812
|
-
let O = [], F = !1, _ = !1, j = !1;
|
|
813
|
-
const A = (m) => {
|
|
814
|
-
const M = { ...v };
|
|
815
|
-
return _ && (M.pageBreakBefore = !0, _ = !1), j && (M.columnBreakBefore = !0, j = !1), {
|
|
816
|
-
kind: "paragraph",
|
|
817
|
-
id: i(),
|
|
818
|
-
revision: 0,
|
|
819
|
-
runs: Ze(m, D),
|
|
820
|
-
style: M
|
|
821
|
-
};
|
|
822
|
-
}, E = () => {
|
|
823
|
-
O.length !== 0 && (I.push(A(O)), O = []);
|
|
824
|
-
};
|
|
825
|
-
for (const m of l.inlines)
|
|
826
|
-
switch (m.kind) {
|
|
827
|
-
case "break":
|
|
828
|
-
!m.page && !m.column ? (e.add("soft-breaks", "Soft line breaks (Shift+Enter) became paragraph breaks."), O.length > 0 ? E() : I.push(A([]))) : (O.length > 0 && E(), m.page && (_ = !0), m.column && (j = !0)), F = !0;
|
|
829
|
-
break;
|
|
830
|
-
case "image": {
|
|
831
|
-
const M = te(m, h, v.align);
|
|
832
|
-
M && (E(), (_ || j) && I.push(A([])), I.push(M), F = !1);
|
|
833
|
-
break;
|
|
834
|
-
}
|
|
835
|
-
case "run": {
|
|
836
|
-
const M = t.run(l.props.styleId, m.props);
|
|
837
|
-
O.push(de(m.text, M, R, m.sdtId)), F = !1;
|
|
838
|
-
break;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
E(), (F || I.length === 0) && I.push(A([]));
|
|
842
|
-
const b = I.filter((m) => m.kind === "paragraph");
|
|
843
|
-
if (b.forEach((m, M) => {
|
|
844
|
-
M > 0 && (m.style.spaceBeforePx = 0), M < b.length - 1 && (m.style.spaceAfterPx = 0), M > 0 && m.style.list && (delete m.style.list, m.style.indentLeftPx = S(m.style.indentLeftPx + x));
|
|
845
|
-
}), l.bookmarkMarkers && l.bookmarkMarkers.length > 0 && I[0]) {
|
|
846
|
-
const m = I[0], M = m.kind === "paragraph" ? m.runs.reduce((H, W) => H + W.text.length, 0) : 0;
|
|
847
|
-
for (const H of l.bookmarkMarkers) {
|
|
848
|
-
const W = { blockId: m.id, offset: Math.min(H.offset, M) };
|
|
849
|
-
H.kind === "start" && H.name ? f.set(H.id, { name: H.name, pos: W }) : H.kind === "end" && p.set(H.id, W);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
return I;
|
|
853
|
-
}
|
|
854
|
-
function te(l, h, R) {
|
|
855
|
-
const L = h.resolve(l.relId);
|
|
856
|
-
if (!L) return;
|
|
857
|
-
if (l.widthEmu === void 0 || l.heightEmu === void 0) {
|
|
858
|
-
e.add("images-unsized", "An image without explicit dimensions was skipped.");
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
const v = {
|
|
862
|
-
kind: "image",
|
|
863
|
-
id: i(),
|
|
864
|
-
revision: 0,
|
|
865
|
-
src: L,
|
|
866
|
-
widthPx: S(Me(l.widthEmu)),
|
|
867
|
-
heightPx: S(Me(l.heightEmu)),
|
|
868
|
-
align: l.anchorAlign ?? (R === "justify" ? "left" : R)
|
|
869
|
-
};
|
|
870
|
-
return l.anchored && l.anchorWrap === "square" && (v.wrap = "square"), v;
|
|
871
|
-
}
|
|
872
|
-
function de(l, h, R, L) {
|
|
873
|
-
let v = l;
|
|
874
|
-
const x = be(h);
|
|
875
|
-
if (h.linkRelId) {
|
|
876
|
-
const D = R(h.linkRelId);
|
|
877
|
-
D ? x.link = D : e.add("links-unresolved", "A hyperlink target could not be resolved and was dropped.");
|
|
878
|
-
} else h.linkAnchor && (x.link = `#${h.linkAnchor}`);
|
|
879
|
-
if (h.footnoteId !== void 0 && (v = g(h.footnoteId), x.footnoteRef = `fn${h.footnoteId}`, x.verticalAlign = "super"), L) {
|
|
880
|
-
x.sdtId = L;
|
|
881
|
-
const D = n[L];
|
|
882
|
-
D?.type === "checkbox" && v.length > 0 && (v = D.checked ? "☒" : "☐", x.fontFamily = _e.fontFamily);
|
|
883
|
-
}
|
|
884
|
-
return { text: v, style: x };
|
|
885
|
-
}
|
|
886
|
-
function ae(l, h, R, L, v, x) {
|
|
887
|
-
const D = l.cell.rowSpan ?? 1, I = {
|
|
888
|
-
top: l.startRow === 0,
|
|
889
|
-
bottom: l.startRow + D - 1 === x - 1,
|
|
890
|
-
left: l.startCol === 0,
|
|
891
|
-
right: l.startCol + l.colSpan - 1 === v - 1
|
|
892
|
-
}, O = l.ir?.shd ?? h.shd ?? R.shd;
|
|
893
|
-
if (O && (l.cell.shading = O), L) {
|
|
894
|
-
const F = { cell: l.ir?.borders, table: h.borders, style: R.borders };
|
|
895
|
-
l.cell.borders = at(F, I);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
function ce(l, h, R) {
|
|
899
|
-
const L = (j) => {
|
|
900
|
-
const A = [];
|
|
901
|
-
for (const m of j.blocks)
|
|
902
|
-
m.kind === "paragraph" ? A.push(...q(m, h, R)) : A.push(ce(m, h, R));
|
|
903
|
-
const E = { id: i(), blocks: A.length > 0 ? A : [U()] };
|
|
904
|
-
j.gridSpan > 1 && (E.colSpan = j.gridSpan);
|
|
905
|
-
const b = (m) => j.marginTwips?.[m] ?? l.cellMarginTwips?.[m] ?? xt[m];
|
|
906
|
-
return E.margin = ke({ top: b("top"), right: b("right"), bottom: b("bottom"), left: b("left") }), E;
|
|
907
|
-
}, v = Math.max(1, ...l.rows.map((j) => j.cells.reduce((A, E) => A + Math.max(1, E.gridSpan), 0))), x = new Array(v), D = l.rows.map((j, A) => {
|
|
908
|
-
const E = [];
|
|
909
|
-
let b = 0;
|
|
910
|
-
for (const m of j.cells) {
|
|
911
|
-
if (b >= v) break;
|
|
912
|
-
const M = Math.max(1, Math.min(m.gridSpan, v - b));
|
|
913
|
-
if (m.vMergeContinue) {
|
|
914
|
-
const W = x[b];
|
|
915
|
-
W ? W.rowSpan = (W.rowSpan ?? 1) + 1 : e.add("cell-vmerge-orphan", "A merged-cell continuation had no cell above to extend."), b += M;
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
const H = L(m);
|
|
919
|
-
E.push({ cell: H, ir: m, startRow: A, startCol: b, colSpan: M });
|
|
920
|
-
for (let W = 0; W < M && b + W < v; W++) x[b + W] = H;
|
|
921
|
-
b += M;
|
|
922
|
-
}
|
|
923
|
-
for (; b < v; ) {
|
|
924
|
-
const m = { id: i(), blocks: [U()] };
|
|
925
|
-
E.push({ cell: m, ir: null, startRow: A, startCol: b, colSpan: 1 }), x[b] = m, b += 1;
|
|
926
|
-
}
|
|
927
|
-
return E;
|
|
928
|
-
}), I = l.styleId ? s(l.styleId) : {}, O = !!I.borders || !!l.borders || !!l.bordersSpecified || l.rows.some((j) => j.cells.some((A) => A.borders || A.bordersSpecified));
|
|
929
|
-
for (const j of D) for (const A of j) ae(A, l, I, O, v, l.rows.length);
|
|
930
|
-
const F = D.map((j) => ({ cells: j.map((A) => A.cell) })), _ = { kind: "table", id: i(), revision: 0, rows: F };
|
|
931
|
-
return _.colFractions = Ot(l.colWidthsTwips, v), _;
|
|
932
|
-
}
|
|
933
|
-
function fe(l) {
|
|
934
|
-
if (!l) return { ...le, marginPx: { ...le.marginPx } };
|
|
935
|
-
const h = {
|
|
936
|
-
pageWidthPx: l.pageWidthTwips !== void 0 ? S(N(l.pageWidthTwips)) : le.pageWidthPx,
|
|
937
|
-
pageHeightPx: l.pageHeightTwips !== void 0 ? S(N(l.pageHeightTwips)) : le.pageHeightPx,
|
|
938
|
-
marginPx: l.marginTwips ? ke(l.marginTwips) : { ...le.marginPx }
|
|
939
|
-
};
|
|
940
|
-
return l.columns && (h.columns = { count: l.columns.count, gapPx: S(N(l.columns.spaceTwips ?? 720)) }), l.pageNumberStart !== void 0 && (h.pageNumberStart = l.pageNumberStart), l.headerDistTwips !== void 0 && (h.headerDistancePx = S(N(l.headerDistTwips))), l.footerDistTwips !== void 0 && (h.footerDistancePx = S(N(l.footerDistTwips))), h;
|
|
941
|
-
}
|
|
942
|
-
return {
|
|
943
|
-
mapBlocks: Y,
|
|
944
|
-
mapSection: fe,
|
|
945
|
-
emptyParagraph: U,
|
|
946
|
-
lists: () => Object.fromEntries(w),
|
|
947
|
-
bookmarks: () => {
|
|
948
|
-
const l = {};
|
|
949
|
-
for (const [h, R] of f)
|
|
950
|
-
l[R.name] = { start: R.pos, end: p.get(h) ?? R.pos };
|
|
951
|
-
return l;
|
|
952
|
-
},
|
|
953
|
-
footnoteRefs: () => c.map((l) => ({ docxId: l, noteId: `fn${l}` }))
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
const Mt = {
|
|
957
|
-
decimal: "decimal",
|
|
958
|
-
decimalZero: "decimal",
|
|
959
|
-
lowerLetter: "lowerLetter",
|
|
960
|
-
upperLetter: "upperLetter",
|
|
961
|
-
lowerRoman: "lowerRoman",
|
|
962
|
-
upperRoman: "upperRoman",
|
|
963
|
-
bullet: "bullet"
|
|
964
|
-
};
|
|
965
|
-
function Et(e) {
|
|
966
|
-
if (e.length !== 1) return e;
|
|
967
|
-
switch (e.charCodeAt(0)) {
|
|
968
|
-
case 61623:
|
|
969
|
-
// Symbol (filled round bullet)
|
|
970
|
-
case 183:
|
|
971
|
-
return "•";
|
|
972
|
-
// •
|
|
973
|
-
case 61607:
|
|
974
|
-
// Wingdings (filled square)
|
|
975
|
-
case 167:
|
|
976
|
-
return "▪";
|
|
977
|
-
// ▪
|
|
978
|
-
case 61551:
|
|
979
|
-
return "▫";
|
|
980
|
-
// ▫
|
|
981
|
-
case 61656:
|
|
982
|
-
return "‣";
|
|
983
|
-
// ‣
|
|
984
|
-
case 61692:
|
|
985
|
-
return "✔";
|
|
986
|
-
// ✔
|
|
987
|
-
default:
|
|
988
|
-
return e;
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
function Lt(e) {
|
|
992
|
-
const t = [];
|
|
993
|
-
for (let n = 0; n < 9; n++)
|
|
994
|
-
t.push(At(e.levels[n], n));
|
|
995
|
-
return { id: e.id, levels: t };
|
|
996
|
-
}
|
|
997
|
-
function At(e, t) {
|
|
998
|
-
if (!e)
|
|
999
|
-
return { format: "decimal", text: `%${t + 1}.`, indentLeftPx: 24 + t * 24, hangingPx: 18, start: 1 };
|
|
1000
|
-
const n = Mt[e.format] ?? (e.format === "none" ? "bullet" : "decimal"), o = {
|
|
1001
|
-
format: n,
|
|
1002
|
-
text: n === "bullet" ? "" : e.lvlText,
|
|
1003
|
-
indentLeftPx: e.indentLeftTwips !== void 0 ? S(N(e.indentLeftTwips)) : 24 + t * 24,
|
|
1004
|
-
hangingPx: e.hangingTwips !== void 0 ? S(N(e.hangingTwips)) : 18,
|
|
1005
|
-
start: e.start
|
|
1006
|
-
};
|
|
1007
|
-
if (n === "bullet" && (o.bulletChar = e.format === "none" ? "" : Et(e.lvlText)), e.markerRunProps) {
|
|
1008
|
-
const s = $e(e.markerRunProps);
|
|
1009
|
-
Object.keys(s).length > 0 && (o.markerStyle = s);
|
|
1010
|
-
}
|
|
1011
|
-
return o;
|
|
1012
|
-
}
|
|
1013
|
-
const Bt = {
|
|
1014
|
-
left: "left",
|
|
1015
|
-
start: "left",
|
|
1016
|
-
num: "left",
|
|
1017
|
-
center: "center",
|
|
1018
|
-
right: "right",
|
|
1019
|
-
end: "right",
|
|
1020
|
-
decimal: "decimal"
|
|
1021
|
-
}, Ct = {
|
|
1022
|
-
dot: "dot",
|
|
1023
|
-
middleDot: "dot",
|
|
1024
|
-
hyphen: "dash",
|
|
1025
|
-
underscore: "underscore"
|
|
1026
|
-
};
|
|
1027
|
-
function ze(e) {
|
|
1028
|
-
const t = e.map((n) => {
|
|
1029
|
-
const o = { posPx: S(N(n.posTwips)) }, s = n.val ? Bt[n.val] : void 0;
|
|
1030
|
-
s && s !== "left" && (o.align = s);
|
|
1031
|
-
const a = n.leader ? Ct[n.leader] : void 0;
|
|
1032
|
-
return a && (o.leader = a), o;
|
|
1033
|
-
});
|
|
1034
|
-
return t.sort((n, o) => n.posPx - o.posPx), t;
|
|
1035
|
-
}
|
|
1036
|
-
function Ot(e, t) {
|
|
1037
|
-
const n = e && e.length === t && e.reduce((o, s) => o + s, 0) > 0 ? e.map((o) => Math.round(o / e.reduce((s, a) => s + a, 0) * 1e4) / 1e4) : Array.from({ length: t }, () => Math.round(1 / t * 1e4) / 1e4);
|
|
1038
|
-
return n[n.length - 1] = Math.round((1 - n.slice(0, -1).reduce((o, s) => o + s, 0)) * 1e4) / 1e4, n;
|
|
1039
|
-
}
|
|
1040
|
-
const Ft = {
|
|
1041
|
-
yellow: "#ffff00",
|
|
1042
|
-
green: "#00ff00",
|
|
1043
|
-
cyan: "#00ffff",
|
|
1044
|
-
magenta: "#ff00ff",
|
|
1045
|
-
blue: "#0000ff",
|
|
1046
|
-
red: "#ff0000",
|
|
1047
|
-
darkBlue: "#000080",
|
|
1048
|
-
darkCyan: "#008080",
|
|
1049
|
-
darkGreen: "#008000",
|
|
1050
|
-
darkMagenta: "#800080",
|
|
1051
|
-
darkRed: "#800000",
|
|
1052
|
-
darkYellow: "#808000",
|
|
1053
|
-
darkGray: "#808080",
|
|
1054
|
-
lightGray: "#c0c0c0",
|
|
1055
|
-
black: "#000000",
|
|
1056
|
-
white: "#ffffff"
|
|
1057
|
-
};
|
|
1058
|
-
function be(e) {
|
|
1059
|
-
const t = { ..._e };
|
|
1060
|
-
return We(t, e), t;
|
|
1061
|
-
}
|
|
1062
|
-
function We(e, t) {
|
|
1063
|
-
if (t.fontAscii && (e.fontFamily = `${t.fontAscii}, serif`), t.sizeHalfPoints !== void 0 && (e.fontSizePx = S(ot(t.sizeHalfPoints))), t.bold !== void 0 && (e.bold = t.bold), t.italic !== void 0 && (e.italic = t.italic), t.underline !== void 0 && (e.underline = t.underline), t.strikethrough !== void 0 && (e.strikethrough = t.strikethrough), t.color && t.color !== "auto" && (e.color = `#${t.color.toLowerCase()}`), t.highlight) {
|
|
1064
|
-
const n = Ft[t.highlight];
|
|
1065
|
-
n && (e.highlightColor = n);
|
|
1066
|
-
}
|
|
1067
|
-
t.vertAlign === "superscript" ? e.verticalAlign = "super" : t.vertAlign === "subscript" && (e.verticalAlign = "sub"), t.vanish && (e.hidden = !0);
|
|
1068
|
-
}
|
|
1069
|
-
function Nt(e) {
|
|
1070
|
-
const t = {};
|
|
1071
|
-
for (const [n, o] of Object.entries(e)) {
|
|
1072
|
-
const s = { type: o.type };
|
|
1073
|
-
o.alias !== void 0 && (s.alias = o.alias), o.tag !== void 0 && (s.tag = o.tag), o.placeholder && (s.placeholder = !0), o.listItems !== void 0 && (s.listItems = o.listItems), o.dateFormat !== void 0 && (s.dateFormat = o.dateFormat), o.checked !== void 0 && (s.checked = o.checked), o.lockContent && (s.lockContent = !0), o.lockControl && (s.lockControl = !0), t[n] = s;
|
|
1074
|
-
}
|
|
1075
|
-
return t;
|
|
1076
|
-
}
|
|
1077
|
-
function Ge(e, t = /* @__PURE__ */ new Set()) {
|
|
1078
|
-
for (const n of e)
|
|
1079
|
-
if (n.kind === "paragraph")
|
|
1080
|
-
n.props.styleId && t.add(n.props.styleId);
|
|
1081
|
-
else
|
|
1082
|
-
for (const o of n.rows) for (const s of o.cells) Ge(s.blocks, t);
|
|
1083
|
-
return t;
|
|
1084
|
-
}
|
|
1085
|
-
function $e(e) {
|
|
1086
|
-
const t = {};
|
|
1087
|
-
return We(t, e), t;
|
|
1088
|
-
}
|
|
1089
|
-
function Dt(e) {
|
|
1090
|
-
const t = {};
|
|
1091
|
-
return e.align && (t.align = e.align), e.lineHeight !== void 0 && (t.lineHeight = S(e.lineHeight)), e.spaceBeforeTwips !== void 0 && (t.spaceBeforePx = S(N(e.spaceBeforeTwips))), e.spaceAfterTwips !== void 0 && (t.spaceAfterPx = S(N(e.spaceAfterTwips))), e.indentLeftTwips !== void 0 && (t.indentLeftPx = S(N(e.indentLeftTwips))), e.indentRightTwips !== void 0 && (t.indentRightPx = S(N(e.indentRightTwips))), e.indentFirstLineTwips !== void 0 && (t.indentFirstLinePx = S(N(e.indentFirstLineTwips))), e.keepWithNext && (t.keepWithNext = !0), e.keepLinesTogether && (t.keepLinesTogether = !0), e.tabStops && (t.tabStops = ze(e.tabStops)), t;
|
|
1092
|
-
}
|
|
1093
|
-
function Ht(e, t) {
|
|
1094
|
-
if (e.styles.size === 0) return;
|
|
1095
|
-
const n = /* @__PURE__ */ new Set(), o = (a) => {
|
|
1096
|
-
for (let r = e.styles.get(a); r && !n.has(r.id); r = r.basedOnId ? e.styles.get(r.basedOnId) : void 0)
|
|
1097
|
-
r.type === "paragraph" && n.add(r.id);
|
|
1098
|
-
};
|
|
1099
|
-
for (const a of t) o(a);
|
|
1100
|
-
if (e.defaultParaStyleId && o(e.defaultParaStyleId), n.size === 0) return;
|
|
1101
|
-
const s = [];
|
|
1102
|
-
for (const a of n) {
|
|
1103
|
-
const r = e.styles.get(a), i = {
|
|
1104
|
-
id: a,
|
|
1105
|
-
name: r.name ?? a,
|
|
1106
|
-
char: $e(r.rPr),
|
|
1107
|
-
para: Dt(r.pPr)
|
|
1108
|
-
};
|
|
1109
|
-
r.basedOnId && n.has(r.basedOnId) && (i.basedOn = r.basedOnId), s.push(i);
|
|
1110
|
-
}
|
|
1111
|
-
return s.sort(
|
|
1112
|
-
(a, r) => a.id === e.defaultParaStyleId ? -1 : r.id === e.defaultParaStyleId ? 1 : a.name.localeCompare(r.name)
|
|
1113
|
-
), { styles: s, defaultStyleId: e.defaultParaStyleId ?? s[0].id };
|
|
1114
|
-
}
|
|
1115
|
-
function Be(e) {
|
|
1116
|
-
const t = { ...St };
|
|
1117
|
-
return e.align && (t.align = e.align), e.lineHeight !== void 0 && (t.lineHeight = S(e.lineHeight)), e.spaceBeforeTwips !== void 0 && (t.spaceBeforePx = S(N(e.spaceBeforeTwips))), e.spaceAfterTwips !== void 0 && (t.spaceAfterPx = S(N(e.spaceAfterTwips))), e.indentLeftTwips !== void 0 && (t.indentLeftPx = S(N(e.indentLeftTwips))), e.indentRightTwips !== void 0 && (t.indentRightPx = S(N(e.indentRightTwips))), e.indentFirstLineTwips !== void 0 && (t.indentFirstLinePx = S(N(e.indentFirstLineTwips))), e.keepWithNext && (t.keepWithNext = !0), e.keepLinesTogether && (t.keepLinesTogether = !0), e.tabStops && (t.tabStops = ze(e.tabStops)), e.pageBreakBefore && (t.pageBreakBefore = !0), e.outlineLevel !== void 0 && (t.outlineLevel = e.outlineLevel), e.styleId && (t.namedStyle = e.styleId), t;
|
|
1118
|
-
}
|
|
1119
|
-
const Ut = {
|
|
1120
|
-
png: "image/png",
|
|
1121
|
-
jpg: "image/jpeg",
|
|
1122
|
-
jpeg: "image/jpeg",
|
|
1123
|
-
gif: "image/gif",
|
|
1124
|
-
bmp: "image/bmp",
|
|
1125
|
-
webp: "image/webp",
|
|
1126
|
-
svg: "image/svg+xml"
|
|
1127
|
-
};
|
|
1128
|
-
function jt(e, t, n, o) {
|
|
1129
|
-
const s = /* @__PURE__ */ new Map(), a = [];
|
|
1130
|
-
return {
|
|
1131
|
-
resolve(r) {
|
|
1132
|
-
const i = t.get(r);
|
|
1133
|
-
if (!i) {
|
|
1134
|
-
n.add("media-missing", "An image reference had no matching relationship — skipped.");
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
if (s.has(i.target)) return s.get(i.target);
|
|
1138
|
-
if (i.external) {
|
|
1139
|
-
const c = /^https?:\/\//i.test(i.target);
|
|
1140
|
-
c ? n.add("media-external", "Linked (external) images load from their original URL.") : n.add(
|
|
1141
|
-
"media-external-unreachable",
|
|
1142
|
-
"Linked images pointing at local files can't be loaded in the browser — skipped."
|
|
1143
|
-
);
|
|
1144
|
-
const g = c ? i.target : void 0;
|
|
1145
|
-
return s.set(i.target, g), g;
|
|
1146
|
-
}
|
|
1147
|
-
let f;
|
|
1148
|
-
const p = i.target.slice(i.target.lastIndexOf(".") + 1).toLowerCase(), d = Ut[p];
|
|
1149
|
-
if (!d)
|
|
1150
|
-
n.add(
|
|
1151
|
-
"media-unsupported",
|
|
1152
|
-
`Some images use formats browsers can't display (.${p}, typically metafiles) — skipped.`
|
|
1153
|
-
);
|
|
1154
|
-
else {
|
|
1155
|
-
const c = e.part(i.target);
|
|
1156
|
-
if (!c)
|
|
1157
|
-
n.add("media-missing", "An image reference had no matching relationship — skipped.");
|
|
1158
|
-
else {
|
|
1159
|
-
const g = new Uint8Array(c);
|
|
1160
|
-
o ? f = o.add(g, d) : (f = URL.createObjectURL(new Blob([g], { type: d })), a.push(f));
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
return s.set(i.target, f), f;
|
|
1164
|
-
},
|
|
1165
|
-
urls: () => [...a]
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
const _t = /* @__PURE__ */ new Map();
|
|
1169
|
-
function zt(e) {
|
|
1170
|
-
const t = /* @__PURE__ */ new Map(), n = Z(J(e, "numbering.xml"), "w:numbering");
|
|
1171
|
-
if (!n) return t;
|
|
1172
|
-
const o = /* @__PURE__ */ new Map();
|
|
1173
|
-
for (const s of X(n, "w:abstractNum")) {
|
|
1174
|
-
const a = k(s, "w:abstractNumId");
|
|
1175
|
-
a !== void 0 && o.set(a, Wt(s));
|
|
1176
|
-
}
|
|
1177
|
-
for (const s of X(n, "w:num")) {
|
|
1178
|
-
const a = k(s, "w:numId");
|
|
1179
|
-
if (a === void 0) continue;
|
|
1180
|
-
const r = V(s, "w:abstractNumId"), i = r !== void 0 ? o.get(r) : void 0;
|
|
1181
|
-
if (!i) continue;
|
|
1182
|
-
const f = i.map((p) => ({ ...p }));
|
|
1183
|
-
for (const p of X(s, "w:lvlOverride")) {
|
|
1184
|
-
const d = T(p, "w:ilvl") ?? 0, c = T(u(p, "w:startOverride"), "w:val"), g = u(p, "w:lvl");
|
|
1185
|
-
g && f[d] && (f[d] = Xe(g, d)), c !== void 0 && f[d] && (f[d].start = c);
|
|
1186
|
-
}
|
|
1187
|
-
t.set(a, { id: a, levels: f });
|
|
1188
|
-
}
|
|
1189
|
-
return t;
|
|
1190
|
-
}
|
|
1191
|
-
function Wt(e) {
|
|
1192
|
-
const t = [];
|
|
1193
|
-
for (const n of X(e, "w:lvl")) {
|
|
1194
|
-
const o = T(n, "w:ilvl") ?? t.length;
|
|
1195
|
-
t[o] = Xe(n, o);
|
|
1196
|
-
}
|
|
1197
|
-
return t;
|
|
1198
|
-
}
|
|
1199
|
-
function Xe(e, t) {
|
|
1200
|
-
const n = u(e, "w:lvlText"), o = {
|
|
1201
|
-
format: V(e, "w:numFmt") ?? "decimal",
|
|
1202
|
-
lvlText: n ? k(n, "w:val") ?? "" : `%${t + 1}.`,
|
|
1203
|
-
start: T(u(e, "w:start"), "w:val") ?? 1
|
|
1204
|
-
}, s = u(e, "w:pPr"), a = s && u(s, "w:ind");
|
|
1205
|
-
if (a) {
|
|
1206
|
-
const i = T(a, "w:left") ?? T(a, "w:start");
|
|
1207
|
-
i !== void 0 && (o.indentLeftTwips = i);
|
|
1208
|
-
const f = T(a, "w:hanging");
|
|
1209
|
-
f !== void 0 && (o.hangingTwips = f);
|
|
1210
|
-
}
|
|
1211
|
-
const r = u(e, "w:rPr");
|
|
1212
|
-
return r && (o.markerRunProps = ie(r)), o;
|
|
1213
|
-
}
|
|
1214
|
-
function Gt(e, t) {
|
|
1215
|
-
const n = t.includes("/") ? t.slice(0, t.lastIndexOf("/")) : "", o = /* @__PURE__ */ new Map(), s = Z(J(e, `${t} rels`), "Relationships");
|
|
1216
|
-
if (!s) return o;
|
|
1217
|
-
for (const a of G(s)) {
|
|
1218
|
-
if (a.tagName !== "Relationship") continue;
|
|
1219
|
-
const r = k(a, "Id"), i = k(a, "Type"), f = k(a, "Target");
|
|
1220
|
-
if (!r || !i || !f) continue;
|
|
1221
|
-
const p = k(a, "TargetMode") === "External";
|
|
1222
|
-
o.set(r, { id: r, type: i, target: p ? f : $t(n, f), external: p });
|
|
1223
|
-
}
|
|
1224
|
-
return o;
|
|
1225
|
-
}
|
|
1226
|
-
function $t(e, t) {
|
|
1227
|
-
if (t.startsWith("/")) return t.slice(1);
|
|
1228
|
-
const n = e === "" ? [] : e.split("/");
|
|
1229
|
-
for (const o of t.split("/"))
|
|
1230
|
-
o === ".." ? n.pop() : o !== "." && o !== "" && n.push(o);
|
|
1231
|
-
return n.join("/");
|
|
1232
|
-
}
|
|
1233
|
-
function Ve(e, t) {
|
|
1234
|
-
for (const n of e.values())
|
|
1235
|
-
if (n.type.endsWith(`/${t}`)) return n;
|
|
1236
|
-
}
|
|
1237
|
-
function Xt(e) {
|
|
1238
|
-
const t = e.lastIndexOf("/"), n = t >= 0 ? e.slice(0, t + 1) : "", o = t >= 0 ? e.slice(t + 1) : e;
|
|
1239
|
-
return `${n}_rels/${o}.rels`;
|
|
1240
|
-
}
|
|
1241
|
-
const Vt = { colors: /* @__PURE__ */ new Map() }, Yt = {
|
|
1242
|
-
dark1: "dk1",
|
|
1243
|
-
light1: "lt1",
|
|
1244
|
-
dark2: "dk2",
|
|
1245
|
-
light2: "lt2",
|
|
1246
|
-
text1: "dk1",
|
|
1247
|
-
background1: "lt1",
|
|
1248
|
-
text2: "dk2",
|
|
1249
|
-
background2: "lt2",
|
|
1250
|
-
hyperlink: "hlink",
|
|
1251
|
-
followedHyperlink: "folHlink"
|
|
1252
|
-
};
|
|
1253
|
-
function Kt(e, t) {
|
|
1254
|
-
return e.colors.get(Yt[t] ?? t);
|
|
1255
|
-
}
|
|
1256
|
-
function qt(e, t) {
|
|
1257
|
-
if (t.startsWith("major")) return e.majorLatin;
|
|
1258
|
-
if (t.startsWith("minor")) return e.minorLatin;
|
|
1259
|
-
}
|
|
1260
|
-
function Zt(e) {
|
|
1261
|
-
const t = { colors: /* @__PURE__ */ new Map() }, n = Z(J(e, "theme"), "a:theme"), o = n && u(n, "a:themeElements");
|
|
1262
|
-
if (!o) return t;
|
|
1263
|
-
const s = u(o, "a:fontScheme");
|
|
1264
|
-
if (s) {
|
|
1265
|
-
const r = Ce(u(s, "a:majorFont"));
|
|
1266
|
-
r && (t.majorLatin = r);
|
|
1267
|
-
const i = Ce(u(s, "a:minorFont"));
|
|
1268
|
-
i && (t.minorLatin = i);
|
|
1269
|
-
}
|
|
1270
|
-
const a = u(o, "a:clrScheme");
|
|
1271
|
-
if (a)
|
|
1272
|
-
for (const r of G(a)) {
|
|
1273
|
-
const i = r.tagName.replace(/^a:/, ""), f = u(r, "a:srgbClr"), p = u(r, "a:sysClr"), d = (f && k(f, "val")) ?? (p && k(p, "lastClr"));
|
|
1274
|
-
d && t.colors.set(i, d);
|
|
1275
|
-
}
|
|
1276
|
-
return t;
|
|
1277
|
-
}
|
|
1278
|
-
function Ce(e) {
|
|
1279
|
-
const t = e && u(e, "a:latin");
|
|
1280
|
-
return t && k(t, "typeface") || void 0;
|
|
1281
|
-
}
|
|
1282
|
-
const Qt = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() };
|
|
1283
|
-
function Jt(e, t) {
|
|
1284
|
-
const n = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() }, o = Z(J(e, "styles.xml"), "w:styles");
|
|
1285
|
-
if (!o) return n;
|
|
1286
|
-
const s = u(o, "w:docDefaults");
|
|
1287
|
-
if (s) {
|
|
1288
|
-
const a = u(s, "w:rPrDefault"), r = a && u(a, "w:rPr");
|
|
1289
|
-
r && (n.docDefaultsRun = ie(r));
|
|
1290
|
-
const i = u(s, "w:pPrDefault"), f = i && u(i, "w:pPr");
|
|
1291
|
-
f && (n.docDefaultsPara = ve(f, t));
|
|
1292
|
-
}
|
|
1293
|
-
for (const a of X(o, "w:style")) {
|
|
1294
|
-
const r = k(a, "w:styleId"), i = k(a, "w:type");
|
|
1295
|
-
if (!r || !i) continue;
|
|
1296
|
-
const f = u(a, "w:rPr"), p = u(a, "w:pPr"), d = {
|
|
1297
|
-
id: r,
|
|
1298
|
-
type: i,
|
|
1299
|
-
rPr: f ? ie(f) : {},
|
|
1300
|
-
pPr: p ? ve(p, t) : {}
|
|
1301
|
-
}, c = V(a, "w:name");
|
|
1302
|
-
c && (d.name = c);
|
|
1303
|
-
const g = V(a, "w:basedOn");
|
|
1304
|
-
if (g && (d.basedOnId = g), i === "table") {
|
|
1305
|
-
const B = u(a, "w:tblPr");
|
|
1306
|
-
if (B) {
|
|
1307
|
-
const C = Ie(u(B, "w:tblBorders"));
|
|
1308
|
-
C && (d.tblBorders = C);
|
|
1309
|
-
const y = Se(u(B, "w:shd"));
|
|
1310
|
-
y && (d.tblShd = y);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
n.styles.set(r, d);
|
|
1314
|
-
const w = k(a, "w:default");
|
|
1315
|
-
i === "paragraph" && (w === "1" || w === "true") && (n.defaultParaStyleId = r);
|
|
1316
|
-
}
|
|
1317
|
-
return n;
|
|
1318
|
-
}
|
|
1319
|
-
function en(e, t) {
|
|
1320
|
-
let n, o;
|
|
1321
|
-
const s = /* @__PURE__ */ new Set(), a = [];
|
|
1322
|
-
for (let i = e.styles.get(t); i && !s.has(i.id); i = i.basedOnId ? e.styles.get(i.basedOnId) : void 0)
|
|
1323
|
-
s.add(i.id), a.unshift(i);
|
|
1324
|
-
for (const i of a)
|
|
1325
|
-
n = rt(n, i.tblBorders), i.tblShd !== void 0 && (o = i.tblShd);
|
|
1326
|
-
const r = {};
|
|
1327
|
-
return n && (r.borders = n), o !== void 0 && (r.shd = o), r;
|
|
1328
|
-
}
|
|
1329
|
-
const tn = ["bold", "italic", "strikethrough", "vanish"];
|
|
1330
|
-
function nn(e, t) {
|
|
1331
|
-
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (d) => {
|
|
1332
|
-
const c = [], g = /* @__PURE__ */ new Set();
|
|
1333
|
-
for (let w = e.styles.get(d); w && !g.has(w.id); w = w.basedOnId ? e.styles.get(w.basedOnId) : void 0)
|
|
1334
|
-
g.add(w.id), c.unshift(w);
|
|
1335
|
-
return c;
|
|
1336
|
-
}, a = (d) => {
|
|
1337
|
-
let c = n.get(d);
|
|
1338
|
-
return c || (c = s(d).reduce((g, w) => pe(g, w.rPr), {}), n.set(d, c)), c;
|
|
1339
|
-
}, r = (d) => {
|
|
1340
|
-
let c = o.get(d);
|
|
1341
|
-
return c || (c = s(d).reduce((g, w) => me(g, w.pPr), {}), o.set(d, c)), c;
|
|
1342
|
-
}, i = /* @__PURE__ */ new Map(), f = (d, c) => {
|
|
1343
|
-
const g = `${d ?? ""}|${c ?? ""}`;
|
|
1344
|
-
let w = i.get(g);
|
|
1345
|
-
if (w) return w;
|
|
1346
|
-
const B = d ? a(d) : {}, C = c ? a(c) : {};
|
|
1347
|
-
w = pe(pe(e.docDefaultsRun, B), C);
|
|
1348
|
-
for (const y of tn) {
|
|
1349
|
-
if (e.docDefaultsRun[y] === void 0 && B[y] === void 0 && C[y] === void 0) continue;
|
|
1350
|
-
const U = e.docDefaultsRun[y] ?? !1;
|
|
1351
|
-
w[y] = U !== (B[y] === !0) != (C[y] === !0);
|
|
1352
|
-
}
|
|
1353
|
-
return i.set(g, w), w;
|
|
1354
|
-
};
|
|
1355
|
-
return {
|
|
1356
|
-
run(d, c) {
|
|
1357
|
-
const g = d ?? e.defaultParaStyleId, w = f(g, c.styleId);
|
|
1358
|
-
return p(pe(w, c));
|
|
1359
|
-
},
|
|
1360
|
-
para(d) {
|
|
1361
|
-
const c = d.styleId ?? e.defaultParaStyleId, g = c ? r(c) : {}, w = me(me(e.docDefaultsPara, g), d);
|
|
1362
|
-
return d.styleId ? w.styleId = d.styleId : delete w.styleId, w;
|
|
1363
|
-
},
|
|
1364
|
-
isHeading(d) {
|
|
1365
|
-
if (!d) return !1;
|
|
1366
|
-
const c = (g) => g !== void 0 && /(^|\s)heading(\s|\d|$)/i.test(g);
|
|
1367
|
-
return s(d).some((g) => c(g.name) || c(g.id));
|
|
1368
|
-
}
|
|
1369
|
-
};
|
|
1370
|
-
function p(d) {
|
|
1371
|
-
const c = { ...d };
|
|
1372
|
-
if (!c.fontAscii && c.fontThemeAscii) {
|
|
1373
|
-
const g = qt(t, c.fontThemeAscii);
|
|
1374
|
-
g && (c.fontAscii = g);
|
|
1375
|
-
}
|
|
1376
|
-
if ((c.color === void 0 || c.color === "auto") && c.colorTheme) {
|
|
1377
|
-
const g = Kt(t, c.colorTheme);
|
|
1378
|
-
g && (c.color = g);
|
|
1379
|
-
}
|
|
1380
|
-
return c;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
function pe(e, t) {
|
|
1384
|
-
const n = { ...e };
|
|
1385
|
-
return (t.fontAscii !== void 0 || t.fontThemeAscii !== void 0) && (delete n.fontAscii, delete n.fontThemeAscii), (t.color !== void 0 || t.colorTheme !== void 0) && (delete n.color, delete n.colorTheme), me(n, t);
|
|
1386
|
-
}
|
|
1387
|
-
function me(e, t) {
|
|
1388
|
-
const n = { ...e };
|
|
1389
|
-
for (const [o, s] of Object.entries(t))
|
|
1390
|
-
s !== void 0 && (n[o] = s);
|
|
1391
|
-
return n;
|
|
1392
|
-
}
|
|
1393
|
-
const on = [80, 75], sn = [208, 207, 17, 224], Oe = (e, t) => t.every((n, o) => e[o] === n);
|
|
1394
|
-
function rn(e) {
|
|
1395
|
-
if (Oe(e, sn))
|
|
1396
|
-
throw new se("ENCRYPTED", "Password-protected documents are not supported.");
|
|
1397
|
-
if (!Oe(e, on))
|
|
1398
|
-
throw new se("NOT_ZIP", "Not a .docx file (zip container signature missing).");
|
|
1399
|
-
const t = (r) => /^word\/media\//.test(r);
|
|
1400
|
-
let n, o;
|
|
1401
|
-
try {
|
|
1402
|
-
o = [], n = Re(e, {
|
|
1403
|
-
filter: (r) => t(r.name) ? (o.push(r.name), !1) : !0
|
|
1404
|
-
});
|
|
1405
|
-
} catch (r) {
|
|
1406
|
-
throw new se("NOT_ZIP", `Corrupt zip container: ${r instanceof Error ? r.message : String(r)}`);
|
|
1407
|
-
}
|
|
1408
|
-
const s = /* @__PURE__ */ new Map(), a = (r) => {
|
|
1409
|
-
const i = Re(e, { filter: (f) => f.name === r })[r];
|
|
1410
|
-
return i && (n[r] = i), i;
|
|
1411
|
-
};
|
|
1412
|
-
return {
|
|
1413
|
-
part: (r) => n[r] ?? (t(r) ? a(r) : void 0),
|
|
1414
|
-
text(r) {
|
|
1415
|
-
const i = s.get(r);
|
|
1416
|
-
if (i !== void 0) return i;
|
|
1417
|
-
const f = n[r];
|
|
1418
|
-
if (!f) return;
|
|
1419
|
-
const p = Qe(f);
|
|
1420
|
-
return s.set(r, p), p;
|
|
1421
|
-
},
|
|
1422
|
-
names: () => [...Object.keys(n), ...o.filter((r) => !(r in n))]
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
function hn(e, t, n) {
|
|
1426
|
-
const o = (I, O) => (n?.onProgress ?? t)?.(I, O), s = new qe(), a = [], r = n?.collectMediaBytes ? {
|
|
1427
|
-
add(I, O) {
|
|
1428
|
-
const F = `cw-media:${a.length}`;
|
|
1429
|
-
return a.push({ src: F, bytes: I, mime: O }), F;
|
|
1430
|
-
}
|
|
1431
|
-
} : void 0;
|
|
1432
|
-
o("unzip", 0);
|
|
1433
|
-
const i = rn(e);
|
|
1434
|
-
o("unzip", 1);
|
|
1435
|
-
const f = i.text("[Content_Types].xml"), p = (f !== void 0 ? Ke(f) : void 0) ?? "word/document.xml", d = i.text(p);
|
|
1436
|
-
if (d === void 0)
|
|
1437
|
-
throw new se("NO_DOCUMENT_PART", `Main document part "${p}" not found in the archive.`);
|
|
1438
|
-
const c = ye(i, p);
|
|
1439
|
-
o("styles", 0);
|
|
1440
|
-
const g = he(i, c, "styles") ?? i.text("word/styles.xml"), w = g !== void 0 ? Jt(g, s) : Qt, B = he(i, c, "theme") ?? i.text("word/theme/theme1.xml"), C = B !== void 0 ? Zt(B) : Vt, y = nn(w, C), U = he(i, c, "numbering") ?? i.text("word/numbering.xml"), $ = U !== void 0 ? zt(U) : _t;
|
|
1441
|
-
o("styles", 1), o("parse", 0);
|
|
1442
|
-
const P = dt(d, p, s);
|
|
1443
|
-
o("parse", 1), o("map", 0);
|
|
1444
|
-
const K = {
|
|
1445
|
-
w: P.section?.pageWidthTwips ?? 12240,
|
|
1446
|
-
h: P.section?.pageHeightTwips ?? 15840
|
|
1447
|
-
}, z = Rt(
|
|
1448
|
-
s,
|
|
1449
|
-
y,
|
|
1450
|
-
P.sdts,
|
|
1451
|
-
$,
|
|
1452
|
-
(I) => en(w, I),
|
|
1453
|
-
K
|
|
1454
|
-
), ee = [], Y = (I) => {
|
|
1455
|
-
const O = jt(i, I, s, r);
|
|
1456
|
-
return ee.push(O), O;
|
|
1457
|
-
}, Q = z.mapBlocks(P.blocks, Y(c), Pe(c));
|
|
1458
|
-
Q.length === 0 && Q.push(z.emptyParagraph());
|
|
1459
|
-
const q = z.mapSection(P.section), te = he(i, c, "settings") ?? i.text("word/settings.xml"), de = te !== void 0 && ln(te);
|
|
1460
|
-
Fe(q, "header", P.section?.headerRefs, P.section?.titlePg ?? !1, de, i, c, z, Y, s, P.sdts), Fe(q, "footer", P.section?.footerRefs, P.section?.titlePg ?? !1, de, i, c, z, Y, s, P.sdts);
|
|
1461
|
-
const ae = dn(c, "footnotes") ?? "word/footnotes.xml", ce = i.text(ae), fe = ce !== void 0 ? Pt(ce, ae, s, P.sdts) : /* @__PURE__ */ new Map(), l = {};
|
|
1462
|
-
if (fe.size > 0) {
|
|
1463
|
-
const I = ye(i, ae), O = Y(I), F = Pe(I);
|
|
1464
|
-
for (const { docxId: _, noteId: j } of z.footnoteRefs()) {
|
|
1465
|
-
const A = fe.get(_);
|
|
1466
|
-
if (!A) {
|
|
1467
|
-
s.add("footnote-missing", "A footnote reference had no matching note body.");
|
|
1468
|
-
continue;
|
|
1469
|
-
}
|
|
1470
|
-
const E = z.mapBlocks(A, O, F), b = E.filter((m) => m.kind === "paragraph");
|
|
1471
|
-
b.length < E.length && s.add("footnote-tables", "Tables inside footnotes were dropped (footnotes hold paragraphs only)."), b.length > 0 && (l[j] = b);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
o("map", 1);
|
|
1475
|
-
const h = { section: q, blocks: Q };
|
|
1476
|
-
Object.keys(l).length > 0 && (h.footnotes = l);
|
|
1477
|
-
const R = Nt(P.sdts);
|
|
1478
|
-
Object.keys(R).length > 0 && (h.sdts = R);
|
|
1479
|
-
const L = z.lists();
|
|
1480
|
-
Object.keys(L).length > 0 && (h.lists = L);
|
|
1481
|
-
const v = z.bookmarks();
|
|
1482
|
-
Object.keys(v).length > 0 && (h.bookmarks = v);
|
|
1483
|
-
const x = Ht(w, Ge(P.blocks));
|
|
1484
|
-
x && (h.stylesheet = x);
|
|
1485
|
-
const D = an(d);
|
|
1486
|
-
return D !== void 0 && (h.tocInstruction = D, Ye(h)), P.fields && (h.fields = P.fields), {
|
|
1487
|
-
doc: h,
|
|
1488
|
-
warnings: s.list,
|
|
1489
|
-
mediaUrls: ee.flatMap((I) => I.urls()),
|
|
1490
|
-
media: a
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
function an(e) {
|
|
1494
|
-
const t = /<w:instrText[^>]*>([\s\S]*?)<\/w:instrText>/g;
|
|
1495
|
-
let n;
|
|
1496
|
-
for (; (n = t.exec(e)) !== null; ) if (/\bTOC\b/.test(n[1])) return n[1];
|
|
1497
|
-
}
|
|
1498
|
-
function cn(e, t, n, o, s, a, r) {
|
|
1499
|
-
if (!n) return;
|
|
1500
|
-
const i = t.get(n), f = i && !i.external ? e.text(i.target) : void 0;
|
|
1501
|
-
if (i === void 0 || f === void 0) {
|
|
1502
|
-
a.add("header-missing", "A referenced header/footer part was missing from the archive.");
|
|
1503
|
-
return;
|
|
1504
|
-
}
|
|
1505
|
-
const p = ye(e, i.target), d = ft(f, i.target, a, r), c = o.mapBlocks(d, s(p), Pe(p));
|
|
1506
|
-
return c.length > 0 ? c : void 0;
|
|
1507
|
-
}
|
|
1508
|
-
function Fe(e, t, n, o, s, a, r, i, f, p, d) {
|
|
1509
|
-
if (!n) return;
|
|
1510
|
-
const c = (w) => `${t}${w}`, g = (w, B) => {
|
|
1511
|
-
const C = cn(a, r, B, i, f, p, d);
|
|
1512
|
-
C && (e[w] = C);
|
|
1513
|
-
};
|
|
1514
|
-
g(c(""), n.default), o && g(c("First"), n.first), s && g(c("Even"), n.even);
|
|
1515
|
-
}
|
|
1516
|
-
function ln(e) {
|
|
1517
|
-
const t = Z(J(e, "settings.xml"), "w:settings");
|
|
1518
|
-
return !!t && !!u(t, "w:evenAndOddHeadersAndFooters");
|
|
1519
|
-
}
|
|
1520
|
-
function ye(e, t) {
|
|
1521
|
-
const n = e.text(Xt(t));
|
|
1522
|
-
return n !== void 0 ? Gt(n, t) : /* @__PURE__ */ new Map();
|
|
1523
|
-
}
|
|
1524
|
-
function Pe(e) {
|
|
1525
|
-
return (t) => {
|
|
1526
|
-
const n = e.get(t);
|
|
1527
|
-
return n?.external ? n.target : void 0;
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
function he(e, t, n) {
|
|
1531
|
-
const o = Ve(t, n);
|
|
1532
|
-
return o && !o.external ? e.text(o.target) : void 0;
|
|
1533
|
-
}
|
|
1534
|
-
function dn(e, t) {
|
|
1535
|
-
const n = Ve(e, t);
|
|
1536
|
-
return n && !n.external ? n.target : void 0;
|
|
1537
|
-
}
|
|
1
|
+
import "./toc-B6VpkJge.js";
|
|
2
|
+
import "./contentTypes-f7VddqoF.js";
|
|
3
|
+
import { r as t } from "./pipeline-CbxmCE84.js";
|
|
1538
4
|
export {
|
|
1539
|
-
|
|
5
|
+
t as runImport
|
|
1540
6
|
};
|