@forevka/wordcanvas 0.7.1 → 0.7.3

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