@forevka/wordcanvas 0.1.0 → 0.3.0
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 +7 -4
- package/dist-lib/assets/{engine-DZ0JqUhP.js → engine-BVd9_fny.js} +1126 -1125
- package/dist-lib/assets/{worker-DL4Rxrg-.js → worker-C35TK5Ee.js} +1 -1
- package/dist-lib/builder.js +2347 -0
- package/dist-lib/{editorApp-Bl8rfr3S.js → editorApp-DYckquXo.js} +5052 -5577
- package/dist-lib/types-5-egHV_r.js +972 -0
- package/dist-lib/wordcanvas.js +65 -2
- package/package.json +6 -1
- package/types/builder.d.ts +231 -0
- package/types/model.d.ts +225 -0
- package/types/wordcanvas.d.ts +16 -0
- package/dist-lib/wordcanvas-DPJsuqnm.js +0 -365
|
@@ -0,0 +1,2347 @@
|
|
|
1
|
+
import { d as Ve, D as Ct, a as Bt, I as pe, n as It, W as Lt, B as it, b as Mt, c as qe } from "./types-5-egHV_r.js";
|
|
2
|
+
function Rt(n) {
|
|
3
|
+
let e = "";
|
|
4
|
+
for (let o = 0; o < n.length; o += 32768)
|
|
5
|
+
e += String.fromCharCode(...n.subarray(o, o + 32768));
|
|
6
|
+
return btoa(e);
|
|
7
|
+
}
|
|
8
|
+
function st(n, e) {
|
|
9
|
+
const t = n instanceof ArrayBuffer ? new Uint8Array(n) : n;
|
|
10
|
+
return `data:${e};base64,${Rt(t)}`;
|
|
11
|
+
}
|
|
12
|
+
class Nt {
|
|
13
|
+
constructor(e, t, o) {
|
|
14
|
+
this.parent = e, this.ctx = t, this.para = o;
|
|
15
|
+
}
|
|
16
|
+
/** Char formatting accrued in this scope — future text() runs inherit it. */
|
|
17
|
+
charPatch = {};
|
|
18
|
+
// ---- paragraph scope -----------------------------------------------------
|
|
19
|
+
/** Apply a named style from the stylesheet: sets the reference and patches
|
|
20
|
+
* exactly the fields the style defines (direct formatting applied AFTER this
|
|
21
|
+
* call wins — call order is precedence, like applying a style in the editor). */
|
|
22
|
+
withStyle(e) {
|
|
23
|
+
const t = this.ctx.lookupStyle(e);
|
|
24
|
+
if (!t) return this;
|
|
25
|
+
this.para.style.namedStyle = e, Object.assign(this.para.style, t.para);
|
|
26
|
+
for (const o of this.para.runs) Object.assign(o.style, t.char);
|
|
27
|
+
return Object.assign(this.charPatch, t.char), this;
|
|
28
|
+
}
|
|
29
|
+
/** Append a run. Inherits the scope's accrued char formatting; `style` wins. */
|
|
30
|
+
text(e, t) {
|
|
31
|
+
const o = this.ctx.run(e, { ...this.charPatch, ...t });
|
|
32
|
+
return this.para.runs.length === 1 && this.para.runs[0].text === "" ? this.para.runs[0] = o : this.para.runs.push(o), this;
|
|
33
|
+
}
|
|
34
|
+
applyChar(e) {
|
|
35
|
+
Object.assign(this.charPatch, e);
|
|
36
|
+
for (const t of this.para.runs) Object.assign(t.style, e);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
bold(e = !0) {
|
|
40
|
+
return this.applyChar({ bold: e });
|
|
41
|
+
}
|
|
42
|
+
italic(e = !0) {
|
|
43
|
+
return this.applyChar({ italic: e });
|
|
44
|
+
}
|
|
45
|
+
underline(e = !0) {
|
|
46
|
+
return this.applyChar({ underline: e });
|
|
47
|
+
}
|
|
48
|
+
strikethrough(e = !0) {
|
|
49
|
+
return this.applyChar({ strikethrough: e });
|
|
50
|
+
}
|
|
51
|
+
color(e) {
|
|
52
|
+
return this.applyChar({ color: e });
|
|
53
|
+
}
|
|
54
|
+
highlight(e) {
|
|
55
|
+
return this.applyChar({ highlightColor: e });
|
|
56
|
+
}
|
|
57
|
+
fontSize(e) {
|
|
58
|
+
return this.applyChar({ fontSizePx: e });
|
|
59
|
+
}
|
|
60
|
+
font(e) {
|
|
61
|
+
return this.applyChar({ fontFamily: e });
|
|
62
|
+
}
|
|
63
|
+
/** Make the paragraph's text a hyperlink (painted blue+underlined, Ctrl+click). */
|
|
64
|
+
link(e) {
|
|
65
|
+
return this.applyChar({ link: e });
|
|
66
|
+
}
|
|
67
|
+
align(e) {
|
|
68
|
+
return this.para.style.align = e, this;
|
|
69
|
+
}
|
|
70
|
+
spacing(e) {
|
|
71
|
+
return e.before !== void 0 && (this.para.style.spaceBeforePx = e.before), e.after !== void 0 && (this.para.style.spaceAfterPx = e.after), e.lineHeight !== void 0 && (this.para.style.lineHeight = e.lineHeight), this;
|
|
72
|
+
}
|
|
73
|
+
indent(e) {
|
|
74
|
+
return e.left !== void 0 && (this.para.style.indentLeftPx = e.left), e.right !== void 0 && (this.para.style.indentRightPx = e.right), e.firstLine !== void 0 && (this.para.style.indentFirstLinePx = e.firstLine), this;
|
|
75
|
+
}
|
|
76
|
+
keepWithNext(e = !0) {
|
|
77
|
+
return this.para.style.keepWithNext = e, this;
|
|
78
|
+
}
|
|
79
|
+
/** Escape the paragraph scope explicitly (rarely needed — any block-starting
|
|
80
|
+
* call below does it implicitly). */
|
|
81
|
+
end() {
|
|
82
|
+
return this.parent;
|
|
83
|
+
}
|
|
84
|
+
// ---- delegated block-starting surface (pops this scope) -------------------
|
|
85
|
+
paragraph(e, t) {
|
|
86
|
+
return this.parent.paragraph(e, t);
|
|
87
|
+
}
|
|
88
|
+
table(e, t) {
|
|
89
|
+
return this.parent.table(e, t);
|
|
90
|
+
}
|
|
91
|
+
image(e, t) {
|
|
92
|
+
return this.parent.image(e, t);
|
|
93
|
+
}
|
|
94
|
+
list(e, t) {
|
|
95
|
+
return this.parent.list(e, t);
|
|
96
|
+
}
|
|
97
|
+
bulletList(e) {
|
|
98
|
+
return this.parent.bulletList(e);
|
|
99
|
+
}
|
|
100
|
+
numberedList(e) {
|
|
101
|
+
return this.parent.numberedList(e);
|
|
102
|
+
}
|
|
103
|
+
pageBreak() {
|
|
104
|
+
return this.parent.pageBreak();
|
|
105
|
+
}
|
|
106
|
+
// ---- document-level delegators (only when the parent is the root builder) -
|
|
107
|
+
header(e, t) {
|
|
108
|
+
return this.parent.header(e, t);
|
|
109
|
+
}
|
|
110
|
+
footer(e, t) {
|
|
111
|
+
return this.parent.footer(e, t);
|
|
112
|
+
}
|
|
113
|
+
pageSetup(e) {
|
|
114
|
+
return this.parent.pageSetup(e);
|
|
115
|
+
}
|
|
116
|
+
style(e) {
|
|
117
|
+
return this.parent.style(e);
|
|
118
|
+
}
|
|
119
|
+
build() {
|
|
120
|
+
return this.parent.build();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const Ye = { spaceAfterPx: 0, lineHeight: 1.35 };
|
|
124
|
+
class Ot {
|
|
125
|
+
constructor(e, t = {}) {
|
|
126
|
+
this.ctx = e, this.opts = t, this.fractions = t.colFractions;
|
|
127
|
+
}
|
|
128
|
+
tableRows = [];
|
|
129
|
+
fractions;
|
|
130
|
+
row(e) {
|
|
131
|
+
const t = new Et(this.ctx);
|
|
132
|
+
if (typeof e == "function") e(t);
|
|
133
|
+
else for (const o of e) t.cell(o);
|
|
134
|
+
return this.tableRows.push({ cells: t.cells }), this;
|
|
135
|
+
}
|
|
136
|
+
rows(e) {
|
|
137
|
+
for (const t of e) this.row(t);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
colFractions(e) {
|
|
141
|
+
return this.fractions = e, this;
|
|
142
|
+
}
|
|
143
|
+
/** Materialize the TableBlock (called by the owning scope's .table()). */
|
|
144
|
+
toBlock() {
|
|
145
|
+
if (this.tableRows.length === 0 && (this.ctx.warn("table-empty", "A table was built with no rows — a single empty cell was inserted."), this.row([""])), this.opts.headerRow) {
|
|
146
|
+
for (const t of this.tableRows[0].cells)
|
|
147
|
+
for (const o of t.blocks)
|
|
148
|
+
if (o.kind === "paragraph") for (const r of o.runs) r.style.bold = !0;
|
|
149
|
+
}
|
|
150
|
+
const e = { kind: "table", id: this.ctx.ids.next(), revision: 0, rows: this.tableRows };
|
|
151
|
+
if (this.fractions && this.fractions.length > 0) {
|
|
152
|
+
const t = this.fractions.reduce((o, r) => o + r, 0);
|
|
153
|
+
t > 0 && (e.colFractions = this.fractions.map((o) => o / t));
|
|
154
|
+
}
|
|
155
|
+
return e;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
class Et {
|
|
159
|
+
constructor(e) {
|
|
160
|
+
this.ctx = e;
|
|
161
|
+
}
|
|
162
|
+
cells = [];
|
|
163
|
+
cell(e, t) {
|
|
164
|
+
const o = [];
|
|
165
|
+
let r;
|
|
166
|
+
if (typeof e == "function")
|
|
167
|
+
e(new Oe(this.ctx, o)), r = t ?? {};
|
|
168
|
+
else {
|
|
169
|
+
r = typeof e == "string" ? { ...t, text: e } : { ...e, ...t };
|
|
170
|
+
const s = { ...Ye };
|
|
171
|
+
r.align !== void 0 && (s.align = r.align), o.push(this.ctx.paragraph([this.ctx.run(r.text ?? "", r.style ?? {})], s));
|
|
172
|
+
}
|
|
173
|
+
o.length === 0 && o.push(this.ctx.paragraph([], Ye));
|
|
174
|
+
const i = { id: this.ctx.ids.next(), blocks: o };
|
|
175
|
+
return r.colSpan !== void 0 && r.colSpan > 1 && (i.colSpan = r.colSpan), r.rowSpan !== void 0 && r.rowSpan > 1 && (i.rowSpan = r.rowSpan), r.shading !== void 0 && (i.shading = r.shading), r.borders !== void 0 && (i.borders = r.borders), r.margin !== void 0 && (i.margin = r.margin), this.cells.push(i), this;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
class Oe {
|
|
179
|
+
ctx;
|
|
180
|
+
blocks;
|
|
181
|
+
pendingPageBreak = !1;
|
|
182
|
+
constructor(e, t) {
|
|
183
|
+
this.ctx = e, this.blocks = t;
|
|
184
|
+
}
|
|
185
|
+
/** Append a block, honoring a pending pageBreak(). Only paragraphs carry
|
|
186
|
+
* pageBreakBefore, so a break before a table/image lands on an injected
|
|
187
|
+
* empty paragraph (same trick as the docx import mapper). */
|
|
188
|
+
push(e) {
|
|
189
|
+
this.pendingPageBreak && (e.kind === "paragraph" ? e.style.pageBreakBefore = !0 : this.blocks.push(this.ctx.paragraph([], { pageBreakBefore: !0 })), this.pendingPageBreak = !1), this.blocks.push(e);
|
|
190
|
+
}
|
|
191
|
+
/** Start a paragraph. The returned scope styles THIS paragraph and delegates
|
|
192
|
+
* block-starting calls back here, so the chain continues seamlessly. */
|
|
193
|
+
paragraph(e, t) {
|
|
194
|
+
const o = e !== void 0 ? [this.ctx.run(e, t ?? {})] : [], r = this.ctx.paragraph(o);
|
|
195
|
+
return this.push(r), new Nt(this, this.ctx, r);
|
|
196
|
+
}
|
|
197
|
+
table(e, t) {
|
|
198
|
+
const o = new Ot(this.ctx, t);
|
|
199
|
+
return typeof e == "function" ? e(o) : o.rows(e), this.push(o.toBlock()), this;
|
|
200
|
+
}
|
|
201
|
+
/** Insert an image from a URL (https:/data:) or raw bytes (inlined as data:). */
|
|
202
|
+
image(e, t) {
|
|
203
|
+
if (!Number.isFinite(t?.widthPx) || !Number.isFinite(t?.heightPx) || t.widthPx <= 0 || t.heightPx <= 0)
|
|
204
|
+
throw new TypeError("image() requires positive widthPx and heightPx (no DOM to auto-measure in Node).");
|
|
205
|
+
const o = typeof e == "string" ? e : st(e.data, e.mime);
|
|
206
|
+
return this.push(this.ctx.image(o, t.widthPx, t.heightPx, t.align ?? "left", t.wrap)), this;
|
|
207
|
+
}
|
|
208
|
+
/** One paragraph per item, marked as list members. Definitions resolve to the
|
|
209
|
+
* template's (via listId), or the editor-default bullet/number definitions
|
|
210
|
+
* registered on demand. */
|
|
211
|
+
list(e, t = {}) {
|
|
212
|
+
const o = t.kind ?? "bullet", r = this.ctx.doc.lists ??= {};
|
|
213
|
+
let i = t.listId;
|
|
214
|
+
i !== void 0 ? r[i] || (this.ctx.warn(
|
|
215
|
+
`list-missing:${i}`,
|
|
216
|
+
`List definition "${i}" is not in the document — a default ${o} definition was registered under that id.`
|
|
217
|
+
), r[i] = { ...Ve(o === "number" ? "decimal" : "bullet"), id: i }) : (i = o === "number" ? Ct : Bt, r[i] || (r[i] = Ve(o === "number" ? "decimal" : "bullet")));
|
|
218
|
+
for (const s of e) {
|
|
219
|
+
const a = typeof s == "string" ? { text: s } : s, f = Math.max(0, Math.min(8, a.level ?? t.level ?? 0));
|
|
220
|
+
this.push(this.ctx.paragraph([this.ctx.run(a.text, a.style ?? {})], { list: { listId: i, level: f } }));
|
|
221
|
+
}
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
bulletList(e) {
|
|
225
|
+
return this.list(e, { kind: "bullet" });
|
|
226
|
+
}
|
|
227
|
+
numberedList(e) {
|
|
228
|
+
return this.list(e, { kind: "number" });
|
|
229
|
+
}
|
|
230
|
+
/** The NEXT block starts a new page. */
|
|
231
|
+
pageBreak() {
|
|
232
|
+
return this.pendingPageBreak = !0, this;
|
|
233
|
+
}
|
|
234
|
+
/** A trailing pageBreak() with no following block still needs to exist —
|
|
235
|
+
* materialize it as an empty page-broken paragraph (called by build()). */
|
|
236
|
+
flushPendingPageBreak() {
|
|
237
|
+
this.pendingPageBreak && (this.blocks.push(this.ctx.paragraph([], { pageBreakBefore: !0 })), this.pendingPageBreak = !1);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function Ie(n) {
|
|
241
|
+
return n.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g, function(e, t) {
|
|
242
|
+
if (t === "amp") return "&";
|
|
243
|
+
if (t === "lt") return "<";
|
|
244
|
+
if (t === "gt") return ">";
|
|
245
|
+
if (t === "quot") return '"';
|
|
246
|
+
if (t === "apos") return "'";
|
|
247
|
+
if (t[0] === "#") {
|
|
248
|
+
var o = t[1] === "x" || t[1] === "X", r = parseInt(t.slice(o ? 2 : 1), o ? 16 : 10);
|
|
249
|
+
if (!Number.isNaN(r) && r >= 0 && r <= 1114111) try {
|
|
250
|
+
return String.fromCodePoint(r);
|
|
251
|
+
} catch {
|
|
252
|
+
return e;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return e;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function at(n, e) {
|
|
259
|
+
var t = (e = e || {}).pos || 0, o = !!e.keepComments, r = !!e.keepWhitespace, i = !!e.decodeEntities, s = 60, a = 62, f = 45, h = 47, d = 33, c = 63, p = 39, m = 34, T = 61, b = 91, A = 93, E = 63;
|
|
260
|
+
function _(R) {
|
|
261
|
+
for (var W = []; n[t]; ) if (n.charCodeAt(t) == s) {
|
|
262
|
+
if (n.charCodeAt(t + 1) === h) {
|
|
263
|
+
var ne = t + 2;
|
|
264
|
+
if (t = n.indexOf(">", t), n.substring(ne, t).indexOf(R) == -1) {
|
|
265
|
+
var K = n.substring(0, t).split(`
|
|
266
|
+
`);
|
|
267
|
+
throw new Error(`Unexpected close tag
|
|
268
|
+
Line: ` + (K.length - 1) + `
|
|
269
|
+
Column: ` + (K[K.length - 1].length + 1) + `
|
|
270
|
+
Char: ` + n[t]);
|
|
271
|
+
}
|
|
272
|
+
return t + 1 && (t += 1), W;
|
|
273
|
+
}
|
|
274
|
+
if (n.charCodeAt(t + 1) === d) {
|
|
275
|
+
if (n.charCodeAt(t + 2) == f) {
|
|
276
|
+
const I = t;
|
|
277
|
+
for (; t !== -1 && (n.charCodeAt(t) !== a || n.charCodeAt(t - 1) != f || n.charCodeAt(t - 2) != f || t == -1); ) t = n.indexOf(">", t + 1);
|
|
278
|
+
t === -1 && (t = n.length), o && W.push(n.substring(I, t + 1));
|
|
279
|
+
} else {
|
|
280
|
+
if (n.charCodeAt(t + 2) === b && n.charCodeAt(t + 8) === b && n.substr(t + 3, 5).toLowerCase() === "cdata") {
|
|
281
|
+
var l = n.indexOf("]]>", t);
|
|
282
|
+
l == -1 ? (W.push(n.substr(t + 9)), t = n.length) : (W.push(n.substring(t + 9, l)), t = l + 3);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
{
|
|
286
|
+
const I = t + 1;
|
|
287
|
+
t += 2;
|
|
288
|
+
for (var g = !1; (n.charCodeAt(t) !== a || g === !0) && n[t]; ) n.charCodeAt(t) === b ? g = !0 : g === !0 && n.charCodeAt(t) === A && (g = !1), t++;
|
|
289
|
+
W.push(n.substring(I, t));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
t++;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
var y = J();
|
|
296
|
+
W.push(y);
|
|
297
|
+
} else {
|
|
298
|
+
var C = O();
|
|
299
|
+
if (r) C.length > 0 && W.push(C);
|
|
300
|
+
else {
|
|
301
|
+
var w = C.trim();
|
|
302
|
+
w.length > 0 && W.push(w);
|
|
303
|
+
}
|
|
304
|
+
t++;
|
|
305
|
+
}
|
|
306
|
+
return W;
|
|
307
|
+
}
|
|
308
|
+
function O() {
|
|
309
|
+
var R = t;
|
|
310
|
+
(t = n.indexOf("<", t) - 1) === -2 && (t = n.length);
|
|
311
|
+
var W = n.slice(R, t + 1);
|
|
312
|
+
return i ? Ie(W) : W;
|
|
313
|
+
}
|
|
314
|
+
var V = `\r
|
|
315
|
+
>/= `;
|
|
316
|
+
function X() {
|
|
317
|
+
for (var R = t; V.indexOf(n[t]) === -1 && n[t]; ) t++;
|
|
318
|
+
return n.slice(R, t);
|
|
319
|
+
}
|
|
320
|
+
var j, te = e.selfClosingTags || e.noChildNodes || ["img", "br", "input", "meta", "link", "hr"];
|
|
321
|
+
function J() {
|
|
322
|
+
t++;
|
|
323
|
+
const R = X(), W = R[0] === "?", ne = t, K = {};
|
|
324
|
+
let l = [];
|
|
325
|
+
for (; n[t] && n.charCodeAt(t) !== a && (!W || n.charCodeAt(t) !== c || n.charCodeAt(t + 1) !== a); ) {
|
|
326
|
+
var g = n.charCodeAt(t);
|
|
327
|
+
if (g > 64 && g < 91 || g > 96 && g < 123) {
|
|
328
|
+
for (var y = X(), C = null; n.charCodeAt(t) === 32 || n.charCodeAt(t) === 9 || n.charCodeAt(t) === 10 || n.charCodeAt(t) === 13; ) t++;
|
|
329
|
+
if (n.charCodeAt(t) === T) {
|
|
330
|
+
for (t++; n.charCodeAt(t) === 32 || n.charCodeAt(t) === 9 || n.charCodeAt(t) === 10 || n.charCodeAt(t) === 13; ) t++;
|
|
331
|
+
var w = n.charCodeAt(t);
|
|
332
|
+
if (w === p || w === m) {
|
|
333
|
+
if (C = q(), t === -1) return { tagName: R, attributes: K, children: l };
|
|
334
|
+
} else if (w && w !== a) {
|
|
335
|
+
for (var I = t; n[t] && V.indexOf(n[t]) === -1; ) t++;
|
|
336
|
+
C = n.slice(I, t), i && (C = Ie(C));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
K[y] = C;
|
|
340
|
+
} else t++;
|
|
341
|
+
}
|
|
342
|
+
if (W) {
|
|
343
|
+
var L = n.slice(ne, t).trim();
|
|
344
|
+
return L.length > 0 && Object.keys(K).length === 0 && (l = [L]), n.charCodeAt(t) === c && n.charCodeAt(t + 1) === a ? t += 2 : n.charCodeAt(t) === a && (t += 1), { tagName: R, attributes: K, children: l };
|
|
345
|
+
}
|
|
346
|
+
if (n.charCodeAt(t - 1) !== h && n.charCodeAt(t - 1) !== E) if (R == "script") {
|
|
347
|
+
var M = t + 1;
|
|
348
|
+
t = n.indexOf("<\/script>", t), l = [n.slice(M, t)], t += 9;
|
|
349
|
+
} else R == "style" ? (M = t + 1, t = n.indexOf("</style>", t), l = [n.slice(M, t)], t += 8) : te.indexOf(R) === -1 ? (t++, l = _(R)) : t++;
|
|
350
|
+
else t++;
|
|
351
|
+
return { tagName: R, attributes: K, children: l };
|
|
352
|
+
}
|
|
353
|
+
function q() {
|
|
354
|
+
var R = n[t], W = t + 1;
|
|
355
|
+
t = n.indexOf(R, W);
|
|
356
|
+
var ne = n.slice(W, t);
|
|
357
|
+
return i ? Ie(ne) : ne;
|
|
358
|
+
}
|
|
359
|
+
function ce() {
|
|
360
|
+
if (!e || !e.attrName || !e.attrValue) return -1;
|
|
361
|
+
var R = new RegExp("\\s" + e.attrName + `\\s*=['"]` + e.attrValue + `['"]`).exec(n);
|
|
362
|
+
return R ? R.index : -1;
|
|
363
|
+
}
|
|
364
|
+
if (e.attrValue !== void 0) for (e.attrName = e.attrName || "id", j = []; (t = ce()) !== -1; ) (t = n.lastIndexOf("<", t)) !== -1 && j.push(J()), n = n.substr(t), t = 0;
|
|
365
|
+
else j = e.parseNode ? J() : _("");
|
|
366
|
+
return e.filter && Array.isArray(j) && (j = ct(j, e.filter)), e.simplify ? Ee(Array.isArray(j) ? j : [j]) : (e.setPos && typeof j == "object" && !Array.isArray(j) && (j.pos = t), j);
|
|
367
|
+
}
|
|
368
|
+
function Ee(n) {
|
|
369
|
+
if (typeof n == "string") return Ee(at(n));
|
|
370
|
+
if (!Array.isArray(n)) throw new TypeError("simplify() expects parsed node array or XML string");
|
|
371
|
+
var e = {};
|
|
372
|
+
if (!n.length) return "";
|
|
373
|
+
if (n.length === 1 && typeof n[0] == "string") return n[0];
|
|
374
|
+
for (var t in n.forEach(function(o) {
|
|
375
|
+
if (typeof o == "object") {
|
|
376
|
+
e[o.tagName] || (e[o.tagName] = []);
|
|
377
|
+
var r = Ee(o.children);
|
|
378
|
+
e[o.tagName].push(r), Object.keys(o.attributes).length && typeof r == "object" && !Array.isArray(r) && (r._attributes = o.attributes);
|
|
379
|
+
}
|
|
380
|
+
}), e) e[t].length == 1 && (e[t] = e[t][0]);
|
|
381
|
+
return e;
|
|
382
|
+
}
|
|
383
|
+
function ct(n, e, t = 0, o = "") {
|
|
384
|
+
var r = [];
|
|
385
|
+
return n.forEach(function(i, s) {
|
|
386
|
+
if (typeof i == "object" && e(i, s, t, o) && r.push(i), typeof i == "object" && i.children) {
|
|
387
|
+
var a = ct(i.children, e, t + 1, (o ? o + "." : "") + s + "." + i.tagName);
|
|
388
|
+
r = r.concat(a);
|
|
389
|
+
}
|
|
390
|
+
}), r;
|
|
391
|
+
}
|
|
392
|
+
function xe(n) {
|
|
393
|
+
return typeof n == "object" && n !== null && "tagName" in n;
|
|
394
|
+
}
|
|
395
|
+
function de(n, e) {
|
|
396
|
+
try {
|
|
397
|
+
return at(n, { keepWhitespace: !0, decodeEntities: !0 }).filter(xe);
|
|
398
|
+
} catch (t) {
|
|
399
|
+
throw new pe(
|
|
400
|
+
"MALFORMED_XML",
|
|
401
|
+
`Failed to parse ${e}: ${t instanceof Error ? t.message : String(t)}`
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function fe(n, e) {
|
|
406
|
+
return n.find((t) => t.tagName === e);
|
|
407
|
+
}
|
|
408
|
+
function Y(n) {
|
|
409
|
+
return n.children.filter(xe);
|
|
410
|
+
}
|
|
411
|
+
function u(n, e) {
|
|
412
|
+
return n.children.find((t) => xe(t) && t.tagName === e);
|
|
413
|
+
}
|
|
414
|
+
function ee(n, e) {
|
|
415
|
+
return n.children.filter((t) => xe(t) && t.tagName === e);
|
|
416
|
+
}
|
|
417
|
+
function v(n, e) {
|
|
418
|
+
const t = n.attributes[e];
|
|
419
|
+
return t === void 0 ? void 0 : t ?? "";
|
|
420
|
+
}
|
|
421
|
+
function ye(n, e) {
|
|
422
|
+
for (const t of n.children) {
|
|
423
|
+
if (!xe(t)) continue;
|
|
424
|
+
if (t.tagName === e) return t;
|
|
425
|
+
const o = ye(t, e);
|
|
426
|
+
if (o) return o;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function Fe(n) {
|
|
430
|
+
let e = "";
|
|
431
|
+
for (const t of n.children) typeof t == "string" && (e += t);
|
|
432
|
+
return e;
|
|
433
|
+
}
|
|
434
|
+
function se(n, e) {
|
|
435
|
+
const t = u(n, e);
|
|
436
|
+
return t ? v(t, "w:val") : void 0;
|
|
437
|
+
}
|
|
438
|
+
function he(n) {
|
|
439
|
+
if (!n) return;
|
|
440
|
+
const e = v(n, "w:val");
|
|
441
|
+
return e === void 0 ? !0 : !["0", "false", "none", "off"].includes(e);
|
|
442
|
+
}
|
|
443
|
+
function x(n, e) {
|
|
444
|
+
if (!n) return;
|
|
445
|
+
const t = v(n, e);
|
|
446
|
+
if (t === void 0) return;
|
|
447
|
+
const o = Number(t);
|
|
448
|
+
return Number.isFinite(o) ? o : void 0;
|
|
449
|
+
}
|
|
450
|
+
const Ft = /* @__PURE__ */ new Set([
|
|
451
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
|
|
452
|
+
"application/vnd.ms-word.document.macroEnabled.main+xml"
|
|
453
|
+
]);
|
|
454
|
+
function Dt(n) {
|
|
455
|
+
const e = fe(de(n, "[Content_Types].xml"), "Types");
|
|
456
|
+
if (e)
|
|
457
|
+
for (const t of Y(e)) {
|
|
458
|
+
if (t.tagName !== "Override") continue;
|
|
459
|
+
const o = v(t, "ContentType"), r = v(t, "PartName");
|
|
460
|
+
if (o && r && Ft.has(o))
|
|
461
|
+
return r.replace(/^\//, "");
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const F = (n) => n / 15, Ht = (n) => n * 2 / 3, Ke = (n) => n / 9525, jt = (n) => n / 240, B = (n) => Math.round(n * 100) / 100, Wt = [
|
|
465
|
+
["top", "w:top"],
|
|
466
|
+
["left", "w:left"],
|
|
467
|
+
["bottom", "w:bottom"],
|
|
468
|
+
["right", "w:right"],
|
|
469
|
+
["insideH", "w:insideH"],
|
|
470
|
+
["insideV", "w:insideV"]
|
|
471
|
+
];
|
|
472
|
+
function Ue(n) {
|
|
473
|
+
if (!n) return;
|
|
474
|
+
const e = {};
|
|
475
|
+
for (const [t, o] of Wt) {
|
|
476
|
+
const r = u(n, o);
|
|
477
|
+
if (!r) continue;
|
|
478
|
+
const i = { val: v(r, "w:val") ?? "single" }, s = x(r, "w:sz");
|
|
479
|
+
s !== void 0 && (i.sizeEighthPt = s);
|
|
480
|
+
const a = v(r, "w:color");
|
|
481
|
+
a && (i.color = a), e[t] = i;
|
|
482
|
+
}
|
|
483
|
+
return Object.keys(e).length > 0 ? e : void 0;
|
|
484
|
+
}
|
|
485
|
+
function Ge(n) {
|
|
486
|
+
if (!n) return;
|
|
487
|
+
const e = v(n, "w:fill");
|
|
488
|
+
if (e && e !== "auto") return `#${e.toLowerCase()}`;
|
|
489
|
+
const t = v(n, "w:val"), o = v(n, "w:color");
|
|
490
|
+
if (t && t !== "clear" && t !== "nil" && o && o !== "auto")
|
|
491
|
+
return `#${o.toLowerCase()}`;
|
|
492
|
+
}
|
|
493
|
+
function zt(n, e) {
|
|
494
|
+
return n ? e ? { ...n, ...e } : n : e;
|
|
495
|
+
}
|
|
496
|
+
function _t(n, e) {
|
|
497
|
+
const t = (f, h, d) => (
|
|
498
|
+
// Cell edges are named directly; the table/style layers use the named edge
|
|
499
|
+
// on the boundary and the inside edge between cells.
|
|
500
|
+
n.cell?.[f] ?? n.table?.[d ? f : h] ?? n.style?.[d ? f : h]
|
|
501
|
+
), o = {}, r = Te(t("top", "insideH", e.top));
|
|
502
|
+
r && (o.top = r);
|
|
503
|
+
const i = Te(t("bottom", "insideH", e.bottom));
|
|
504
|
+
i && (o.bottom = i);
|
|
505
|
+
const s = Te(t("left", "insideV", e.left));
|
|
506
|
+
s && (o.left = s);
|
|
507
|
+
const a = Te(t("right", "insideV", e.right));
|
|
508
|
+
return a && (o.right = a), o;
|
|
509
|
+
}
|
|
510
|
+
function Te(n) {
|
|
511
|
+
if (!n || n.val === "nil" || n.val === "none") return;
|
|
512
|
+
const e = B(Math.max(0.5, (n.sizeEighthPt ?? 4) / 6)), o = { color: !n.color || n.color === "auto" ? "#000000" : `#${n.color.toLowerCase()}`, widthPx: e }, r = $t(n.val);
|
|
513
|
+
return r !== "single" && (o.style = r), o;
|
|
514
|
+
}
|
|
515
|
+
function $t(n) {
|
|
516
|
+
return n === "double" ? "double" : /dash/i.test(n) ? "dashed" : /dot/i.test(n) ? "dotted" : "single";
|
|
517
|
+
}
|
|
518
|
+
function we(n) {
|
|
519
|
+
const e = {}, t = se(n, "w:rStyle");
|
|
520
|
+
t && (e.styleId = t);
|
|
521
|
+
const o = he(u(n, "w:b"));
|
|
522
|
+
o !== void 0 && (e.bold = o);
|
|
523
|
+
const r = he(u(n, "w:i"));
|
|
524
|
+
r !== void 0 && (e.italic = r);
|
|
525
|
+
const i = he(u(n, "w:strike"));
|
|
526
|
+
i !== void 0 && (e.strikethrough = i);
|
|
527
|
+
const s = u(n, "w:u");
|
|
528
|
+
s && (e.underline = v(s, "w:val") !== "none");
|
|
529
|
+
const a = u(n, "w:color");
|
|
530
|
+
if (a) {
|
|
531
|
+
const m = v(a, "w:val");
|
|
532
|
+
m && (e.color = m);
|
|
533
|
+
const T = v(a, "w:themeColor");
|
|
534
|
+
T && (e.colorTheme = T);
|
|
535
|
+
}
|
|
536
|
+
const f = x(u(n, "w:sz"), "w:val");
|
|
537
|
+
f !== void 0 && (e.sizeHalfPoints = f);
|
|
538
|
+
const h = u(n, "w:rFonts");
|
|
539
|
+
if (h) {
|
|
540
|
+
const m = v(h, "w:ascii");
|
|
541
|
+
m && (e.fontAscii = m);
|
|
542
|
+
const T = v(h, "w:asciiTheme");
|
|
543
|
+
T && (e.fontThemeAscii = T);
|
|
544
|
+
}
|
|
545
|
+
const d = se(n, "w:highlight");
|
|
546
|
+
d && d !== "none" && (e.highlight = d);
|
|
547
|
+
const c = se(n, "w:vertAlign");
|
|
548
|
+
c && (e.vertAlign = c);
|
|
549
|
+
const p = he(u(n, "w:vanish"));
|
|
550
|
+
return p !== void 0 && (e.vanish = p), e;
|
|
551
|
+
}
|
|
552
|
+
const Ut = {
|
|
553
|
+
left: "left",
|
|
554
|
+
start: "left",
|
|
555
|
+
center: "center",
|
|
556
|
+
right: "right",
|
|
557
|
+
end: "right",
|
|
558
|
+
both: "justify",
|
|
559
|
+
distribute: "justify"
|
|
560
|
+
};
|
|
561
|
+
function De(n, e) {
|
|
562
|
+
const t = {}, o = se(n, "w:pStyle");
|
|
563
|
+
o && (t.styleId = o);
|
|
564
|
+
const r = se(n, "w:jc"), i = r !== void 0 ? Ut[r] : void 0;
|
|
565
|
+
i && (t.align = i);
|
|
566
|
+
const s = u(n, "w:spacing");
|
|
567
|
+
if (s) {
|
|
568
|
+
const b = x(s, "w:before");
|
|
569
|
+
b !== void 0 && (t.spaceBeforeTwips = b);
|
|
570
|
+
const A = x(s, "w:after");
|
|
571
|
+
A !== void 0 && (t.spaceAfterTwips = A);
|
|
572
|
+
const E = x(s, "w:line"), _ = v(s, "w:lineRule") ?? "auto";
|
|
573
|
+
E !== void 0 && (_ === "auto" ? t.lineHeight = jt(E) : e.add("line-rule-exact", "Exact/atLeast line spacing was ignored (model is multiplier-only)."));
|
|
574
|
+
}
|
|
575
|
+
const a = u(n, "w:ind");
|
|
576
|
+
if (a) {
|
|
577
|
+
const b = x(a, "w:left") ?? x(a, "w:start");
|
|
578
|
+
b !== void 0 && (t.indentLeftTwips = b);
|
|
579
|
+
const A = x(a, "w:right") ?? x(a, "w:end");
|
|
580
|
+
A !== void 0 && (t.indentRightTwips = A);
|
|
581
|
+
const E = x(a, "w:firstLine"), _ = x(a, "w:hanging");
|
|
582
|
+
E !== void 0 ? t.indentFirstLineTwips = E : _ !== void 0 && (t.indentFirstLineTwips = -_);
|
|
583
|
+
}
|
|
584
|
+
const f = he(u(n, "w:keepNext"));
|
|
585
|
+
f !== void 0 && (t.keepWithNext = f);
|
|
586
|
+
const h = he(u(n, "w:keepLines"));
|
|
587
|
+
h !== void 0 && (t.keepLinesTogether = h);
|
|
588
|
+
const d = u(n, "w:tabs");
|
|
589
|
+
if (d) {
|
|
590
|
+
const b = [];
|
|
591
|
+
for (const A of ee(d, "w:tab")) {
|
|
592
|
+
const E = x(A, "w:pos"), _ = v(A, "w:val");
|
|
593
|
+
if (E === void 0 || _ === "clear" || _ === "bar") continue;
|
|
594
|
+
const O = { posTwips: E };
|
|
595
|
+
_ && (O.val = _);
|
|
596
|
+
const V = v(A, "w:leader");
|
|
597
|
+
V && (O.leader = V), b.push(O);
|
|
598
|
+
}
|
|
599
|
+
b.length > 0 && (t.tabStops = b);
|
|
600
|
+
}
|
|
601
|
+
const c = he(u(n, "w:pageBreakBefore"));
|
|
602
|
+
c !== void 0 && (t.pageBreakBefore = c);
|
|
603
|
+
const p = u(n, "w:numPr");
|
|
604
|
+
if (p) {
|
|
605
|
+
const b = se(p, "w:numId");
|
|
606
|
+
b !== void 0 && (t.list = b === "0" ? null : { numId: b, level: x(u(p, "w:ilvl"), "w:val") ?? 0 });
|
|
607
|
+
}
|
|
608
|
+
const m = u(n, "w:rPr");
|
|
609
|
+
m && (t.markRunProps = we(m));
|
|
610
|
+
const T = u(n, "w:sectPr");
|
|
611
|
+
if (T) {
|
|
612
|
+
t.sectionBreak = se(T, "w:type") === "continuous" ? "continuous" : "page";
|
|
613
|
+
const b = u(T, "w:pgSz"), A = x(b, "w:w"), E = x(b, "w:h");
|
|
614
|
+
A !== void 0 && E !== void 0 && (t.sectionPgSize = { w: A, h: E });
|
|
615
|
+
const _ = u(T, "w:pgMar");
|
|
616
|
+
if (_) {
|
|
617
|
+
const j = x(_, "w:top"), te = x(_, "w:right"), J = x(_, "w:bottom"), q = x(_, "w:left");
|
|
618
|
+
j !== void 0 && te !== void 0 && J !== void 0 && q !== void 0 && (t.sectionMarginTwips = { top: j, right: te, bottom: J, left: q });
|
|
619
|
+
}
|
|
620
|
+
const O = u(T, "w:cols"), V = x(O, "w:num");
|
|
621
|
+
if (V !== void 0 && V > 1) {
|
|
622
|
+
t.sectionColumns = { count: V };
|
|
623
|
+
const j = x(O, "w:space");
|
|
624
|
+
j !== void 0 && (t.sectionColumns.spaceTwips = j);
|
|
625
|
+
}
|
|
626
|
+
const X = x(u(T, "w:pgNumType"), "w:start");
|
|
627
|
+
X !== void 0 && (t.sectionPageNumberStart = X), (ee(T, "w:headerReference").length > 0 || ee(T, "w:footerReference").length > 0) && (t.sectionHasBands = !0);
|
|
628
|
+
}
|
|
629
|
+
return t;
|
|
630
|
+
}
|
|
631
|
+
function Ze(n) {
|
|
632
|
+
let e = 0;
|
|
633
|
+
for (const t of n)
|
|
634
|
+
t.kind === "run" ? e += t.text.length : t.kind === "break" && (e += 1);
|
|
635
|
+
return e;
|
|
636
|
+
}
|
|
637
|
+
function Gt(n, e, t) {
|
|
638
|
+
const o = fe(de(n, e), "w:document"), r = o && u(o, "w:body");
|
|
639
|
+
if (!r)
|
|
640
|
+
throw new pe("MALFORMED_XML", `${e} has no w:document/w:body root.`);
|
|
641
|
+
const i = {}, s = { warnings: t, fieldTokens: !1, sdts: i, nextSdt: { n: 0 }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null }, a = [];
|
|
642
|
+
ve(Y(r), a, s);
|
|
643
|
+
const f = u(r, "w:sectPr"), h = f ? nn(f) : null;
|
|
644
|
+
return { blocks: a, section: h, sdts: i };
|
|
645
|
+
}
|
|
646
|
+
function Xt(n, e, t, o = {}) {
|
|
647
|
+
const r = de(n, e), i = fe(r, "w:hdr") ?? fe(r, "w:ftr");
|
|
648
|
+
if (!i)
|
|
649
|
+
throw new pe("MALFORMED_XML", `${e} has no w:hdr/w:ftr root.`);
|
|
650
|
+
const s = { warnings: t, fieldTokens: !0, sdts: o, nextSdt: { n: Object.keys(o).length }, pendingBookmarks: [], currentBookmarks: null, pendingMarkers: [], currentMarkers: null }, a = [];
|
|
651
|
+
return ve(Y(i), a, s), a;
|
|
652
|
+
}
|
|
653
|
+
const Vt = /* @__PURE__ */ new Set(["_GoBack", "_Toc_Placeholder"]);
|
|
654
|
+
function lt(n) {
|
|
655
|
+
const e = v(n, "w:name");
|
|
656
|
+
return e && !Vt.has(e) ? e : null;
|
|
657
|
+
}
|
|
658
|
+
function ve(n, e, t) {
|
|
659
|
+
for (const o of n)
|
|
660
|
+
switch (o.tagName) {
|
|
661
|
+
case "w:p":
|
|
662
|
+
e.push(qt(o, t));
|
|
663
|
+
break;
|
|
664
|
+
case "w:tbl":
|
|
665
|
+
e.push(en(o, t));
|
|
666
|
+
break;
|
|
667
|
+
case "w:sdt": {
|
|
668
|
+
const r = u(o, "w:sdtContent");
|
|
669
|
+
if (!r) break;
|
|
670
|
+
const i = dt(u(o, "w:sdtPr"));
|
|
671
|
+
if (!i) {
|
|
672
|
+
t.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), ve(Y(r), e, t);
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
const s = `sdt${t.nextSdt.n++}`;
|
|
676
|
+
t.sdts[s] = i;
|
|
677
|
+
const a = [];
|
|
678
|
+
ve(Y(r), a, t);
|
|
679
|
+
for (const f of a) ut(f, s);
|
|
680
|
+
e.push(...a);
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
case "w:bookmarkStart": {
|
|
684
|
+
const r = lt(o), i = v(o, "w:id");
|
|
685
|
+
r && (t.pendingBookmarks.push(r), i && t.pendingMarkers.push({ id: i, name: r, kind: "start", offset: 0 }));
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case "w:bookmarkEnd": {
|
|
689
|
+
const r = v(o, "w:id");
|
|
690
|
+
r && t.pendingMarkers.push({ id: r, kind: "end", offset: 0 });
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function qt(n, e) {
|
|
696
|
+
const t = u(n, "w:pPr"), o = t ? De(t, e.warnings) : {}, r = [], i = e.pendingBookmarks;
|
|
697
|
+
e.pendingBookmarks = [], e.currentBookmarks = i;
|
|
698
|
+
const s = e.pendingMarkers;
|
|
699
|
+
e.pendingMarkers = [], e.currentMarkers = s;
|
|
700
|
+
const a = { depth: 0, instr: "", suppressResult: !1 };
|
|
701
|
+
ge(Y(n), r, e, a), e.currentBookmarks = null, e.currentMarkers = null;
|
|
702
|
+
const f = { kind: "paragraph", props: o, inlines: r };
|
|
703
|
+
return i.length > 0 && (f.bookmarks = i), s.length > 0 && (f.bookmarkMarkers = s), f;
|
|
704
|
+
}
|
|
705
|
+
function He(n) {
|
|
706
|
+
if (/\bNUMPAGES\b/.test(n)) return "{pages}";
|
|
707
|
+
if (/\bPAGE\b/.test(n)) return "{page}";
|
|
708
|
+
}
|
|
709
|
+
function ge(n, e, t, o) {
|
|
710
|
+
for (const r of n)
|
|
711
|
+
switch (r.tagName) {
|
|
712
|
+
case "w:r":
|
|
713
|
+
Kt(r, e, t, o);
|
|
714
|
+
break;
|
|
715
|
+
case "w:hyperlink": {
|
|
716
|
+
const i = v(r, "r:id"), s = v(r, "w:anchor"), a = e.length;
|
|
717
|
+
if (ge(Y(r), e, t, o), i || s)
|
|
718
|
+
for (let f = a; f < e.length; f++) {
|
|
719
|
+
const h = e[f];
|
|
720
|
+
h.kind === "run" && (i ? h.props.linkRelId = i : s && (h.props.linkAnchor = s));
|
|
721
|
+
}
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
case "w:sdt": {
|
|
725
|
+
const i = u(r, "w:sdtContent");
|
|
726
|
+
if (!i) break;
|
|
727
|
+
const s = dt(u(r, "w:sdtPr"));
|
|
728
|
+
if (!s) {
|
|
729
|
+
t.warnings.add("sdt-unwrapped", "Content controls were unwrapped to their content."), ge(Y(i), e, t, o);
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
const a = `sdt${t.nextSdt.n++}`;
|
|
733
|
+
t.sdts[a] = s;
|
|
734
|
+
const f = [];
|
|
735
|
+
ge(Y(i), f, t, o);
|
|
736
|
+
for (const h of f)
|
|
737
|
+
h.kind === "run" && (h.sdtId = a);
|
|
738
|
+
e.push(...f);
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
case "w:fldSimple": {
|
|
742
|
+
const i = v(r, "w:instr") ?? "", s = t.fieldTokens ? He(i) : void 0;
|
|
743
|
+
s ? e.push({ kind: "run", text: s, props: Yt(r) }) : ge(Y(r), e, t, o);
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
case "w:smartTag":
|
|
747
|
+
case "w:ins":
|
|
748
|
+
ge(Y(r), e, t, o);
|
|
749
|
+
break;
|
|
750
|
+
case "w:del":
|
|
751
|
+
break;
|
|
752
|
+
case "w:bookmarkStart": {
|
|
753
|
+
const i = lt(r), s = v(r, "w:id");
|
|
754
|
+
i && t.currentBookmarks && t.currentBookmarks.push(i), i && s && t.currentMarkers && t.currentMarkers.push({ id: s, name: i, kind: "start", offset: Ze(e) });
|
|
755
|
+
break;
|
|
756
|
+
}
|
|
757
|
+
case "w:bookmarkEnd": {
|
|
758
|
+
const i = v(r, "w:id");
|
|
759
|
+
i && t.currentMarkers && t.currentMarkers.push({ id: i, kind: "end", offset: Ze(e) });
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
function Yt(n) {
|
|
765
|
+
const e = ye(n, "w:r"), t = e && u(e, "w:rPr");
|
|
766
|
+
return t ? we(t) : {};
|
|
767
|
+
}
|
|
768
|
+
function Kt(n, e, t, o) {
|
|
769
|
+
const r = u(n, "w:rPr"), i = r ? we(r) : {};
|
|
770
|
+
let s = "";
|
|
771
|
+
const a = () => {
|
|
772
|
+
s.length > 0 && e.push({ kind: "run", text: s, props: i }), s = "";
|
|
773
|
+
}, f = (h) => {
|
|
774
|
+
for (const d of h)
|
|
775
|
+
switch (d.tagName) {
|
|
776
|
+
case "w:t":
|
|
777
|
+
o.suppressResult || (s += Fe(d));
|
|
778
|
+
break;
|
|
779
|
+
case "w:tab":
|
|
780
|
+
o.suppressResult || (s += " ");
|
|
781
|
+
break;
|
|
782
|
+
case "w:br": {
|
|
783
|
+
a();
|
|
784
|
+
const c = v(d, "w:type");
|
|
785
|
+
c === "page" ? e.push({ kind: "break", page: !0 }) : c === "column" ? e.push({ kind: "break", column: !0 }) : e.push({ kind: "break" });
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
case "w:cr":
|
|
789
|
+
a(), e.push({ kind: "break" });
|
|
790
|
+
break;
|
|
791
|
+
case "w:noBreakHyphen":
|
|
792
|
+
s += "‑";
|
|
793
|
+
break;
|
|
794
|
+
case "w:drawing": {
|
|
795
|
+
a();
|
|
796
|
+
const c = Jt(d, t);
|
|
797
|
+
c && e.push(c);
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
case "w:pict": {
|
|
801
|
+
a();
|
|
802
|
+
const c = Qt(d, t);
|
|
803
|
+
c && e.push(c);
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case "w:object":
|
|
807
|
+
t.warnings.add("objects-skipped", "Embedded OLE objects are not imported.");
|
|
808
|
+
break;
|
|
809
|
+
case "w:instrText":
|
|
810
|
+
o.depth > 0 && (o.instr += Fe(d));
|
|
811
|
+
break;
|
|
812
|
+
case "w:fldChar":
|
|
813
|
+
Zt(d, i, e, t, o);
|
|
814
|
+
break;
|
|
815
|
+
case "mc:AlternateContent": {
|
|
816
|
+
const c = u(d, "mc:Choice") ?? u(d, "mc:Fallback");
|
|
817
|
+
c && f(Y(c));
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
case "w:footnoteReference": {
|
|
821
|
+
const c = v(d, "w:id");
|
|
822
|
+
c !== void 0 && (a(), e.push({ kind: "run", text: "", props: { ...i, footnoteId: c } }));
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
f(Y(n)), a();
|
|
828
|
+
}
|
|
829
|
+
function Zt(n, e, t, o, r) {
|
|
830
|
+
switch (v(n, "w:fldCharType")) {
|
|
831
|
+
case "begin":
|
|
832
|
+
r.depth++, r.depth === 1 && (r.instr = "", r.suppressResult = !1);
|
|
833
|
+
break;
|
|
834
|
+
case "separate": {
|
|
835
|
+
if (r.depth !== 1) break;
|
|
836
|
+
const i = o.fieldTokens ? He(r.instr) : void 0;
|
|
837
|
+
i && (t.push({ kind: "run", text: i, props: e }), r.suppressResult = !0);
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
case "end":
|
|
841
|
+
if (r.depth > 0 && r.depth--, r.depth === 0) {
|
|
842
|
+
if (!r.suppressResult) {
|
|
843
|
+
const i = o.fieldTokens ? He(r.instr) : void 0;
|
|
844
|
+
i && t.push({ kind: "run", text: i, props: e });
|
|
845
|
+
}
|
|
846
|
+
r.instr = "", r.suppressResult = !1;
|
|
847
|
+
}
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function Jt(n, e) {
|
|
852
|
+
const t = u(n, "wp:anchor"), o = u(n, "wp:inline") ?? t;
|
|
853
|
+
if (!o) return;
|
|
854
|
+
const r = ye(o, "a:blip"), i = r && v(r, "r:embed");
|
|
855
|
+
if (!i) {
|
|
856
|
+
e.warnings.add("images-skipped", "A drawing without an embedded image reference was skipped.");
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const s = u(o, "wp:extent"), a = { kind: "image", relId: i, anchored: !!t }, f = x(s, "cx");
|
|
860
|
+
f !== void 0 && (a.widthEmu = f);
|
|
861
|
+
const h = x(s, "cy");
|
|
862
|
+
if (h !== void 0 && (a.heightEmu = h), t) {
|
|
863
|
+
const d = u(t, "wp:wrapSquare") ?? u(t, "wp:wrapTight") ?? u(t, "wp:wrapThrough");
|
|
864
|
+
a.anchorWrap = d ? "square" : "block", d || e.warnings.add(
|
|
865
|
+
"images-anchored",
|
|
866
|
+
"Some floating images (overlapping or top-and-bottom wrap) were placed in the text flow."
|
|
867
|
+
);
|
|
868
|
+
const c = u(t, "wp:positionH"), p = c && u(c, "wp:align"), m = p && Fe(p);
|
|
869
|
+
(m === "left" || m === "right" || m === "center") && (a.anchorAlign = m);
|
|
870
|
+
}
|
|
871
|
+
return a;
|
|
872
|
+
}
|
|
873
|
+
function Qt(n, e) {
|
|
874
|
+
const t = ye(n, "v:imagedata"), o = t && v(t, "r:id");
|
|
875
|
+
if (!o) {
|
|
876
|
+
e.warnings.add("images-skipped", "A legacy picture without an image reference was skipped.");
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
const r = { kind: "image", relId: o, anchored: !1 }, i = ye(n, "v:shape"), s = (i && v(i, "style")) ?? "", a = (d) => {
|
|
880
|
+
const c = s.match(new RegExp(`(?:^|;)\\s*${d}:([\\d.]+)pt`));
|
|
881
|
+
return c ? Number(c[1]) * 12700 : void 0;
|
|
882
|
+
}, f = a("width");
|
|
883
|
+
f !== void 0 && (r.widthEmu = f);
|
|
884
|
+
const h = a("height");
|
|
885
|
+
return h !== void 0 && (r.heightEmu = h), r;
|
|
886
|
+
}
|
|
887
|
+
function ft(n) {
|
|
888
|
+
if (!n) return;
|
|
889
|
+
const e = (a) => x(u(n, a), "w:w"), t = {}, o = e("w:top");
|
|
890
|
+
o !== void 0 && (t.top = o);
|
|
891
|
+
const r = e("w:right");
|
|
892
|
+
r !== void 0 && (t.right = r);
|
|
893
|
+
const i = e("w:bottom");
|
|
894
|
+
i !== void 0 && (t.bottom = i);
|
|
895
|
+
const s = e("w:left");
|
|
896
|
+
return s !== void 0 && (t.left = s), Object.keys(t).length > 0 ? t : void 0;
|
|
897
|
+
}
|
|
898
|
+
function en(n, e) {
|
|
899
|
+
const t = [];
|
|
900
|
+
for (const s of ee(n, "w:tr")) {
|
|
901
|
+
const a = [];
|
|
902
|
+
for (const f of ee(s, "w:tc"))
|
|
903
|
+
a.push(tn(f, e));
|
|
904
|
+
t.push({ cells: a });
|
|
905
|
+
}
|
|
906
|
+
const o = { kind: "table", rows: t }, r = u(n, "w:tblGrid");
|
|
907
|
+
if (r) {
|
|
908
|
+
const s = ee(r, "w:gridCol").map((a) => x(a, "w:w")).filter((a) => a !== void 0 && a > 0);
|
|
909
|
+
s.length > 0 && (o.colWidthsTwips = s);
|
|
910
|
+
}
|
|
911
|
+
const i = u(n, "w:tblPr");
|
|
912
|
+
if (i) {
|
|
913
|
+
const s = se(i, "w:tblStyle");
|
|
914
|
+
s && (o.styleId = s), u(i, "w:tblBorders") && (o.bordersSpecified = !0);
|
|
915
|
+
const a = Ue(u(i, "w:tblBorders"));
|
|
916
|
+
a && (o.borders = a);
|
|
917
|
+
const f = Ge(u(i, "w:shd"));
|
|
918
|
+
f && (o.shd = f);
|
|
919
|
+
const h = ft(u(i, "w:tblCellMar"));
|
|
920
|
+
h && (o.cellMarginTwips = h);
|
|
921
|
+
}
|
|
922
|
+
return o;
|
|
923
|
+
}
|
|
924
|
+
function tn(n, e) {
|
|
925
|
+
const t = u(n, "w:tcPr"), o = (t && x(u(t, "w:gridSpan"), "w:val")) ?? 1, r = t && u(t, "w:vMerge"), i = !!r && (v(r, "w:val") ?? "continue") === "continue", s = [];
|
|
926
|
+
ve(Y(n), s, e);
|
|
927
|
+
const a = { blocks: s, gridSpan: o, vMergeContinue: i };
|
|
928
|
+
if (t) {
|
|
929
|
+
u(t, "w:tcBorders") && (a.bordersSpecified = !0);
|
|
930
|
+
const f = Ue(u(t, "w:tcBorders"));
|
|
931
|
+
f && (a.borders = f);
|
|
932
|
+
const h = Ge(u(t, "w:shd"));
|
|
933
|
+
h && (a.shd = h);
|
|
934
|
+
const d = ft(u(t, "w:tcMar"));
|
|
935
|
+
d && (a.marginTwips = d);
|
|
936
|
+
}
|
|
937
|
+
return a;
|
|
938
|
+
}
|
|
939
|
+
function dt(n) {
|
|
940
|
+
if (!n) return null;
|
|
941
|
+
const e = { type: "richText" }, t = u(n, "w:alias"), o = t && v(t, "w:val");
|
|
942
|
+
o && (e.alias = o);
|
|
943
|
+
const r = u(n, "w:tag"), i = r && v(r, "w:val");
|
|
944
|
+
i && (e.tag = i), u(n, "w:text") && (e.type = "plainText");
|
|
945
|
+
const s = u(n, "w:dropDownList") ?? u(n, "w:comboBox");
|
|
946
|
+
s && (e.type = s.tagName === "w:dropDownList" ? "dropDown" : "comboBox", e.listItems = ee(s, "w:listItem").map((c) => ({
|
|
947
|
+
display: v(c, "w:displayText") ?? v(c, "w:value") ?? "",
|
|
948
|
+
value: v(c, "w:value") ?? v(c, "w:displayText") ?? ""
|
|
949
|
+
})));
|
|
950
|
+
const a = u(n, "w:date");
|
|
951
|
+
if (a) {
|
|
952
|
+
e.type = "date";
|
|
953
|
+
const c = u(a, "w:dateFormat"), p = c && v(c, "w:val");
|
|
954
|
+
p && (e.dateFormat = p);
|
|
955
|
+
}
|
|
956
|
+
const f = u(n, "w14:checkbox");
|
|
957
|
+
if (f) {
|
|
958
|
+
e.type = "checkbox";
|
|
959
|
+
const c = u(f, "w14:checked"), p = c && v(c, "w14:val");
|
|
960
|
+
e.checked = p === "1" || p === "true";
|
|
961
|
+
}
|
|
962
|
+
u(n, "w:showingPlcHdr") && (e.placeholder = !0);
|
|
963
|
+
const h = u(n, "w:lock"), d = h && v(h, "w:val");
|
|
964
|
+
return (d === "contentLocked" || d === "sdtContentLocked") && (e.lockContent = !0), (d === "sdtLocked" || d === "sdtContentLocked") && (e.lockControl = !0), e;
|
|
965
|
+
}
|
|
966
|
+
function ut(n, e) {
|
|
967
|
+
if (n.kind === "paragraph") {
|
|
968
|
+
for (const t of n.inlines)
|
|
969
|
+
t.kind === "run" && t.sdtId === void 0 && (t.sdtId = e);
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
for (const t of n.rows)
|
|
973
|
+
for (const o of t.cells) for (const r of o.blocks) ut(r, e);
|
|
974
|
+
}
|
|
975
|
+
function nn(n, e) {
|
|
976
|
+
const t = {}, o = u(n, "w:pgSz"), r = x(o, "w:w");
|
|
977
|
+
r !== void 0 && (t.pageWidthTwips = r);
|
|
978
|
+
const i = x(o, "w:h");
|
|
979
|
+
i !== void 0 && (t.pageHeightTwips = i);
|
|
980
|
+
const s = u(n, "w:pgMar");
|
|
981
|
+
if (s) {
|
|
982
|
+
const c = x(s, "w:top"), p = x(s, "w:right"), m = x(s, "w:bottom"), T = x(s, "w:left");
|
|
983
|
+
c !== void 0 && p !== void 0 && m !== void 0 && T !== void 0 && (t.marginTwips = { top: c, right: p, bottom: m, left: T });
|
|
984
|
+
const b = x(s, "w:header");
|
|
985
|
+
b !== void 0 && (t.headerDistTwips = b);
|
|
986
|
+
const A = x(s, "w:footer");
|
|
987
|
+
A !== void 0 && (t.footerDistTwips = A);
|
|
988
|
+
}
|
|
989
|
+
const a = Je(ee(n, "w:headerReference"));
|
|
990
|
+
a && (t.headerRefs = a);
|
|
991
|
+
const f = Je(ee(n, "w:footerReference"));
|
|
992
|
+
f && (t.footerRefs = f), u(n, "w:titlePg") && (t.titlePg = !0);
|
|
993
|
+
const h = u(n, "w:cols");
|
|
994
|
+
if (h) {
|
|
995
|
+
const c = x(h, "w:num") ?? 1;
|
|
996
|
+
if (c > 1) {
|
|
997
|
+
t.columns = { count: c };
|
|
998
|
+
const p = x(h, "w:space");
|
|
999
|
+
p !== void 0 && (t.columns.spaceTwips = p);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
const d = x(u(n, "w:pgNumType"), "w:start");
|
|
1003
|
+
return d !== void 0 && (t.pageNumberStart = d), t;
|
|
1004
|
+
}
|
|
1005
|
+
function Je(n) {
|
|
1006
|
+
if (n.length === 0) return;
|
|
1007
|
+
const e = {};
|
|
1008
|
+
for (const t of n) {
|
|
1009
|
+
const o = v(t, "r:id");
|
|
1010
|
+
if (!o) continue;
|
|
1011
|
+
const r = v(t, "w:type") ?? "default";
|
|
1012
|
+
r === "first" ? e.first = o : r === "even" ? e.even = o : e.default = o;
|
|
1013
|
+
}
|
|
1014
|
+
return Object.keys(e).length > 0 ? e : void 0;
|
|
1015
|
+
}
|
|
1016
|
+
function on(n, e, t, o = {}) {
|
|
1017
|
+
const r = /* @__PURE__ */ new Map(), i = fe(de(n, e), "w:footnotes");
|
|
1018
|
+
if (!i) return r;
|
|
1019
|
+
const s = {
|
|
1020
|
+
warnings: t,
|
|
1021
|
+
fieldTokens: !1,
|
|
1022
|
+
sdts: o,
|
|
1023
|
+
nextSdt: { n: Object.keys(o).length },
|
|
1024
|
+
pendingBookmarks: [],
|
|
1025
|
+
currentBookmarks: null,
|
|
1026
|
+
pendingMarkers: [],
|
|
1027
|
+
currentMarkers: null
|
|
1028
|
+
};
|
|
1029
|
+
for (const a of ee(i, "w:footnote")) {
|
|
1030
|
+
const f = v(a, "w:id");
|
|
1031
|
+
if (f === void 0 || v(a, "w:type")) continue;
|
|
1032
|
+
const d = [];
|
|
1033
|
+
ve(Y(a), d, s), r.set(f, d);
|
|
1034
|
+
}
|
|
1035
|
+
return r;
|
|
1036
|
+
}
|
|
1037
|
+
const rn = () => {
|
|
1038
|
+
}, ht = {
|
|
1039
|
+
fontFamily: "Times New Roman, serif",
|
|
1040
|
+
fontSizePx: 16,
|
|
1041
|
+
// 12pt
|
|
1042
|
+
bold: !1,
|
|
1043
|
+
italic: !1,
|
|
1044
|
+
underline: !1,
|
|
1045
|
+
strikethrough: !1,
|
|
1046
|
+
color: "#000000"
|
|
1047
|
+
}, sn = {
|
|
1048
|
+
align: "left",
|
|
1049
|
+
lineHeight: 1,
|
|
1050
|
+
spaceBeforePx: 0,
|
|
1051
|
+
spaceAfterPx: 0,
|
|
1052
|
+
indentFirstLinePx: 0,
|
|
1053
|
+
indentLeftPx: 0
|
|
1054
|
+
}, an = { top: 0, right: 108, bottom: 0, left: 108 }, ke = {
|
|
1055
|
+
pageWidthPx: 816,
|
|
1056
|
+
pageHeightPx: 1056,
|
|
1057
|
+
marginPx: { top: 96, right: 96, bottom: 96, left: 96 }
|
|
1058
|
+
};
|
|
1059
|
+
function cn(n, e, t = {}, o = /* @__PURE__ */ new Map(), r = () => ({}), i) {
|
|
1060
|
+
let s = 0;
|
|
1061
|
+
const a = () => `i${s++}`, f = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), c = [], p = (l) => {
|
|
1062
|
+
let g = d.get(l);
|
|
1063
|
+
return g === void 0 && (g = String(d.size + 1), d.set(l, g), c.push(l)), g;
|
|
1064
|
+
}, m = /* @__PURE__ */ new Map(), T = (l) => {
|
|
1065
|
+
const g = m.get(l);
|
|
1066
|
+
if (g) return g;
|
|
1067
|
+
const y = o.get(l);
|
|
1068
|
+
if (!y) return;
|
|
1069
|
+
const C = dn(y);
|
|
1070
|
+
return m.set(l, C), C;
|
|
1071
|
+
}, b = Le(e.run(void 0, {})), A = Qe(e.para({})), E = () => ({
|
|
1072
|
+
kind: "paragraph",
|
|
1073
|
+
id: a(),
|
|
1074
|
+
revision: 0,
|
|
1075
|
+
runs: [{ text: "", style: { ...b } }],
|
|
1076
|
+
style: { ...A }
|
|
1077
|
+
}), _ = (l, g) => {
|
|
1078
|
+
if (!g) return 0;
|
|
1079
|
+
const y = T(g.numId);
|
|
1080
|
+
if (!y)
|
|
1081
|
+
return n.add("list-missing", "A list reference had no matching definition — markers were dropped."), 0;
|
|
1082
|
+
l.list = { listId: g.numId, level: g.level };
|
|
1083
|
+
const C = y.levels[Math.min(g.level, y.levels.length - 1)], w = C ? C.indentLeftPx : 0;
|
|
1084
|
+
return l.indentLeftPx = Math.max(0, B(l.indentLeftPx - w)), l.indentFirstLinePx = 0, w;
|
|
1085
|
+
}, O = (l) => {
|
|
1086
|
+
const g = l.sectionPgSize;
|
|
1087
|
+
return !!g && !!i && (g.w !== i.w || g.h !== i.h);
|
|
1088
|
+
}, V = (l) => O(l) || !!l.sectionColumns || l.sectionPageNumberStart !== void 0, X = (l) => {
|
|
1089
|
+
const g = {};
|
|
1090
|
+
if (l.sectionPgSize && (g.pageWidthPx = B(F(l.sectionPgSize.w)), g.pageHeightPx = B(F(l.sectionPgSize.h))), l.sectionMarginTwips) {
|
|
1091
|
+
const y = l.sectionMarginTwips;
|
|
1092
|
+
g.marginPx = {
|
|
1093
|
+
top: B(F(y.top)),
|
|
1094
|
+
right: B(F(y.right)),
|
|
1095
|
+
bottom: B(F(y.bottom)),
|
|
1096
|
+
left: B(F(y.left))
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
return l.sectionColumns && (g.columns = { count: l.sectionColumns.count, gapPx: B(F(l.sectionColumns.spaceTwips ?? 720)) }), l.sectionPageNumberStart !== void 0 && (g.pageNumberStart = l.sectionPageNumberStart), g;
|
|
1100
|
+
}, j = (l) => {
|
|
1101
|
+
for (let g = l.length - 1; g >= 0; g--) if (l[g].kind === "paragraph") return l[g];
|
|
1102
|
+
}, te = (l, g, y = rn) => {
|
|
1103
|
+
const C = [];
|
|
1104
|
+
let w = !1, I = !1, L = !1, M = !1;
|
|
1105
|
+
const z = (D) => D.some((S) => S.kind !== "paragraph" || S.runs.some((P) => P.text.trim().length > 0 && !P.style.hidden)), U = (D) => {
|
|
1106
|
+
for (let S = D + 1; S < l.length; S++) {
|
|
1107
|
+
const P = l[S];
|
|
1108
|
+
if (P.kind !== "paragraph") return !1;
|
|
1109
|
+
if (P.inlines.some(
|
|
1110
|
+
(N) => N.kind === "run" && N.text.trim().length > 0 && !N.props.vanish
|
|
1111
|
+
))
|
|
1112
|
+
return e.isHeading(P.props.styleId) ? !0 : (P.bookmarks ?? []).some((N) => /toc/i.test(N));
|
|
1113
|
+
}
|
|
1114
|
+
return !1;
|
|
1115
|
+
};
|
|
1116
|
+
for (let D = 0; D < l.length; D++) {
|
|
1117
|
+
const S = l[D], P = S.kind === "paragraph" ? q(S, g, y) : [ne(S, g, y)];
|
|
1118
|
+
if (w && P.length > 0) {
|
|
1119
|
+
const H = P[0];
|
|
1120
|
+
H.kind === "paragraph" && H.runs.every((k) => k.text.length === 0 || k.style.hidden) || ((S.kind === "paragraph" && e.isHeading(S.props.styleId) || I) && (H.kind === "paragraph" ? H.style.pageBreakBefore = !0 : P.unshift({ ...E(), style: { ...A, pageBreakBefore: !0 } })), w = !1, I = !1);
|
|
1121
|
+
}
|
|
1122
|
+
if (S.kind === "paragraph" && S.props.sectionBreak === "page") {
|
|
1123
|
+
const H = S.props;
|
|
1124
|
+
if (V(H)) {
|
|
1125
|
+
let N = j(P);
|
|
1126
|
+
N || (N = E(), P.push(N)), N.style.sectionBreak = { type: "nextPage", props: X(H) }, w = !1;
|
|
1127
|
+
} else
|
|
1128
|
+
H.sectionHasBands && n.add(
|
|
1129
|
+
"section-bands-flattened",
|
|
1130
|
+
"Per-section headers/footers on geometry-preserving section breaks were not applied (the document section's are used)."
|
|
1131
|
+
), w = !0, I = !L && M || U(D);
|
|
1132
|
+
L = !0;
|
|
1133
|
+
}
|
|
1134
|
+
C.push(...P), L || (M ||= z(P));
|
|
1135
|
+
}
|
|
1136
|
+
return J(C), C;
|
|
1137
|
+
}, J = (l) => {
|
|
1138
|
+
const g = (w) => w.kind === "image" || w.kind === "table", y = (w) => w.kind === "paragraph" && w.runs.every((I) => I.text.trim().length === 0 || I.style.hidden), C = (w) => w.kind === "paragraph" ? w.runs.reduce((I, L) => I + L.text.length, 0) : 0;
|
|
1139
|
+
for (let w = 0; w < l.length; w++) {
|
|
1140
|
+
const I = l[w];
|
|
1141
|
+
if (I.kind !== "paragraph" || !I.style.namedStyle || !e.isHeading(I.style.namedStyle)) continue;
|
|
1142
|
+
const L = [];
|
|
1143
|
+
let M = 0, z = -1;
|
|
1144
|
+
for (let U = w + 1; U < l.length && U <= w + 6; U++) {
|
|
1145
|
+
const D = l[U];
|
|
1146
|
+
if (g(D)) {
|
|
1147
|
+
z = U;
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
if (D.kind !== "paragraph") break;
|
|
1151
|
+
if (!y(D)) {
|
|
1152
|
+
if (M >= 2 || C(D) > 300) break;
|
|
1153
|
+
M++, L.push(D);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
if (!(z < 0)) {
|
|
1157
|
+
I.style.keepWithNext = !0;
|
|
1158
|
+
for (const U of L) U.style.keepWithNext = !0;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
function q(l, g, y) {
|
|
1163
|
+
const C = e.para(l.props), w = Qe(C), I = _(w, C.list), L = Le(e.run(l.props.styleId, l.props.markRunProps ?? {})), M = [];
|
|
1164
|
+
let z = [], U = !1, D = !1, S = !1;
|
|
1165
|
+
const P = (k) => {
|
|
1166
|
+
const G = { ...w };
|
|
1167
|
+
return D && (G.pageBreakBefore = !0, D = !1), S && (G.columnBreakBefore = !0, S = !1), {
|
|
1168
|
+
kind: "paragraph",
|
|
1169
|
+
id: a(),
|
|
1170
|
+
revision: 0,
|
|
1171
|
+
runs: It(k, L),
|
|
1172
|
+
style: G
|
|
1173
|
+
};
|
|
1174
|
+
}, H = () => {
|
|
1175
|
+
z.length !== 0 && (M.push(P(z)), z = []);
|
|
1176
|
+
};
|
|
1177
|
+
for (const k of l.inlines)
|
|
1178
|
+
switch (k.kind) {
|
|
1179
|
+
case "break":
|
|
1180
|
+
!k.page && !k.column && n.add("soft-breaks", "Soft line breaks (Shift+Enter) became paragraph breaks."), z.length > 0 ? H() : M.push(P([])), k.page && (D = !0), k.column && (S = !0), U = !0;
|
|
1181
|
+
break;
|
|
1182
|
+
case "image": {
|
|
1183
|
+
const G = ce(k, g, w.align);
|
|
1184
|
+
G && (H(), (D || S) && M.push(P([])), M.push(G), U = !1);
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
case "run": {
|
|
1188
|
+
const G = e.run(l.props.styleId, k.props);
|
|
1189
|
+
z.push(R(k.text, G, y, k.sdtId)), U = !1;
|
|
1190
|
+
break;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
H(), (U || M.length === 0) && M.push(P([]));
|
|
1194
|
+
const N = M.filter((k) => k.kind === "paragraph");
|
|
1195
|
+
if (N.forEach((k, G) => {
|
|
1196
|
+
G > 0 && (k.style.spaceBeforePx = 0), G < N.length - 1 && (k.style.spaceAfterPx = 0), G > 0 && k.style.list && (delete k.style.list, k.style.indentLeftPx = B(k.style.indentLeftPx + I));
|
|
1197
|
+
}), l.bookmarkMarkers && l.bookmarkMarkers.length > 0 && M[0]) {
|
|
1198
|
+
const k = M[0], G = k.kind === "paragraph" ? k.runs.reduce((Q, Z) => Q + Z.text.length, 0) : 0;
|
|
1199
|
+
for (const Q of l.bookmarkMarkers) {
|
|
1200
|
+
const Z = { blockId: k.id, offset: Math.min(Q.offset, G) };
|
|
1201
|
+
Q.kind === "start" && Q.name ? f.set(Q.id, { name: Q.name, pos: Z }) : Q.kind === "end" && h.set(Q.id, Z);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return M;
|
|
1205
|
+
}
|
|
1206
|
+
function ce(l, g, y) {
|
|
1207
|
+
const C = g.resolve(l.relId);
|
|
1208
|
+
if (!C) return;
|
|
1209
|
+
if (l.widthEmu === void 0 || l.heightEmu === void 0) {
|
|
1210
|
+
n.add("images-unsized", "An image without explicit dimensions was skipped.");
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const w = {
|
|
1214
|
+
kind: "image",
|
|
1215
|
+
id: a(),
|
|
1216
|
+
revision: 0,
|
|
1217
|
+
src: C,
|
|
1218
|
+
widthPx: B(Ke(l.widthEmu)),
|
|
1219
|
+
heightPx: B(Ke(l.heightEmu)),
|
|
1220
|
+
align: l.anchorAlign ?? (y === "justify" ? "left" : y)
|
|
1221
|
+
};
|
|
1222
|
+
return l.anchored && l.anchorWrap === "square" && (w.wrap = "square"), w;
|
|
1223
|
+
}
|
|
1224
|
+
function R(l, g, y, C) {
|
|
1225
|
+
let w = l;
|
|
1226
|
+
const I = Le(g);
|
|
1227
|
+
if (g.linkRelId) {
|
|
1228
|
+
const L = y(g.linkRelId);
|
|
1229
|
+
L ? I.link = L : n.add("links-unresolved", "A hyperlink target could not be resolved and was dropped.");
|
|
1230
|
+
} else g.linkAnchor && (I.link = `#${g.linkAnchor}`);
|
|
1231
|
+
if (g.footnoteId !== void 0 && (w = p(g.footnoteId), I.footnoteRef = `fn${g.footnoteId}`, I.verticalAlign = "super"), C) {
|
|
1232
|
+
I.sdtId = C;
|
|
1233
|
+
const L = t[C];
|
|
1234
|
+
L?.type === "checkbox" && w.length > 0 && (w = L.checked ? "☒" : "☐", I.fontFamily = ht.fontFamily);
|
|
1235
|
+
}
|
|
1236
|
+
return { text: w, style: I };
|
|
1237
|
+
}
|
|
1238
|
+
function W(l, g, y, C, w, I) {
|
|
1239
|
+
const L = l.cell.rowSpan ?? 1, M = {
|
|
1240
|
+
top: l.startRow === 0,
|
|
1241
|
+
bottom: l.startRow + L - 1 === I - 1,
|
|
1242
|
+
left: l.startCol === 0,
|
|
1243
|
+
right: l.startCol + l.colSpan - 1 === w - 1
|
|
1244
|
+
}, z = l.ir?.shd ?? g.shd ?? y.shd;
|
|
1245
|
+
if (z && (l.cell.shading = z), C) {
|
|
1246
|
+
const U = { cell: l.ir?.borders, table: g.borders, style: y.borders };
|
|
1247
|
+
l.cell.borders = _t(U, M);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function ne(l, g, y) {
|
|
1251
|
+
const C = (S) => {
|
|
1252
|
+
const P = [];
|
|
1253
|
+
for (const k of S.blocks)
|
|
1254
|
+
k.kind === "paragraph" ? P.push(...q(k, g, y)) : P.push(ne(k, g, y));
|
|
1255
|
+
const H = { id: a(), blocks: P.length > 0 ? P : [E()] };
|
|
1256
|
+
S.gridSpan > 1 && (H.colSpan = S.gridSpan);
|
|
1257
|
+
const N = (k) => S.marginTwips?.[k] ?? l.cellMarginTwips?.[k] ?? an[k];
|
|
1258
|
+
return H.margin = {
|
|
1259
|
+
top: B(F(N("top"))),
|
|
1260
|
+
right: B(F(N("right"))),
|
|
1261
|
+
bottom: B(F(N("bottom"))),
|
|
1262
|
+
left: B(F(N("left")))
|
|
1263
|
+
}, H;
|
|
1264
|
+
}, w = Math.max(1, ...l.rows.map((S) => S.cells.reduce((P, H) => P + Math.max(1, H.gridSpan), 0))), I = new Array(w), L = l.rows.map((S, P) => {
|
|
1265
|
+
const H = [];
|
|
1266
|
+
let N = 0;
|
|
1267
|
+
for (const k of S.cells) {
|
|
1268
|
+
if (N >= w) break;
|
|
1269
|
+
const G = Math.max(1, Math.min(k.gridSpan, w - N));
|
|
1270
|
+
if (k.vMergeContinue) {
|
|
1271
|
+
const Z = I[N];
|
|
1272
|
+
Z ? Z.rowSpan = (Z.rowSpan ?? 1) + 1 : n.add("cell-vmerge-orphan", "A merged-cell continuation had no cell above to extend."), N += G;
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
const Q = C(k);
|
|
1276
|
+
H.push({ cell: Q, ir: k, startRow: P, startCol: N, colSpan: G });
|
|
1277
|
+
for (let Z = 0; Z < G && N + Z < w; Z++) I[N + Z] = Q;
|
|
1278
|
+
N += G;
|
|
1279
|
+
}
|
|
1280
|
+
for (; N < w; ) {
|
|
1281
|
+
const k = { id: a(), blocks: [E()] };
|
|
1282
|
+
H.push({ cell: k, ir: null, startRow: P, startCol: N, colSpan: 1 }), I[N] = k, N += 1;
|
|
1283
|
+
}
|
|
1284
|
+
return H;
|
|
1285
|
+
}), M = l.styleId ? r(l.styleId) : {}, z = !!M.borders || !!l.borders || !!l.bordersSpecified || l.rows.some((S) => S.cells.some((P) => P.borders || P.bordersSpecified));
|
|
1286
|
+
for (const S of L) for (const P of S) W(P, l, M, z, w, l.rows.length);
|
|
1287
|
+
const U = L.map((S) => ({ cells: S.map((P) => P.cell) })), D = { kind: "table", id: a(), revision: 0, rows: U };
|
|
1288
|
+
return D.colFractions = gn(l.colWidthsTwips, w), D;
|
|
1289
|
+
}
|
|
1290
|
+
function K(l) {
|
|
1291
|
+
if (!l) return { ...ke, marginPx: { ...ke.marginPx } };
|
|
1292
|
+
const g = {
|
|
1293
|
+
pageWidthPx: l.pageWidthTwips !== void 0 ? B(F(l.pageWidthTwips)) : ke.pageWidthPx,
|
|
1294
|
+
pageHeightPx: l.pageHeightTwips !== void 0 ? B(F(l.pageHeightTwips)) : ke.pageHeightPx,
|
|
1295
|
+
marginPx: l.marginTwips ? {
|
|
1296
|
+
top: B(F(l.marginTwips.top)),
|
|
1297
|
+
right: B(F(l.marginTwips.right)),
|
|
1298
|
+
bottom: B(F(l.marginTwips.bottom)),
|
|
1299
|
+
left: B(F(l.marginTwips.left))
|
|
1300
|
+
} : { ...ke.marginPx }
|
|
1301
|
+
};
|
|
1302
|
+
return l.columns && (g.columns = { count: l.columns.count, gapPx: B(F(l.columns.spaceTwips ?? 720)) }), l.pageNumberStart !== void 0 && (g.pageNumberStart = l.pageNumberStart), l.headerDistTwips !== void 0 && (g.headerDistancePx = B(F(l.headerDistTwips))), l.footerDistTwips !== void 0 && (g.footerDistancePx = B(F(l.footerDistTwips))), g;
|
|
1303
|
+
}
|
|
1304
|
+
return {
|
|
1305
|
+
mapBlocks: te,
|
|
1306
|
+
mapSection: K,
|
|
1307
|
+
emptyParagraph: E,
|
|
1308
|
+
lists: () => Object.fromEntries(m),
|
|
1309
|
+
bookmarks: () => {
|
|
1310
|
+
const l = {};
|
|
1311
|
+
for (const [g, y] of f)
|
|
1312
|
+
l[y.name] = { start: y.pos, end: h.get(g) ?? y.pos };
|
|
1313
|
+
return l;
|
|
1314
|
+
},
|
|
1315
|
+
footnoteRefs: () => c.map((l) => ({ docxId: l, noteId: `fn${l}` }))
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
const ln = {
|
|
1319
|
+
decimal: "decimal",
|
|
1320
|
+
decimalZero: "decimal",
|
|
1321
|
+
lowerLetter: "lowerLetter",
|
|
1322
|
+
upperLetter: "upperLetter",
|
|
1323
|
+
lowerRoman: "lowerRoman",
|
|
1324
|
+
upperRoman: "upperRoman",
|
|
1325
|
+
bullet: "bullet"
|
|
1326
|
+
};
|
|
1327
|
+
function fn(n) {
|
|
1328
|
+
if (n.length !== 1) return n;
|
|
1329
|
+
switch (n.charCodeAt(0)) {
|
|
1330
|
+
case 61623:
|
|
1331
|
+
// Symbol (filled round bullet)
|
|
1332
|
+
case 183:
|
|
1333
|
+
return "•";
|
|
1334
|
+
// •
|
|
1335
|
+
case 61607:
|
|
1336
|
+
// Wingdings (filled square)
|
|
1337
|
+
case 167:
|
|
1338
|
+
return "▪";
|
|
1339
|
+
// ▪
|
|
1340
|
+
case 61551:
|
|
1341
|
+
return "▫";
|
|
1342
|
+
// ▫
|
|
1343
|
+
case 61656:
|
|
1344
|
+
return "‣";
|
|
1345
|
+
// ‣
|
|
1346
|
+
case 61692:
|
|
1347
|
+
return "✔";
|
|
1348
|
+
// ✔
|
|
1349
|
+
default:
|
|
1350
|
+
return n;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
function dn(n) {
|
|
1354
|
+
const e = [];
|
|
1355
|
+
for (let t = 0; t < 9; t++)
|
|
1356
|
+
e.push(un(n.levels[t], t));
|
|
1357
|
+
return { id: n.id, levels: e };
|
|
1358
|
+
}
|
|
1359
|
+
function un(n, e) {
|
|
1360
|
+
if (!n)
|
|
1361
|
+
return { format: "decimal", text: `%${e + 1}.`, indentLeftPx: 24 + e * 24, hangingPx: 18, start: 1 };
|
|
1362
|
+
const t = ln[n.format] ?? (n.format === "none" ? "bullet" : "decimal"), o = {
|
|
1363
|
+
format: t,
|
|
1364
|
+
text: t === "bullet" ? "" : n.lvlText,
|
|
1365
|
+
indentLeftPx: n.indentLeftTwips !== void 0 ? B(F(n.indentLeftTwips)) : 24 + e * 24,
|
|
1366
|
+
hangingPx: n.hangingTwips !== void 0 ? B(F(n.hangingTwips)) : 18,
|
|
1367
|
+
start: n.start
|
|
1368
|
+
};
|
|
1369
|
+
if (t === "bullet" && (o.bulletChar = n.format === "none" ? "" : fn(n.lvlText)), n.markerRunProps) {
|
|
1370
|
+
const r = wt(n.markerRunProps);
|
|
1371
|
+
Object.keys(r).length > 0 && (o.markerStyle = r);
|
|
1372
|
+
}
|
|
1373
|
+
return o;
|
|
1374
|
+
}
|
|
1375
|
+
const hn = {
|
|
1376
|
+
left: "left",
|
|
1377
|
+
start: "left",
|
|
1378
|
+
num: "left",
|
|
1379
|
+
center: "center",
|
|
1380
|
+
right: "right",
|
|
1381
|
+
end: "right",
|
|
1382
|
+
decimal: "decimal"
|
|
1383
|
+
}, pn = {
|
|
1384
|
+
dot: "dot",
|
|
1385
|
+
middleDot: "dot",
|
|
1386
|
+
hyphen: "dash",
|
|
1387
|
+
underscore: "underscore"
|
|
1388
|
+
};
|
|
1389
|
+
function pt(n) {
|
|
1390
|
+
const e = n.map((t) => {
|
|
1391
|
+
const o = { posPx: B(F(t.posTwips)) }, r = t.val ? hn[t.val] : void 0;
|
|
1392
|
+
r && r !== "left" && (o.align = r);
|
|
1393
|
+
const i = t.leader ? pn[t.leader] : void 0;
|
|
1394
|
+
return i && (o.leader = i), o;
|
|
1395
|
+
});
|
|
1396
|
+
return e.sort((t, o) => t.posPx - o.posPx), e;
|
|
1397
|
+
}
|
|
1398
|
+
function gn(n, e) {
|
|
1399
|
+
const t = n && n.length === e && n.reduce((o, r) => o + r, 0) > 0 ? n.map((o) => Math.round(o / n.reduce((r, i) => r + i, 0) * 1e4) / 1e4) : Array.from({ length: e }, () => Math.round(1 / e * 1e4) / 1e4);
|
|
1400
|
+
return t[t.length - 1] = Math.round((1 - t.slice(0, -1).reduce((o, r) => o + r, 0)) * 1e4) / 1e4, t;
|
|
1401
|
+
}
|
|
1402
|
+
const mn = {
|
|
1403
|
+
yellow: "#ffff00",
|
|
1404
|
+
green: "#00ff00",
|
|
1405
|
+
cyan: "#00ffff",
|
|
1406
|
+
magenta: "#ff00ff",
|
|
1407
|
+
blue: "#0000ff",
|
|
1408
|
+
red: "#ff0000",
|
|
1409
|
+
darkBlue: "#000080",
|
|
1410
|
+
darkCyan: "#008080",
|
|
1411
|
+
darkGreen: "#008000",
|
|
1412
|
+
darkMagenta: "#800080",
|
|
1413
|
+
darkRed: "#800000",
|
|
1414
|
+
darkYellow: "#808000",
|
|
1415
|
+
darkGray: "#808080",
|
|
1416
|
+
lightGray: "#c0c0c0",
|
|
1417
|
+
black: "#000000",
|
|
1418
|
+
white: "#ffffff"
|
|
1419
|
+
};
|
|
1420
|
+
function Le(n) {
|
|
1421
|
+
const e = { ...ht };
|
|
1422
|
+
return gt(e, n), e;
|
|
1423
|
+
}
|
|
1424
|
+
function gt(n, e) {
|
|
1425
|
+
if (e.fontAscii && (n.fontFamily = `${e.fontAscii}, serif`), e.sizeHalfPoints !== void 0 && (n.fontSizePx = B(Ht(e.sizeHalfPoints))), e.bold !== void 0 && (n.bold = e.bold), e.italic !== void 0 && (n.italic = e.italic), e.underline !== void 0 && (n.underline = e.underline), e.strikethrough !== void 0 && (n.strikethrough = e.strikethrough), e.color && e.color !== "auto" && (n.color = `#${e.color.toLowerCase()}`), e.highlight) {
|
|
1426
|
+
const t = mn[e.highlight];
|
|
1427
|
+
t && (n.highlightColor = t);
|
|
1428
|
+
}
|
|
1429
|
+
e.vertAlign === "superscript" ? n.verticalAlign = "super" : e.vertAlign === "subscript" && (n.verticalAlign = "sub"), e.vanish && (n.hidden = !0);
|
|
1430
|
+
}
|
|
1431
|
+
function wn(n) {
|
|
1432
|
+
const e = {};
|
|
1433
|
+
for (const [t, o] of Object.entries(n)) {
|
|
1434
|
+
const r = { type: o.type };
|
|
1435
|
+
o.alias !== void 0 && (r.alias = o.alias), o.tag !== void 0 && (r.tag = o.tag), o.placeholder && (r.placeholder = !0), o.listItems !== void 0 && (r.listItems = o.listItems), o.dateFormat !== void 0 && (r.dateFormat = o.dateFormat), o.checked !== void 0 && (r.checked = o.checked), o.lockContent && (r.lockContent = !0), o.lockControl && (r.lockControl = !0), e[t] = r;
|
|
1436
|
+
}
|
|
1437
|
+
return e;
|
|
1438
|
+
}
|
|
1439
|
+
function mt(n, e = /* @__PURE__ */ new Set()) {
|
|
1440
|
+
for (const t of n)
|
|
1441
|
+
if (t.kind === "paragraph")
|
|
1442
|
+
t.props.styleId && e.add(t.props.styleId);
|
|
1443
|
+
else
|
|
1444
|
+
for (const o of t.rows) for (const r of o.cells) mt(r.blocks, e);
|
|
1445
|
+
return e;
|
|
1446
|
+
}
|
|
1447
|
+
function wt(n) {
|
|
1448
|
+
const e = {};
|
|
1449
|
+
return gt(e, n), e;
|
|
1450
|
+
}
|
|
1451
|
+
function vn(n) {
|
|
1452
|
+
const e = {};
|
|
1453
|
+
return n.align && (e.align = n.align), n.lineHeight !== void 0 && (e.lineHeight = B(n.lineHeight)), n.spaceBeforeTwips !== void 0 && (e.spaceBeforePx = B(F(n.spaceBeforeTwips))), n.spaceAfterTwips !== void 0 && (e.spaceAfterPx = B(F(n.spaceAfterTwips))), n.indentLeftTwips !== void 0 && (e.indentLeftPx = B(F(n.indentLeftTwips))), n.indentRightTwips !== void 0 && (e.indentRightPx = B(F(n.indentRightTwips))), n.indentFirstLineTwips !== void 0 && (e.indentFirstLinePx = B(F(n.indentFirstLineTwips))), n.keepWithNext && (e.keepWithNext = !0), n.keepLinesTogether && (e.keepLinesTogether = !0), n.tabStops && (e.tabStops = pt(n.tabStops)), e;
|
|
1454
|
+
}
|
|
1455
|
+
function kn(n, e) {
|
|
1456
|
+
if (n.styles.size === 0) return;
|
|
1457
|
+
const t = /* @__PURE__ */ new Set(), o = (i) => {
|
|
1458
|
+
for (let s = n.styles.get(i); s && !t.has(s.id); s = s.basedOnId ? n.styles.get(s.basedOnId) : void 0)
|
|
1459
|
+
s.type === "paragraph" && t.add(s.id);
|
|
1460
|
+
};
|
|
1461
|
+
for (const i of e) o(i);
|
|
1462
|
+
if (n.defaultParaStyleId && o(n.defaultParaStyleId), t.size === 0) return;
|
|
1463
|
+
const r = [];
|
|
1464
|
+
for (const i of t) {
|
|
1465
|
+
const s = n.styles.get(i), a = {
|
|
1466
|
+
id: i,
|
|
1467
|
+
name: s.name ?? i,
|
|
1468
|
+
char: wt(s.rPr),
|
|
1469
|
+
para: vn(s.pPr)
|
|
1470
|
+
};
|
|
1471
|
+
s.basedOnId && t.has(s.basedOnId) && (a.basedOn = s.basedOnId), r.push(a);
|
|
1472
|
+
}
|
|
1473
|
+
return r.sort(
|
|
1474
|
+
(i, s) => i.id === n.defaultParaStyleId ? -1 : s.id === n.defaultParaStyleId ? 1 : i.name.localeCompare(s.name)
|
|
1475
|
+
), { styles: r, defaultStyleId: n.defaultParaStyleId ?? r[0].id };
|
|
1476
|
+
}
|
|
1477
|
+
function Qe(n) {
|
|
1478
|
+
const e = { ...sn };
|
|
1479
|
+
return n.align && (e.align = n.align), n.lineHeight !== void 0 && (e.lineHeight = B(n.lineHeight)), n.spaceBeforeTwips !== void 0 && (e.spaceBeforePx = B(F(n.spaceBeforeTwips))), n.spaceAfterTwips !== void 0 && (e.spaceAfterPx = B(F(n.spaceAfterTwips))), n.indentLeftTwips !== void 0 && (e.indentLeftPx = B(F(n.indentLeftTwips))), n.indentRightTwips !== void 0 && (e.indentRightPx = B(F(n.indentRightTwips))), n.indentFirstLineTwips !== void 0 && (e.indentFirstLinePx = B(F(n.indentFirstLineTwips))), n.keepWithNext && (e.keepWithNext = !0), n.keepLinesTogether && (e.keepLinesTogether = !0), n.tabStops && (e.tabStops = pt(n.tabStops)), n.pageBreakBefore && (e.pageBreakBefore = !0), n.styleId && (e.namedStyle = n.styleId), e;
|
|
1480
|
+
}
|
|
1481
|
+
const bn = {
|
|
1482
|
+
png: "image/png",
|
|
1483
|
+
jpg: "image/jpeg",
|
|
1484
|
+
jpeg: "image/jpeg",
|
|
1485
|
+
gif: "image/gif",
|
|
1486
|
+
bmp: "image/bmp",
|
|
1487
|
+
webp: "image/webp",
|
|
1488
|
+
svg: "image/svg+xml"
|
|
1489
|
+
};
|
|
1490
|
+
function yn(n, e, t, o) {
|
|
1491
|
+
const r = /* @__PURE__ */ new Map(), i = [];
|
|
1492
|
+
return {
|
|
1493
|
+
resolve(s) {
|
|
1494
|
+
const a = e.get(s);
|
|
1495
|
+
if (!a) {
|
|
1496
|
+
t.add("media-missing", "An image reference had no matching relationship — skipped.");
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
if (r.has(a.target)) return r.get(a.target);
|
|
1500
|
+
if (a.external) {
|
|
1501
|
+
const c = /^https?:\/\//i.test(a.target);
|
|
1502
|
+
c ? t.add("media-external", "Linked (external) images load from their original URL.") : t.add(
|
|
1503
|
+
"media-external-unreachable",
|
|
1504
|
+
"Linked images pointing at local files can't be loaded in the browser — skipped."
|
|
1505
|
+
);
|
|
1506
|
+
const p = c ? a.target : void 0;
|
|
1507
|
+
return r.set(a.target, p), p;
|
|
1508
|
+
}
|
|
1509
|
+
let f;
|
|
1510
|
+
const h = a.target.slice(a.target.lastIndexOf(".") + 1).toLowerCase(), d = bn[h];
|
|
1511
|
+
if (!d)
|
|
1512
|
+
t.add(
|
|
1513
|
+
"media-unsupported",
|
|
1514
|
+
`Some images use formats browsers can't display (.${h}, typically metafiles) — skipped.`
|
|
1515
|
+
);
|
|
1516
|
+
else {
|
|
1517
|
+
const c = n.part(a.target);
|
|
1518
|
+
if (!c)
|
|
1519
|
+
t.add("media-missing", "An image reference had no matching relationship — skipped.");
|
|
1520
|
+
else {
|
|
1521
|
+
const p = new Uint8Array(c);
|
|
1522
|
+
o ? f = o.add(p, d) : (f = URL.createObjectURL(new Blob([p], { type: d })), i.push(f));
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return r.set(a.target, f), f;
|
|
1526
|
+
},
|
|
1527
|
+
urls: () => [...i]
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
const xn = /* @__PURE__ */ new Map();
|
|
1531
|
+
function Pn(n) {
|
|
1532
|
+
const e = /* @__PURE__ */ new Map(), t = fe(de(n, "numbering.xml"), "w:numbering");
|
|
1533
|
+
if (!t) return e;
|
|
1534
|
+
const o = /* @__PURE__ */ new Map();
|
|
1535
|
+
for (const r of ee(t, "w:abstractNum")) {
|
|
1536
|
+
const i = v(r, "w:abstractNumId");
|
|
1537
|
+
i !== void 0 && o.set(i, Tn(r));
|
|
1538
|
+
}
|
|
1539
|
+
for (const r of ee(t, "w:num")) {
|
|
1540
|
+
const i = v(r, "w:numId");
|
|
1541
|
+
if (i === void 0) continue;
|
|
1542
|
+
const s = se(r, "w:abstractNumId"), a = s !== void 0 ? o.get(s) : void 0;
|
|
1543
|
+
if (!a) continue;
|
|
1544
|
+
const f = a.map((h) => ({ ...h }));
|
|
1545
|
+
for (const h of ee(r, "w:lvlOverride")) {
|
|
1546
|
+
const d = x(h, "w:ilvl") ?? 0, c = x(u(h, "w:startOverride"), "w:val"), p = u(h, "w:lvl");
|
|
1547
|
+
p && f[d] && (f[d] = vt(p, d)), c !== void 0 && f[d] && (f[d].start = c);
|
|
1548
|
+
}
|
|
1549
|
+
e.set(i, { id: i, levels: f });
|
|
1550
|
+
}
|
|
1551
|
+
return e;
|
|
1552
|
+
}
|
|
1553
|
+
function Tn(n) {
|
|
1554
|
+
const e = [];
|
|
1555
|
+
for (const t of ee(n, "w:lvl")) {
|
|
1556
|
+
const o = x(t, "w:ilvl") ?? e.length;
|
|
1557
|
+
e[o] = vt(t, o);
|
|
1558
|
+
}
|
|
1559
|
+
return e;
|
|
1560
|
+
}
|
|
1561
|
+
function vt(n, e) {
|
|
1562
|
+
const t = u(n, "w:lvlText"), o = {
|
|
1563
|
+
format: se(n, "w:numFmt") ?? "decimal",
|
|
1564
|
+
lvlText: t ? v(t, "w:val") ?? "" : `%${e + 1}.`,
|
|
1565
|
+
start: x(u(n, "w:start"), "w:val") ?? 1
|
|
1566
|
+
}, r = u(n, "w:pPr"), i = r && u(r, "w:ind");
|
|
1567
|
+
if (i) {
|
|
1568
|
+
const a = x(i, "w:left") ?? x(i, "w:start");
|
|
1569
|
+
a !== void 0 && (o.indentLeftTwips = a);
|
|
1570
|
+
const f = x(i, "w:hanging");
|
|
1571
|
+
f !== void 0 && (o.hangingTwips = f);
|
|
1572
|
+
}
|
|
1573
|
+
const s = u(n, "w:rPr");
|
|
1574
|
+
return s && (o.markerRunProps = we(s)), o;
|
|
1575
|
+
}
|
|
1576
|
+
function Sn(n, e) {
|
|
1577
|
+
const t = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", o = /* @__PURE__ */ new Map(), r = fe(de(n, `${e} rels`), "Relationships");
|
|
1578
|
+
if (!r) return o;
|
|
1579
|
+
for (const i of Y(r)) {
|
|
1580
|
+
if (i.tagName !== "Relationship") continue;
|
|
1581
|
+
const s = v(i, "Id"), a = v(i, "Type"), f = v(i, "Target");
|
|
1582
|
+
if (!s || !a || !f) continue;
|
|
1583
|
+
const h = v(i, "TargetMode") === "External";
|
|
1584
|
+
o.set(s, { id: s, type: a, target: h ? f : An(t, f), external: h });
|
|
1585
|
+
}
|
|
1586
|
+
return o;
|
|
1587
|
+
}
|
|
1588
|
+
function An(n, e) {
|
|
1589
|
+
if (e.startsWith("/")) return e.slice(1);
|
|
1590
|
+
const t = n === "" ? [] : n.split("/");
|
|
1591
|
+
for (const o of e.split("/"))
|
|
1592
|
+
o === ".." ? t.pop() : o !== "." && o !== "" && t.push(o);
|
|
1593
|
+
return t.join("/");
|
|
1594
|
+
}
|
|
1595
|
+
function kt(n, e) {
|
|
1596
|
+
for (const t of n.values())
|
|
1597
|
+
if (t.type.endsWith(`/${e}`)) return t;
|
|
1598
|
+
}
|
|
1599
|
+
function Cn(n) {
|
|
1600
|
+
const e = n.lastIndexOf("/"), t = e >= 0 ? n.slice(0, e + 1) : "", o = e >= 0 ? n.slice(e + 1) : n;
|
|
1601
|
+
return `${t}_rels/${o}.rels`;
|
|
1602
|
+
}
|
|
1603
|
+
const Bn = { colors: /* @__PURE__ */ new Map() }, In = {
|
|
1604
|
+
dark1: "dk1",
|
|
1605
|
+
light1: "lt1",
|
|
1606
|
+
dark2: "dk2",
|
|
1607
|
+
light2: "lt2",
|
|
1608
|
+
text1: "dk1",
|
|
1609
|
+
background1: "lt1",
|
|
1610
|
+
text2: "dk2",
|
|
1611
|
+
background2: "lt2",
|
|
1612
|
+
hyperlink: "hlink",
|
|
1613
|
+
followedHyperlink: "folHlink"
|
|
1614
|
+
};
|
|
1615
|
+
function Ln(n, e) {
|
|
1616
|
+
return n.colors.get(In[e] ?? e);
|
|
1617
|
+
}
|
|
1618
|
+
function Mn(n, e) {
|
|
1619
|
+
if (e.startsWith("major")) return n.majorLatin;
|
|
1620
|
+
if (e.startsWith("minor")) return n.minorLatin;
|
|
1621
|
+
}
|
|
1622
|
+
function Rn(n) {
|
|
1623
|
+
const e = { colors: /* @__PURE__ */ new Map() }, t = fe(de(n, "theme"), "a:theme"), o = t && u(t, "a:themeElements");
|
|
1624
|
+
if (!o) return e;
|
|
1625
|
+
const r = u(o, "a:fontScheme");
|
|
1626
|
+
if (r) {
|
|
1627
|
+
const s = et(u(r, "a:majorFont"));
|
|
1628
|
+
s && (e.majorLatin = s);
|
|
1629
|
+
const a = et(u(r, "a:minorFont"));
|
|
1630
|
+
a && (e.minorLatin = a);
|
|
1631
|
+
}
|
|
1632
|
+
const i = u(o, "a:clrScheme");
|
|
1633
|
+
if (i)
|
|
1634
|
+
for (const s of Y(i)) {
|
|
1635
|
+
const a = s.tagName.replace(/^a:/, ""), f = u(s, "a:srgbClr"), h = u(s, "a:sysClr"), d = (f && v(f, "val")) ?? (h && v(h, "lastClr"));
|
|
1636
|
+
d && e.colors.set(a, d);
|
|
1637
|
+
}
|
|
1638
|
+
return e;
|
|
1639
|
+
}
|
|
1640
|
+
function et(n) {
|
|
1641
|
+
const e = n && u(n, "a:latin");
|
|
1642
|
+
return e && v(e, "typeface") || void 0;
|
|
1643
|
+
}
|
|
1644
|
+
const Nn = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() };
|
|
1645
|
+
function On(n, e) {
|
|
1646
|
+
const t = { docDefaultsRun: {}, docDefaultsPara: {}, styles: /* @__PURE__ */ new Map() }, o = fe(de(n, "styles.xml"), "w:styles");
|
|
1647
|
+
if (!o) return t;
|
|
1648
|
+
const r = u(o, "w:docDefaults");
|
|
1649
|
+
if (r) {
|
|
1650
|
+
const i = u(r, "w:rPrDefault"), s = i && u(i, "w:rPr");
|
|
1651
|
+
s && (t.docDefaultsRun = we(s));
|
|
1652
|
+
const a = u(r, "w:pPrDefault"), f = a && u(a, "w:pPr");
|
|
1653
|
+
f && (t.docDefaultsPara = De(f, e));
|
|
1654
|
+
}
|
|
1655
|
+
for (const i of ee(o, "w:style")) {
|
|
1656
|
+
const s = v(i, "w:styleId"), a = v(i, "w:type");
|
|
1657
|
+
if (!s || !a) continue;
|
|
1658
|
+
const f = u(i, "w:rPr"), h = u(i, "w:pPr"), d = {
|
|
1659
|
+
id: s,
|
|
1660
|
+
type: a,
|
|
1661
|
+
rPr: f ? we(f) : {},
|
|
1662
|
+
pPr: h ? De(h, e) : {}
|
|
1663
|
+
}, c = se(i, "w:name");
|
|
1664
|
+
c && (d.name = c);
|
|
1665
|
+
const p = se(i, "w:basedOn");
|
|
1666
|
+
if (p && (d.basedOnId = p), a === "table") {
|
|
1667
|
+
const T = u(i, "w:tblPr");
|
|
1668
|
+
if (T) {
|
|
1669
|
+
const b = Ue(u(T, "w:tblBorders"));
|
|
1670
|
+
b && (d.tblBorders = b);
|
|
1671
|
+
const A = Ge(u(T, "w:shd"));
|
|
1672
|
+
A && (d.tblShd = A);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
t.styles.set(s, d);
|
|
1676
|
+
const m = v(i, "w:default");
|
|
1677
|
+
a === "paragraph" && (m === "1" || m === "true") && (t.defaultParaStyleId = s);
|
|
1678
|
+
}
|
|
1679
|
+
return t;
|
|
1680
|
+
}
|
|
1681
|
+
function En(n, e) {
|
|
1682
|
+
let t, o;
|
|
1683
|
+
const r = /* @__PURE__ */ new Set(), i = [];
|
|
1684
|
+
for (let a = n.styles.get(e); a && !r.has(a.id); a = a.basedOnId ? n.styles.get(a.basedOnId) : void 0)
|
|
1685
|
+
r.add(a.id), i.unshift(a);
|
|
1686
|
+
for (const a of i)
|
|
1687
|
+
t = zt(t, a.tblBorders), a.tblShd !== void 0 && (o = a.tblShd);
|
|
1688
|
+
const s = {};
|
|
1689
|
+
return t && (s.borders = t), o !== void 0 && (s.shd = o), s;
|
|
1690
|
+
}
|
|
1691
|
+
const Fn = ["bold", "italic", "strikethrough", "vanish"];
|
|
1692
|
+
function Dn(n, e) {
|
|
1693
|
+
const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = (d) => {
|
|
1694
|
+
const c = [], p = /* @__PURE__ */ new Set();
|
|
1695
|
+
for (let m = n.styles.get(d); m && !p.has(m.id); m = m.basedOnId ? n.styles.get(m.basedOnId) : void 0)
|
|
1696
|
+
p.add(m.id), c.unshift(m);
|
|
1697
|
+
return c;
|
|
1698
|
+
}, i = (d) => {
|
|
1699
|
+
let c = t.get(d);
|
|
1700
|
+
return c || (c = r(d).reduce((p, m) => Se(p, m.rPr), {}), t.set(d, c)), c;
|
|
1701
|
+
}, s = (d) => {
|
|
1702
|
+
let c = o.get(d);
|
|
1703
|
+
return c || (c = r(d).reduce((p, m) => Be(p, m.pPr), {}), o.set(d, c)), c;
|
|
1704
|
+
}, a = /* @__PURE__ */ new Map(), f = (d, c) => {
|
|
1705
|
+
const p = `${d ?? ""}|${c ?? ""}`;
|
|
1706
|
+
let m = a.get(p);
|
|
1707
|
+
if (m) return m;
|
|
1708
|
+
const T = d ? i(d) : {}, b = c ? i(c) : {};
|
|
1709
|
+
m = Se(Se(n.docDefaultsRun, T), b);
|
|
1710
|
+
for (const A of Fn) {
|
|
1711
|
+
if (n.docDefaultsRun[A] === void 0 && T[A] === void 0 && b[A] === void 0) continue;
|
|
1712
|
+
const E = n.docDefaultsRun[A] ?? !1;
|
|
1713
|
+
m[A] = E !== (T[A] === !0) != (b[A] === !0);
|
|
1714
|
+
}
|
|
1715
|
+
return a.set(p, m), m;
|
|
1716
|
+
};
|
|
1717
|
+
return {
|
|
1718
|
+
run(d, c) {
|
|
1719
|
+
const p = d ?? n.defaultParaStyleId, m = f(p, c.styleId);
|
|
1720
|
+
return h(Se(m, c));
|
|
1721
|
+
},
|
|
1722
|
+
para(d) {
|
|
1723
|
+
const c = d.styleId ?? n.defaultParaStyleId, p = c ? s(c) : {}, m = Be(Be(n.docDefaultsPara, p), d);
|
|
1724
|
+
return d.styleId ? m.styleId = d.styleId : delete m.styleId, m;
|
|
1725
|
+
},
|
|
1726
|
+
isHeading(d) {
|
|
1727
|
+
if (!d) return !1;
|
|
1728
|
+
const c = (p) => p !== void 0 && /(^|\s)heading(\s|\d|$)/i.test(p);
|
|
1729
|
+
return r(d).some((p) => c(p.name) || c(p.id));
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
function h(d) {
|
|
1733
|
+
const c = { ...d };
|
|
1734
|
+
if (!c.fontAscii && c.fontThemeAscii) {
|
|
1735
|
+
const p = Mn(e, c.fontThemeAscii);
|
|
1736
|
+
p && (c.fontAscii = p);
|
|
1737
|
+
}
|
|
1738
|
+
if ((c.color === void 0 || c.color === "auto") && c.colorTheme) {
|
|
1739
|
+
const p = Ln(e, c.colorTheme);
|
|
1740
|
+
p && (c.color = p);
|
|
1741
|
+
}
|
|
1742
|
+
return c;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
function Se(n, e) {
|
|
1746
|
+
const t = { ...n };
|
|
1747
|
+
return (e.fontAscii !== void 0 || e.fontThemeAscii !== void 0) && (delete t.fontAscii, delete t.fontThemeAscii), (e.color !== void 0 || e.colorTheme !== void 0) && (delete t.color, delete t.colorTheme), Be(t, e);
|
|
1748
|
+
}
|
|
1749
|
+
function Be(n, e) {
|
|
1750
|
+
const t = { ...n };
|
|
1751
|
+
for (const [o, r] of Object.entries(e))
|
|
1752
|
+
r !== void 0 && (t[o] = r);
|
|
1753
|
+
return t;
|
|
1754
|
+
}
|
|
1755
|
+
var re = Uint8Array, me = Uint16Array, Hn = Int32Array, bt = new re([
|
|
1756
|
+
0,
|
|
1757
|
+
0,
|
|
1758
|
+
0,
|
|
1759
|
+
0,
|
|
1760
|
+
0,
|
|
1761
|
+
0,
|
|
1762
|
+
0,
|
|
1763
|
+
0,
|
|
1764
|
+
1,
|
|
1765
|
+
1,
|
|
1766
|
+
1,
|
|
1767
|
+
1,
|
|
1768
|
+
2,
|
|
1769
|
+
2,
|
|
1770
|
+
2,
|
|
1771
|
+
2,
|
|
1772
|
+
3,
|
|
1773
|
+
3,
|
|
1774
|
+
3,
|
|
1775
|
+
3,
|
|
1776
|
+
4,
|
|
1777
|
+
4,
|
|
1778
|
+
4,
|
|
1779
|
+
4,
|
|
1780
|
+
5,
|
|
1781
|
+
5,
|
|
1782
|
+
5,
|
|
1783
|
+
5,
|
|
1784
|
+
0,
|
|
1785
|
+
/* unused */
|
|
1786
|
+
0,
|
|
1787
|
+
0,
|
|
1788
|
+
/* impossible */
|
|
1789
|
+
0
|
|
1790
|
+
]), yt = new re([
|
|
1791
|
+
0,
|
|
1792
|
+
0,
|
|
1793
|
+
0,
|
|
1794
|
+
0,
|
|
1795
|
+
1,
|
|
1796
|
+
1,
|
|
1797
|
+
2,
|
|
1798
|
+
2,
|
|
1799
|
+
3,
|
|
1800
|
+
3,
|
|
1801
|
+
4,
|
|
1802
|
+
4,
|
|
1803
|
+
5,
|
|
1804
|
+
5,
|
|
1805
|
+
6,
|
|
1806
|
+
6,
|
|
1807
|
+
7,
|
|
1808
|
+
7,
|
|
1809
|
+
8,
|
|
1810
|
+
8,
|
|
1811
|
+
9,
|
|
1812
|
+
9,
|
|
1813
|
+
10,
|
|
1814
|
+
10,
|
|
1815
|
+
11,
|
|
1816
|
+
11,
|
|
1817
|
+
12,
|
|
1818
|
+
12,
|
|
1819
|
+
13,
|
|
1820
|
+
13,
|
|
1821
|
+
/* unused */
|
|
1822
|
+
0,
|
|
1823
|
+
0
|
|
1824
|
+
]), jn = new re([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), xt = function(n, e) {
|
|
1825
|
+
for (var t = new me(31), o = 0; o < 31; ++o)
|
|
1826
|
+
t[o] = e += 1 << n[o - 1];
|
|
1827
|
+
for (var r = new Hn(t[30]), o = 1; o < 30; ++o)
|
|
1828
|
+
for (var i = t[o]; i < t[o + 1]; ++i)
|
|
1829
|
+
r[i] = i - t[o] << 5 | o;
|
|
1830
|
+
return { b: t, r };
|
|
1831
|
+
}, Pt = xt(bt, 2), Tt = Pt.b, Wn = Pt.r;
|
|
1832
|
+
Tt[28] = 258, Wn[258] = 28;
|
|
1833
|
+
var zn = xt(yt, 0), _n = zn.b, je = new me(32768);
|
|
1834
|
+
for (var $ = 0; $ < 32768; ++$) {
|
|
1835
|
+
var ue = ($ & 43690) >> 1 | ($ & 21845) << 1;
|
|
1836
|
+
ue = (ue & 52428) >> 2 | (ue & 13107) << 2, ue = (ue & 61680) >> 4 | (ue & 3855) << 4, je[$] = ((ue & 65280) >> 8 | (ue & 255) << 8) >> 1;
|
|
1837
|
+
}
|
|
1838
|
+
var be = (function(n, e, t) {
|
|
1839
|
+
for (var o = n.length, r = 0, i = new me(e); r < o; ++r)
|
|
1840
|
+
n[r] && ++i[n[r] - 1];
|
|
1841
|
+
var s = new me(e);
|
|
1842
|
+
for (r = 1; r < e; ++r)
|
|
1843
|
+
s[r] = s[r - 1] + i[r - 1] << 1;
|
|
1844
|
+
var a;
|
|
1845
|
+
if (t) {
|
|
1846
|
+
a = new me(1 << e);
|
|
1847
|
+
var f = 15 - e;
|
|
1848
|
+
for (r = 0; r < o; ++r)
|
|
1849
|
+
if (n[r])
|
|
1850
|
+
for (var h = r << 4 | n[r], d = e - n[r], c = s[n[r] - 1]++ << d, p = c | (1 << d) - 1; c <= p; ++c)
|
|
1851
|
+
a[je[c] >> f] = h;
|
|
1852
|
+
} else
|
|
1853
|
+
for (a = new me(o), r = 0; r < o; ++r)
|
|
1854
|
+
n[r] && (a[r] = je[s[n[r] - 1]++] >> 15 - n[r]);
|
|
1855
|
+
return a;
|
|
1856
|
+
}), Pe = new re(288);
|
|
1857
|
+
for (var $ = 0; $ < 144; ++$)
|
|
1858
|
+
Pe[$] = 8;
|
|
1859
|
+
for (var $ = 144; $ < 256; ++$)
|
|
1860
|
+
Pe[$] = 9;
|
|
1861
|
+
for (var $ = 256; $ < 280; ++$)
|
|
1862
|
+
Pe[$] = 7;
|
|
1863
|
+
for (var $ = 280; $ < 288; ++$)
|
|
1864
|
+
Pe[$] = 8;
|
|
1865
|
+
var St = new re(32);
|
|
1866
|
+
for (var $ = 0; $ < 32; ++$)
|
|
1867
|
+
St[$] = 5;
|
|
1868
|
+
var $n = /* @__PURE__ */ be(Pe, 9, 1), Un = /* @__PURE__ */ be(St, 5, 1), Me = function(n) {
|
|
1869
|
+
for (var e = n[0], t = 1; t < n.length; ++t)
|
|
1870
|
+
n[t] > e && (e = n[t]);
|
|
1871
|
+
return e;
|
|
1872
|
+
}, ae = function(n, e, t) {
|
|
1873
|
+
var o = e / 8 | 0;
|
|
1874
|
+
return (n[o] | n[o + 1] << 8) >> (e & 7) & t;
|
|
1875
|
+
}, Re = function(n, e) {
|
|
1876
|
+
var t = e / 8 | 0;
|
|
1877
|
+
return (n[t] | n[t + 1] << 8 | n[t + 2] << 16) >> (e & 7);
|
|
1878
|
+
}, Gn = function(n) {
|
|
1879
|
+
return (n + 7) / 8 | 0;
|
|
1880
|
+
}, Xe = function(n, e, t) {
|
|
1881
|
+
return (e == null || e < 0) && (e = 0), (t == null || t > n.length) && (t = n.length), new re(n.subarray(e, t));
|
|
1882
|
+
}, Xn = [
|
|
1883
|
+
"unexpected EOF",
|
|
1884
|
+
"invalid block type",
|
|
1885
|
+
"invalid length/literal",
|
|
1886
|
+
"invalid distance",
|
|
1887
|
+
"stream finished",
|
|
1888
|
+
"no stream handler",
|
|
1889
|
+
,
|
|
1890
|
+
// determined by compression function
|
|
1891
|
+
"no callback",
|
|
1892
|
+
"invalid UTF-8 data",
|
|
1893
|
+
"extra field too long",
|
|
1894
|
+
"date not in range 1980-2099",
|
|
1895
|
+
"filename too long",
|
|
1896
|
+
"stream finishing",
|
|
1897
|
+
"invalid zip data"
|
|
1898
|
+
// determined by unknown compression method
|
|
1899
|
+
], oe = function(n, e, t) {
|
|
1900
|
+
var o = new Error(e || Xn[n]);
|
|
1901
|
+
if (o.code = n, Error.captureStackTrace && Error.captureStackTrace(o, oe), !t)
|
|
1902
|
+
throw o;
|
|
1903
|
+
return o;
|
|
1904
|
+
}, Vn = function(n, e, t, o) {
|
|
1905
|
+
var r = n.length, i = o ? o.length : 0;
|
|
1906
|
+
if (!r || e.f && !e.l)
|
|
1907
|
+
return t || new re(0);
|
|
1908
|
+
var s = !t, a = s || e.i != 2, f = e.i;
|
|
1909
|
+
s && (t = new re(r * 3));
|
|
1910
|
+
var h = function(G) {
|
|
1911
|
+
var Q = t.length;
|
|
1912
|
+
if (G > Q) {
|
|
1913
|
+
var Z = new re(Math.max(Q * 2, G));
|
|
1914
|
+
Z.set(t), t = Z;
|
|
1915
|
+
}
|
|
1916
|
+
}, d = e.f || 0, c = e.p || 0, p = e.b || 0, m = e.l, T = e.d, b = e.m, A = e.n, E = r * 8;
|
|
1917
|
+
do {
|
|
1918
|
+
if (!m) {
|
|
1919
|
+
d = ae(n, c, 1);
|
|
1920
|
+
var _ = ae(n, c + 1, 3);
|
|
1921
|
+
if (c += 3, _)
|
|
1922
|
+
if (_ == 1)
|
|
1923
|
+
m = $n, T = Un, b = 9, A = 5;
|
|
1924
|
+
else if (_ == 2) {
|
|
1925
|
+
var j = ae(n, c, 31) + 257, te = ae(n, c + 10, 15) + 4, J = j + ae(n, c + 5, 31) + 1;
|
|
1926
|
+
c += 14;
|
|
1927
|
+
for (var q = new re(J), ce = new re(19), R = 0; R < te; ++R)
|
|
1928
|
+
ce[jn[R]] = ae(n, c + R * 3, 7);
|
|
1929
|
+
c += te * 3;
|
|
1930
|
+
for (var W = Me(ce), ne = (1 << W) - 1, K = be(ce, W, 1), R = 0; R < J; ) {
|
|
1931
|
+
var l = K[ae(n, c, ne)];
|
|
1932
|
+
c += l & 15;
|
|
1933
|
+
var O = l >> 4;
|
|
1934
|
+
if (O < 16)
|
|
1935
|
+
q[R++] = O;
|
|
1936
|
+
else {
|
|
1937
|
+
var g = 0, y = 0;
|
|
1938
|
+
for (O == 16 ? (y = 3 + ae(n, c, 3), c += 2, g = q[R - 1]) : O == 17 ? (y = 3 + ae(n, c, 7), c += 3) : O == 18 && (y = 11 + ae(n, c, 127), c += 7); y--; )
|
|
1939
|
+
q[R++] = g;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
var C = q.subarray(0, j), w = q.subarray(j);
|
|
1943
|
+
b = Me(C), A = Me(w), m = be(C, b, 1), T = be(w, A, 1);
|
|
1944
|
+
} else
|
|
1945
|
+
oe(1);
|
|
1946
|
+
else {
|
|
1947
|
+
var O = Gn(c) + 4, V = n[O - 4] | n[O - 3] << 8, X = O + V;
|
|
1948
|
+
if (X > r) {
|
|
1949
|
+
f && oe(0);
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
a && h(p + V), t.set(n.subarray(O, X), p), e.b = p += V, e.p = c = X * 8, e.f = d;
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
if (c > E) {
|
|
1956
|
+
f && oe(0);
|
|
1957
|
+
break;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
a && h(p + 131072);
|
|
1961
|
+
for (var I = (1 << b) - 1, L = (1 << A) - 1, M = c; ; M = c) {
|
|
1962
|
+
var g = m[Re(n, c) & I], z = g >> 4;
|
|
1963
|
+
if (c += g & 15, c > E) {
|
|
1964
|
+
f && oe(0);
|
|
1965
|
+
break;
|
|
1966
|
+
}
|
|
1967
|
+
if (g || oe(2), z < 256)
|
|
1968
|
+
t[p++] = z;
|
|
1969
|
+
else if (z == 256) {
|
|
1970
|
+
M = c, m = null;
|
|
1971
|
+
break;
|
|
1972
|
+
} else {
|
|
1973
|
+
var U = z - 254;
|
|
1974
|
+
if (z > 264) {
|
|
1975
|
+
var R = z - 257, D = bt[R];
|
|
1976
|
+
U = ae(n, c, (1 << D) - 1) + Tt[R], c += D;
|
|
1977
|
+
}
|
|
1978
|
+
var S = T[Re(n, c) & L], P = S >> 4;
|
|
1979
|
+
S || oe(3), c += S & 15;
|
|
1980
|
+
var w = _n[P];
|
|
1981
|
+
if (P > 3) {
|
|
1982
|
+
var D = yt[P];
|
|
1983
|
+
w += Re(n, c) & (1 << D) - 1, c += D;
|
|
1984
|
+
}
|
|
1985
|
+
if (c > E) {
|
|
1986
|
+
f && oe(0);
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
a && h(p + 131072);
|
|
1990
|
+
var H = p + U;
|
|
1991
|
+
if (p < w) {
|
|
1992
|
+
var N = i - w, k = Math.min(w, H);
|
|
1993
|
+
for (N + p < 0 && oe(3); p < k; ++p)
|
|
1994
|
+
t[p] = o[N + p];
|
|
1995
|
+
}
|
|
1996
|
+
for (; p < H; ++p)
|
|
1997
|
+
t[p] = t[p - w];
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
e.l = m, e.p = M, e.b = p, e.f = d, m && (d = 1, e.m = b, e.d = T, e.n = A);
|
|
2001
|
+
} while (!d);
|
|
2002
|
+
return p != t.length && s ? Xe(t, 0, p) : t.subarray(0, p);
|
|
2003
|
+
}, qn = /* @__PURE__ */ new re(0), le = function(n, e) {
|
|
2004
|
+
return n[e] | n[e + 1] << 8;
|
|
2005
|
+
}, ie = function(n, e) {
|
|
2006
|
+
return (n[e] | n[e + 1] << 8 | n[e + 2] << 16 | n[e + 3] << 24) >>> 0;
|
|
2007
|
+
}, Ne = function(n, e) {
|
|
2008
|
+
return ie(n, e) + ie(n, e + 4) * 4294967296;
|
|
2009
|
+
};
|
|
2010
|
+
function Yn(n, e) {
|
|
2011
|
+
return Vn(n, { i: 2 }, e && e.out, e && e.dictionary);
|
|
2012
|
+
}
|
|
2013
|
+
var We = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Kn = 0;
|
|
2014
|
+
try {
|
|
2015
|
+
We.decode(qn, { stream: !0 }), Kn = 1;
|
|
2016
|
+
} catch {
|
|
2017
|
+
}
|
|
2018
|
+
var Zn = function(n) {
|
|
2019
|
+
for (var e = "", t = 0; ; ) {
|
|
2020
|
+
var o = n[t++], r = (o > 127) + (o > 223) + (o > 239);
|
|
2021
|
+
if (t + r > n.length)
|
|
2022
|
+
return { s: e, r: Xe(n, t - 1) };
|
|
2023
|
+
r ? r == 3 ? (o = ((o & 15) << 18 | (n[t++] & 63) << 12 | (n[t++] & 63) << 6 | n[t++] & 63) - 65536, e += String.fromCharCode(55296 | o >> 10, 56320 | o & 1023)) : r & 1 ? e += String.fromCharCode((o & 31) << 6 | n[t++] & 63) : e += String.fromCharCode((o & 15) << 12 | (n[t++] & 63) << 6 | n[t++] & 63) : e += String.fromCharCode(o);
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
function At(n, e) {
|
|
2027
|
+
if (e) {
|
|
2028
|
+
for (var t = "", o = 0; o < n.length; o += 16384)
|
|
2029
|
+
t += String.fromCharCode.apply(null, n.subarray(o, o + 16384));
|
|
2030
|
+
return t;
|
|
2031
|
+
} else {
|
|
2032
|
+
if (We)
|
|
2033
|
+
return We.decode(n);
|
|
2034
|
+
var r = Zn(n), i = r.s, t = r.r;
|
|
2035
|
+
return t.length && oe(8), i;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
var Jn = function(n, e) {
|
|
2039
|
+
return e + 30 + le(n, e + 26) + le(n, e + 28);
|
|
2040
|
+
}, Qn = function(n, e, t) {
|
|
2041
|
+
var o = le(n, e + 28), r = le(n, e + 30), i = At(n.subarray(e + 46, e + 46 + o), !(le(n, e + 8) & 2048)), s = e + 46 + o, a = eo(n, s, r, t, ie(n, e + 20), ie(n, e + 24), ie(n, e + 42)), f = a[0], h = a[1], d = a[2];
|
|
2042
|
+
return [le(n, e + 10), f, h, i, s + r + le(n, e + 32), d];
|
|
2043
|
+
}, eo = function(n, e, t, o, r, i, s) {
|
|
2044
|
+
var a = r == 4294967295, f = i == 4294967295, h = s == 4294967295, d = e + t, c = a + f + h;
|
|
2045
|
+
if (o && c) {
|
|
2046
|
+
for (; e + 4 < d; e += 4 + le(n, e + 2))
|
|
2047
|
+
if (le(n, e) == 1)
|
|
2048
|
+
return [
|
|
2049
|
+
a ? Ne(n, e + 4 + 8 * f) : r,
|
|
2050
|
+
f ? Ne(n, e + 4) : i,
|
|
2051
|
+
h ? Ne(n, e + 4 + 8 * (f + a)) : s,
|
|
2052
|
+
1
|
|
2053
|
+
];
|
|
2054
|
+
o < 2 && oe(13);
|
|
2055
|
+
}
|
|
2056
|
+
return [r, i, s, 0];
|
|
2057
|
+
};
|
|
2058
|
+
function tt(n, e) {
|
|
2059
|
+
for (var t = {}, o = n.length - 22; ie(n, o) != 101010256; --o)
|
|
2060
|
+
(!o || n.length - o > 65558) && oe(13);
|
|
2061
|
+
var r = le(n, o + 8);
|
|
2062
|
+
if (!r)
|
|
2063
|
+
return {};
|
|
2064
|
+
var i = ie(n, o + 16), s = ie(n, o - 20) == 117853008;
|
|
2065
|
+
if (s) {
|
|
2066
|
+
var a = ie(n, o - 12);
|
|
2067
|
+
s = ie(n, a) == 101075792, s && (r = ie(n, a + 32), i = ie(n, a + 48));
|
|
2068
|
+
}
|
|
2069
|
+
for (var f = e && e.filter, h = 0; h < r; ++h) {
|
|
2070
|
+
var d = Qn(n, i, s), c = d[0], p = d[1], m = d[2], T = d[3], b = d[4], A = d[5], E = Jn(n, A);
|
|
2071
|
+
i = b, (!f || f({
|
|
2072
|
+
name: T,
|
|
2073
|
+
size: p,
|
|
2074
|
+
originalSize: m,
|
|
2075
|
+
compression: c
|
|
2076
|
+
})) && (c ? c == 8 ? t[T] = Yn(n.subarray(E, E + p), { out: new re(m) }) : oe(14, "unknown compression type " + c) : t[T] = Xe(n, E, E + p));
|
|
2077
|
+
}
|
|
2078
|
+
return t;
|
|
2079
|
+
}
|
|
2080
|
+
const to = [80, 75], no = [208, 207, 17, 224], nt = (n, e) => e.every((t, o) => n[o] === t);
|
|
2081
|
+
function oo(n) {
|
|
2082
|
+
if (nt(n, no))
|
|
2083
|
+
throw new pe("ENCRYPTED", "Password-protected documents are not supported.");
|
|
2084
|
+
if (!nt(n, to))
|
|
2085
|
+
throw new pe("NOT_ZIP", "Not a .docx file (zip container signature missing).");
|
|
2086
|
+
const e = (s) => /^word\/media\//.test(s);
|
|
2087
|
+
let t, o;
|
|
2088
|
+
try {
|
|
2089
|
+
o = [], t = tt(n, {
|
|
2090
|
+
filter: (s) => e(s.name) ? (o.push(s.name), !1) : !0
|
|
2091
|
+
});
|
|
2092
|
+
} catch (s) {
|
|
2093
|
+
throw new pe("NOT_ZIP", `Corrupt zip container: ${s instanceof Error ? s.message : String(s)}`);
|
|
2094
|
+
}
|
|
2095
|
+
const r = /* @__PURE__ */ new Map(), i = (s) => {
|
|
2096
|
+
const a = tt(n, { filter: (f) => f.name === s })[s];
|
|
2097
|
+
return a && (t[s] = a), a;
|
|
2098
|
+
};
|
|
2099
|
+
return {
|
|
2100
|
+
part: (s) => t[s] ?? (e(s) ? i(s) : void 0),
|
|
2101
|
+
text(s) {
|
|
2102
|
+
const a = r.get(s);
|
|
2103
|
+
if (a !== void 0) return a;
|
|
2104
|
+
const f = t[s];
|
|
2105
|
+
if (!f) return;
|
|
2106
|
+
const h = At(f);
|
|
2107
|
+
return r.set(s, h), h;
|
|
2108
|
+
},
|
|
2109
|
+
names: () => [...Object.keys(t), ...o.filter((s) => !(s in t))]
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
function ro(n, e, t) {
|
|
2113
|
+
const o = (L, M) => (t?.onProgress ?? e)?.(L, M), r = new Lt(), i = [], s = {
|
|
2114
|
+
add(L, M) {
|
|
2115
|
+
const z = `cw-media:${i.length}`;
|
|
2116
|
+
return i.push({ src: z, bytes: L, mime: M }), z;
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
o("unzip", 0);
|
|
2120
|
+
const a = oo(n);
|
|
2121
|
+
o("unzip", 1);
|
|
2122
|
+
const f = a.text("[Content_Types].xml"), h = (f !== void 0 ? Dt(f) : void 0) ?? "word/document.xml", d = a.text(h);
|
|
2123
|
+
if (d === void 0)
|
|
2124
|
+
throw new pe("NO_DOCUMENT_PART", `Main document part "${h}" not found in the archive.`);
|
|
2125
|
+
const c = ze(a, h);
|
|
2126
|
+
o("styles", 0);
|
|
2127
|
+
const p = Ae(a, c, "styles") ?? a.text("word/styles.xml"), m = p !== void 0 ? On(p, r) : Nn, T = Ae(a, c, "theme") ?? a.text("word/theme/theme1.xml"), b = T !== void 0 ? Rn(T) : Bn, A = Dn(m, b), E = Ae(a, c, "numbering") ?? a.text("word/numbering.xml"), _ = E !== void 0 ? Pn(E) : xn;
|
|
2128
|
+
o("styles", 1), o("parse", 0);
|
|
2129
|
+
const O = Gt(d, h, r);
|
|
2130
|
+
o("parse", 1), o("map", 0);
|
|
2131
|
+
const V = {
|
|
2132
|
+
w: O.section?.pageWidthTwips ?? 12240,
|
|
2133
|
+
h: O.section?.pageHeightTwips ?? 15840
|
|
2134
|
+
}, X = cn(
|
|
2135
|
+
r,
|
|
2136
|
+
A,
|
|
2137
|
+
O.sdts,
|
|
2138
|
+
_,
|
|
2139
|
+
(L) => En(m, L),
|
|
2140
|
+
V
|
|
2141
|
+
), j = [], te = (L) => {
|
|
2142
|
+
const M = yn(a, L, r, s);
|
|
2143
|
+
return j.push(M), M;
|
|
2144
|
+
}, J = X.mapBlocks(O.blocks, te(c), _e(c));
|
|
2145
|
+
J.length === 0 && J.push(X.emptyParagraph());
|
|
2146
|
+
const q = X.mapSection(O.section), ce = Ae(a, c, "settings") ?? a.text("word/settings.xml"), R = ce !== void 0 && so(ce);
|
|
2147
|
+
ot(q, "header", O.section?.headerRefs, O.section?.titlePg ?? !1, R, a, c, X, te, r, O.sdts), ot(q, "footer", O.section?.footerRefs, O.section?.titlePg ?? !1, R, a, c, X, te, r, O.sdts);
|
|
2148
|
+
const W = ao(c, "footnotes") ?? "word/footnotes.xml", ne = a.text(W), K = ne !== void 0 ? on(ne, W, r, O.sdts) : /* @__PURE__ */ new Map(), l = {};
|
|
2149
|
+
if (K.size > 0) {
|
|
2150
|
+
const L = ze(a, W), M = te(L), z = _e(L);
|
|
2151
|
+
for (const { docxId: U, noteId: D } of X.footnoteRefs()) {
|
|
2152
|
+
const S = K.get(U);
|
|
2153
|
+
if (!S) {
|
|
2154
|
+
r.add("footnote-missing", "A footnote reference had no matching note body.");
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
const P = X.mapBlocks(S, M, z), H = P.filter((N) => N.kind === "paragraph");
|
|
2158
|
+
H.length < P.length && r.add("footnote-tables", "Tables inside footnotes were dropped (footnotes hold paragraphs only)."), H.length > 0 && (l[D] = H);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
o("map", 1);
|
|
2162
|
+
const g = { section: q, blocks: J };
|
|
2163
|
+
Object.keys(l).length > 0 && (g.footnotes = l);
|
|
2164
|
+
const y = wn(O.sdts);
|
|
2165
|
+
Object.keys(y).length > 0 && (g.sdts = y);
|
|
2166
|
+
const C = X.lists();
|
|
2167
|
+
Object.keys(C).length > 0 && (g.lists = C);
|
|
2168
|
+
const w = X.bookmarks();
|
|
2169
|
+
Object.keys(w).length > 0 && (g.bookmarks = w);
|
|
2170
|
+
const I = kn(m, mt(O.blocks));
|
|
2171
|
+
return I && (g.stylesheet = I), {
|
|
2172
|
+
doc: g,
|
|
2173
|
+
warnings: r.list,
|
|
2174
|
+
mediaUrls: j.flatMap((L) => L.urls()),
|
|
2175
|
+
media: i
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
function io(n, e, t, o, r, i, s) {
|
|
2179
|
+
if (!t) return;
|
|
2180
|
+
const a = e.get(t), f = a && !a.external ? n.text(a.target) : void 0;
|
|
2181
|
+
if (a === void 0 || f === void 0) {
|
|
2182
|
+
i.add("header-missing", "A referenced header/footer part was missing from the archive.");
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
const h = ze(n, a.target), d = Xt(f, a.target, i, s), c = o.mapBlocks(d, r(h), _e(h));
|
|
2186
|
+
return c.length > 0 ? c : void 0;
|
|
2187
|
+
}
|
|
2188
|
+
function ot(n, e, t, o, r, i, s, a, f, h, d) {
|
|
2189
|
+
if (!t) return;
|
|
2190
|
+
const c = (m) => `${e}${m}`, p = (m, T) => {
|
|
2191
|
+
const b = io(i, s, T, a, f, h, d);
|
|
2192
|
+
b && (n[m] = b);
|
|
2193
|
+
};
|
|
2194
|
+
p(c(""), t.default), o && p(c("First"), t.first), r && p(c("Even"), t.even);
|
|
2195
|
+
}
|
|
2196
|
+
function so(n) {
|
|
2197
|
+
const e = fe(de(n, "settings.xml"), "w:settings");
|
|
2198
|
+
return !!e && !!u(e, "w:evenAndOddHeadersAndFooters");
|
|
2199
|
+
}
|
|
2200
|
+
function ze(n, e) {
|
|
2201
|
+
const t = n.text(Cn(e));
|
|
2202
|
+
return t !== void 0 ? Sn(t, e) : /* @__PURE__ */ new Map();
|
|
2203
|
+
}
|
|
2204
|
+
function _e(n) {
|
|
2205
|
+
return (e) => {
|
|
2206
|
+
const t = n.get(e);
|
|
2207
|
+
return t?.external ? t.target : void 0;
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
function Ae(n, e, t) {
|
|
2211
|
+
const o = kt(e, t);
|
|
2212
|
+
return o && !o.external ? n.text(o.target) : void 0;
|
|
2213
|
+
}
|
|
2214
|
+
function ao(n, e) {
|
|
2215
|
+
const t = kt(n, e);
|
|
2216
|
+
return t && !t.external ? t.target : void 0;
|
|
2217
|
+
}
|
|
2218
|
+
function co(n, e) {
|
|
2219
|
+
const t = n instanceof Uint8Array ? n : new Uint8Array(n), o = ro(t, void 0, {}), r = o.doc, i = new Map(o.media.map((s) => [s.src, st(s.bytes, s.mime)]));
|
|
2220
|
+
if (i.size > 0) {
|
|
2221
|
+
const s = (a) => {
|
|
2222
|
+
for (const f of a ?? [])
|
|
2223
|
+
if (f.kind === "image") {
|
|
2224
|
+
const h = i.get(f.src);
|
|
2225
|
+
h && (f.src = h);
|
|
2226
|
+
} else if (f.kind === "table")
|
|
2227
|
+
for (const h of f.rows) for (const d of h.cells) s(d.blocks);
|
|
2228
|
+
};
|
|
2229
|
+
s(r.blocks);
|
|
2230
|
+
for (const a of it) s(r.section[a]);
|
|
2231
|
+
}
|
|
2232
|
+
return e || (r.blocks = [], delete r.footnotes, lo(r)), { doc: r, warnings: o.warnings };
|
|
2233
|
+
}
|
|
2234
|
+
function lo(n) {
|
|
2235
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), o = (r) => {
|
|
2236
|
+
for (const i of r ?? [])
|
|
2237
|
+
if (e.add(i.id), i.kind === "paragraph")
|
|
2238
|
+
for (const s of i.runs) s.style.sdtId && t.add(s.style.sdtId);
|
|
2239
|
+
else if (i.kind === "table")
|
|
2240
|
+
for (const s of i.rows) for (const a of s.cells) o(a.blocks);
|
|
2241
|
+
};
|
|
2242
|
+
o(n.blocks);
|
|
2243
|
+
for (const r of it) o(n.section[r]);
|
|
2244
|
+
if (n.bookmarks) {
|
|
2245
|
+
for (const [r, i] of Object.entries(n.bookmarks))
|
|
2246
|
+
(!e.has(i.start.blockId) || !e.has(i.end.blockId)) && delete n.bookmarks[r];
|
|
2247
|
+
Object.keys(n.bookmarks).length === 0 && delete n.bookmarks;
|
|
2248
|
+
}
|
|
2249
|
+
if (n.sdts) {
|
|
2250
|
+
for (const r of Object.keys(n.sdts))
|
|
2251
|
+
t.has(r) || delete n.sdts[r];
|
|
2252
|
+
Object.keys(n.sdts).length === 0 && delete n.sdts;
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
const ho = (n) => n * 96, po = (n) => n * 96 / 2.54, go = (n) => n * 96 / 72, mo = (n) => n / 15, fo = {
|
|
2256
|
+
Letter: { pageWidthPx: 816, pageHeightPx: 1056 },
|
|
2257
|
+
Legal: { pageWidthPx: 816, pageHeightPx: 1344 },
|
|
2258
|
+
A4: { pageWidthPx: 794, pageHeightPx: 1123 },
|
|
2259
|
+
A3: { pageWidthPx: 1123, pageHeightPx: 1587 },
|
|
2260
|
+
Tabloid: { pageWidthPx: 1056, pageHeightPx: 1632 }
|
|
2261
|
+
}, Ce = 96;
|
|
2262
|
+
function rt(n) {
|
|
2263
|
+
return typeof n == "string" ? fo[n] : n;
|
|
2264
|
+
}
|
|
2265
|
+
class $e extends Oe {
|
|
2266
|
+
/** Start from a blank document (default stylesheet, US Letter, 1in margins). */
|
|
2267
|
+
static create(e = {}) {
|
|
2268
|
+
const t = rt(e.pageSize ?? "Letter"), o = {
|
|
2269
|
+
section: {
|
|
2270
|
+
pageWidthPx: t.pageWidthPx,
|
|
2271
|
+
pageHeightPx: t.pageHeightPx,
|
|
2272
|
+
marginPx: { top: Ce, right: Ce, bottom: Ce, left: Ce, ...e.margins }
|
|
2273
|
+
},
|
|
2274
|
+
blocks: [],
|
|
2275
|
+
stylesheet: e.stylesheet ?? Mt()
|
|
2276
|
+
};
|
|
2277
|
+
return new $e(new qe(o, e.idSeed));
|
|
2278
|
+
}
|
|
2279
|
+
/** Start from a .docx template: its stylesheet, list definitions, page setup,
|
|
2280
|
+
* and header/footer bands carry over (body content is discarded unless
|
|
2281
|
+
* keepBody). Import warnings surface on `builder.warnings`. */
|
|
2282
|
+
static async fromTemplate(e, t = {}) {
|
|
2283
|
+
const { doc: o, warnings: r } = co(e, t.keepBody ?? !1), i = new $e(new qe(o, t.idSeed));
|
|
2284
|
+
for (const s of r) i.ctx.warn(s.code, s.message);
|
|
2285
|
+
return i;
|
|
2286
|
+
}
|
|
2287
|
+
constructor(e) {
|
|
2288
|
+
super(e, e.doc.blocks);
|
|
2289
|
+
}
|
|
2290
|
+
/** Lossy decisions made while building (unknown style ids, template import
|
|
2291
|
+
* warnings, …) — surfaced, not swallowed. */
|
|
2292
|
+
get warnings() {
|
|
2293
|
+
return this.ctx.warnings;
|
|
2294
|
+
}
|
|
2295
|
+
/** Compose a header band. Replaces the variant's existing story (including
|
|
2296
|
+
* one carried over from the template). */
|
|
2297
|
+
header(e, t = {}) {
|
|
2298
|
+
return this.band("header", e, t);
|
|
2299
|
+
}
|
|
2300
|
+
/** Compose a footer band. Same variant semantics as header(). */
|
|
2301
|
+
footer(e, t = {}) {
|
|
2302
|
+
return this.band("footer", e, t);
|
|
2303
|
+
}
|
|
2304
|
+
band(e, t, o) {
|
|
2305
|
+
const r = o.variant ?? "default", i = r === "default" ? e : `${e}${r === "first" ? "First" : "Even"}`, s = [];
|
|
2306
|
+
return t(new Oe(this.ctx, s)), s.length === 0 && s.push(this.ctx.paragraph([])), this.ctx.doc.section[i] = s, this;
|
|
2307
|
+
}
|
|
2308
|
+
/** Merge page geometry onto the section (template values are the base). */
|
|
2309
|
+
pageSetup(e) {
|
|
2310
|
+
const t = this.ctx.doc.section;
|
|
2311
|
+
if (e.pageSize !== void 0) {
|
|
2312
|
+
const o = rt(e.pageSize);
|
|
2313
|
+
t.pageWidthPx = o.pageWidthPx, t.pageHeightPx = o.pageHeightPx;
|
|
2314
|
+
}
|
|
2315
|
+
if (e.orientation !== void 0) {
|
|
2316
|
+
const o = e.orientation === "landscape", [r, i] = [t.pageWidthPx, t.pageHeightPx];
|
|
2317
|
+
o !== r > i && (t.pageWidthPx = i, t.pageHeightPx = r);
|
|
2318
|
+
}
|
|
2319
|
+
return e.margins !== void 0 && (t.marginPx = { ...t.marginPx, ...e.margins }), e.columns !== void 0 && (t.columns = { count: e.columns.count, gapPx: e.columns.gapPx ?? 48 }), e.headerDistancePx !== void 0 && (t.headerDistancePx = e.headerDistancePx), e.footerDistancePx !== void 0 && (t.footerDistancePx = e.footerDistancePx), e.pageNumberStart !== void 0 && (t.pageNumberStart = e.pageNumberStart), this;
|
|
2320
|
+
}
|
|
2321
|
+
/** Register (or override) a named style. Register BEFORE applying it —
|
|
2322
|
+
* withStyle() resolves at call time, not at build(). */
|
|
2323
|
+
style(e) {
|
|
2324
|
+
const t = this.ctx.stylesheet(), o = t.styles.findIndex((r) => r.id === e.id);
|
|
2325
|
+
return o >= 0 ? t.styles[o] = e : t.styles.push(e), this;
|
|
2326
|
+
}
|
|
2327
|
+
/** Snapshot the document: deep clone, guaranteed at least one paragraph.
|
|
2328
|
+
* The builder remains usable (and unaffected by mutations of the result). */
|
|
2329
|
+
build() {
|
|
2330
|
+
this.flushPendingPageBreak();
|
|
2331
|
+
const e = structuredClone(this.ctx.doc);
|
|
2332
|
+
return e.blocks.length === 0 && e.blocks.push(this.ctx.paragraph([])), e;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
export {
|
|
2336
|
+
$e as DocumentBuilder,
|
|
2337
|
+
fo as PAGE_SIZES,
|
|
2338
|
+
Nt as ParagraphBuilder,
|
|
2339
|
+
Et as RowBuilder,
|
|
2340
|
+
Oe as StoryBuilder,
|
|
2341
|
+
Ot as TableBuilder,
|
|
2342
|
+
st as bytesToDataUrl,
|
|
2343
|
+
po as cm,
|
|
2344
|
+
ho as inches,
|
|
2345
|
+
go as pt,
|
|
2346
|
+
mo as twips
|
|
2347
|
+
};
|