@forevka/wordcanvas 0.7.0 → 0.7.2

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