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