@w100n/documents 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{SheetView-3XTEV2VT.css → SheetView-43MPR64N.css} +5 -4
  2. package/dist/{SheetView-3XTEV2VT.css.map → SheetView-43MPR64N.css.map} +1 -1
  3. package/dist/{SheetView-3UAFXGZS.js → SheetView-72KXS4DM.js} +51 -10
  4. package/dist/SheetView-72KXS4DM.js.map +1 -0
  5. package/dist/TextEditor-NSICFE6U.js +1562 -0
  6. package/dist/TextEditor-NSICFE6U.js.map +1 -0
  7. package/dist/{chunk-L765DZPO.js → chunk-2CA3HQTI.js} +3 -3
  8. package/dist/{chunk-L765DZPO.js.map → chunk-2CA3HQTI.js.map} +1 -1
  9. package/dist/{chunk-WR3MT7KP.js → chunk-M4OQG3EN.js} +754 -57
  10. package/dist/chunk-M4OQG3EN.js.map +1 -0
  11. package/dist/{chunk-T7XCGDE5.js → chunk-OXC4PUOC.js} +2 -2
  12. package/dist/{chunk-MRP3EURG.js → chunk-Z7UNJ4ND.js} +194 -25
  13. package/dist/chunk-Z7UNJ4ND.js.map +1 -0
  14. package/dist/collab.cjs +927 -80
  15. package/dist/collab.cjs.map +1 -1
  16. package/dist/collab.d.cts +2 -2
  17. package/dist/collab.d.ts +2 -2
  18. package/dist/collab.js +2 -2
  19. package/dist/{grid-EI5JNZAA.js → grid-Q4XBPQFY.js} +3 -3
  20. package/dist/grid-Q4XBPQFY.js.map +1 -0
  21. package/dist/index.cjs +2136 -420
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.css +1047 -171
  24. package/dist/index.css.map +1 -1
  25. package/dist/index.d.cts +9 -4
  26. package/dist/index.d.ts +9 -4
  27. package/dist/index.js +283 -33
  28. package/dist/index.js.map +1 -1
  29. package/dist/kinds.cjs +2 -2
  30. package/dist/kinds.cjs.map +1 -1
  31. package/dist/kinds.d.cts +2 -2
  32. package/dist/kinds.d.ts +2 -2
  33. package/dist/kinds.js +1 -1
  34. package/dist/memory.cjs +3 -0
  35. package/dist/memory.cjs.map +1 -1
  36. package/dist/memory.d.cts +1 -1
  37. package/dist/memory.d.ts +1 -1
  38. package/dist/memory.js +4 -1
  39. package/dist/memory.js.map +1 -1
  40. package/dist/{types-Er60M5kL.d.ts → types-BTsVooZw.d.cts} +2 -1
  41. package/dist/{types-Er60M5kL.d.cts → types-BTsVooZw.d.ts} +2 -1
  42. package/dist/write-BCI8yool.d.cts +16 -0
  43. package/dist/write-BCI8yool.d.ts +16 -0
  44. package/package.json +1 -1
  45. package/dist/SheetView-3UAFXGZS.js.map +0 -1
  46. package/dist/TextEditor-OLBLWC6F.js +0 -983
  47. package/dist/TextEditor-OLBLWC6F.js.map +0 -1
  48. package/dist/chunk-MRP3EURG.js.map +0 -1
  49. package/dist/chunk-WR3MT7KP.js.map +0 -1
  50. package/dist/grid-EI5JNZAA.js.map +0 -1
  51. package/dist/write-DaVtTJCS.d.cts +0 -6
  52. package/dist/write-DaVtTJCS.d.ts +0 -6
  53. /package/dist/{chunk-T7XCGDE5.js.map → chunk-OXC4PUOC.js.map} +0 -0
@@ -1,7 +1,267 @@
1
1
  'use client';
2
2
 
3
+ // src/editor/math.ts
4
+ var words = {
5
+ alpha: "\u03B1",
6
+ beta: "\u03B2",
7
+ gamma: "\u03B3",
8
+ delta: "\u03B4",
9
+ epsilon: "\u03B5",
10
+ zeta: "\u03B6",
11
+ eta: "\u03B7",
12
+ theta: "\u03B8",
13
+ iota: "\u03B9",
14
+ kappa: "\u03BA",
15
+ lambda: "\u03BB",
16
+ mu: "\u03BC",
17
+ nu: "\u03BD",
18
+ xi: "\u03BE",
19
+ pi: "\u03C0",
20
+ rho: "\u03C1",
21
+ sigma: "\u03C3",
22
+ tau: "\u03C4",
23
+ upsilon: "\u03C5",
24
+ phi: "\u03C6",
25
+ chi: "\u03C7",
26
+ psi: "\u03C8",
27
+ omega: "\u03C9",
28
+ Gamma: "\u0393",
29
+ Delta: "\u0394",
30
+ Theta: "\u0398",
31
+ Lambda: "\u039B",
32
+ Xi: "\u039E",
33
+ Pi: "\u03A0",
34
+ Sigma: "\u03A3",
35
+ Phi: "\u03A6",
36
+ Psi: "\u03A8",
37
+ Omega: "\u03A9",
38
+ infty: "\u221E",
39
+ partial: "\u2202",
40
+ nabla: "\u2207"
41
+ };
42
+ var ops = {
43
+ cdot: "\xB7",
44
+ times: "\xD7",
45
+ div: "\xF7",
46
+ pm: "\xB1",
47
+ mp: "\u2213",
48
+ le: "\u2264",
49
+ leq: "\u2264",
50
+ ge: "\u2265",
51
+ geq: "\u2265",
52
+ ne: "\u2260",
53
+ neq: "\u2260",
54
+ approx: "\u2248",
55
+ equiv: "\u2261",
56
+ to: "\u2192",
57
+ rightarrow: "\u2192",
58
+ leftarrow: "\u2190",
59
+ Rightarrow: "\u21D2",
60
+ in: "\u2208",
61
+ notin: "\u2209",
62
+ subset: "\u2282",
63
+ cup: "\u222A",
64
+ cap: "\u2229",
65
+ forall: "\u2200",
66
+ exists: "\u2203",
67
+ sum: "\u2211",
68
+ prod: "\u220F",
69
+ int: "\u222B",
70
+ oint: "\u222E",
71
+ degree: "\xB0"
72
+ };
73
+ var big = /* @__PURE__ */ new Set(["\u2211", "\u220F", "\u222B", "\u222E"]);
74
+ var glyph = {};
75
+ for (const [k, v] of [...Object.entries(words), ...Object.entries(ops)]) glyph[v] ?? (glyph[v] = k);
76
+ function parse(src) {
77
+ let i = 0;
78
+ const group = () => {
79
+ if (src[i] === "{") {
80
+ i++;
81
+ const kids2 = row("}");
82
+ i++;
83
+ return kids2.length === 1 ? kids2[0] : { t: "row", kids: kids2 };
84
+ }
85
+ return one() ?? { t: "row", kids: [] };
86
+ };
87
+ const one = () => {
88
+ while (src[i] === " ") i++;
89
+ if (i >= src.length) return null;
90
+ const c = src[i];
91
+ if (c === "{") return group();
92
+ if (c === "\\") {
93
+ const m = /^\\([a-zA-Z]+|.)/.exec(src.slice(i));
94
+ if (!m) {
95
+ i++;
96
+ return { t: "tok", v: "\\", kind: "mo" };
97
+ }
98
+ i += m[0].length;
99
+ const name = m[1];
100
+ if (name === "frac") return { t: "frac", num: group(), den: group() };
101
+ if (name === "sqrt") {
102
+ let deg = null;
103
+ if (src[i] === "[") {
104
+ const end = src.indexOf("]", i);
105
+ deg = parse(src.slice(i + 1, end < 0 ? src.length : end));
106
+ i = end < 0 ? src.length : end + 1;
107
+ }
108
+ return { t: "sqrt", body: group(), deg };
109
+ }
110
+ if (name === "text" || name === "mathrm") {
111
+ const g = src[i] === "{" ? src.indexOf("}", i) : -1;
112
+ const v = g < 0 ? "" : src.slice(i + 1, g);
113
+ i = g < 0 ? i : g + 1;
114
+ return { t: "tok", v, kind: "mtext" };
115
+ }
116
+ if (name === "left" || name === "right") return one();
117
+ if (words[name]) return { t: "tok", v: words[name], kind: "mi" };
118
+ if (ops[name]) return { t: "tok", v: ops[name], kind: "mo" };
119
+ return { t: "tok", v: name.length === 1 ? name : `\\${name}`, kind: name.length === 1 ? "mo" : "mi" };
120
+ }
121
+ if (/[0-9.]/.test(c)) {
122
+ const m = /^[0-9]*\.?[0-9]+|^[0-9]+/.exec(src.slice(i));
123
+ i += m[0].length;
124
+ return { t: "tok", v: m[0], kind: "mn" };
125
+ }
126
+ i++;
127
+ if (/[\p{L}]/u.test(c)) return { t: "tok", v: c, kind: big.has(c) ? "mo" : "mi" };
128
+ return { t: "tok", v: c, kind: "mo" };
129
+ };
130
+ const row = (stop) => {
131
+ const kids2 = [];
132
+ while (i < src.length && src[i] !== stop) {
133
+ while (src[i] === " ") i++;
134
+ if (i >= src.length || src[i] === stop) break;
135
+ if (src[i] === "^" || src[i] === "_") {
136
+ const base = kids2.pop() ?? { t: "row", kids: [] };
137
+ const s = base.t === "script" && !base.sub !== !base.sup ? base : { t: "script", base, sub: null, sup: null };
138
+ const which = src[i++] === "^" ? "sup" : "sub";
139
+ s[which] = group();
140
+ kids2.push(s);
141
+ continue;
142
+ }
143
+ if (src[i] === "}") {
144
+ i++;
145
+ continue;
146
+ }
147
+ const a = one();
148
+ if (a) kids2.push(a);
149
+ }
150
+ return kids2;
151
+ };
152
+ const kids = row("\0");
153
+ return kids.length === 1 ? kids[0] : { t: "row", kids };
154
+ }
155
+ var esc = (v) => v.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
156
+ function ml(a) {
157
+ switch (a.t) {
158
+ case "tok":
159
+ return `<${a.kind}>${esc(a.v)}</${a.kind}>`;
160
+ case "row":
161
+ return `<mrow>${a.kids.map(ml).join("")}</mrow>`;
162
+ case "frac":
163
+ return `<mfrac>${ml(a.num)}${ml(a.den)}</mfrac>`;
164
+ case "sqrt":
165
+ return a.deg ? `<mroot>${ml(a.body)}${ml(a.deg)}</mroot>` : `<msqrt>${ml(a.body)}</msqrt>`;
166
+ case "script": {
167
+ const over = a.base.t === "tok" && big.has(a.base.v);
168
+ if (a.sub && a.sup) return `<${over ? "munderover" : "msubsup"}>${ml(a.base)}${ml(a.sub)}${ml(a.sup)}</${over ? "munderover" : "msubsup"}>`;
169
+ if (a.sub) return `<${over ? "munder" : "msub"}>${ml(a.base)}${ml(a.sub)}</${over ? "munder" : "msub"}>`;
170
+ return `<${over ? "mover" : "msup"}>${ml(a.base)}${ml(a.sup)}</${over ? "mover" : "msup"}>`;
171
+ }
172
+ }
173
+ }
174
+ var mathml = (latex) => `<math xmlns="http://www.w3.org/1998/Math/MathML">${ml(parse(latex))}</math>`;
175
+ var run = (v, plain2 = false) => `<m:r>${plain2 ? '<m:rPr><m:sty m:val="p"/></m:rPr>' : ""}<m:t xml:space="preserve">${esc(v)}</m:t></m:r>`;
176
+ function om(a) {
177
+ switch (a.t) {
178
+ case "tok":
179
+ return run(a.v, a.kind === "mtext" || a.kind === "mo" && !big.has(a.v));
180
+ case "row":
181
+ return a.kids.map(om).join("");
182
+ case "frac":
183
+ return `<m:f><m:num>${om(a.num)}</m:num><m:den>${om(a.den)}</m:den></m:f>`;
184
+ case "sqrt":
185
+ return a.deg ? `<m:rad><m:deg>${om(a.deg)}</m:deg><m:e>${om(a.body)}</m:e></m:rad>` : `<m:rad><m:radPr><m:degHide m:val="1"/></m:radPr><m:deg/><m:e>${om(a.body)}</m:e></m:rad>`;
186
+ case "script": {
187
+ if (a.base.t === "tok" && big.has(a.base.v)) return `<m:nary><m:naryPr><m:chr m:val="${a.base.v}"/>${a.sub ? "" : '<m:subHide m:val="1"/>'}${a.sup ? "" : '<m:supHide m:val="1"/>'}</m:naryPr><m:sub>${a.sub ? om(a.sub) : ""}</m:sub><m:sup>${a.sup ? om(a.sup) : ""}</m:sup><m:e/></m:nary>`;
188
+ if (a.sub && a.sup) return `<m:sSubSup><m:e>${om(a.base)}</m:e><m:sub>${om(a.sub)}</m:sub><m:sup>${om(a.sup)}</m:sup></m:sSubSup>`;
189
+ if (a.sub) return `<m:sSub><m:e>${om(a.base)}</m:e><m:sub>${om(a.sub)}</m:sub></m:sSub>`;
190
+ return `<m:sSup><m:e>${om(a.base)}</m:e><m:sup>${om(a.sup)}</m:sup></m:sSup>`;
191
+ }
192
+ }
193
+ }
194
+ var omml = (latex) => `<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">${om(parse(latex))}</m:oMath>`;
195
+ function tree(xml) {
196
+ const root = { name: "", kids: [], text: "", attrs: {} };
197
+ const stack = [root];
198
+ for (const m of xml.matchAll(/<(\/?)([\w:]+)([^>]*?)(\/?)>|([^<]+)/g)) {
199
+ const top = stack[stack.length - 1];
200
+ if (m[5] !== void 0) {
201
+ top.text += m[5];
202
+ continue;
203
+ }
204
+ if (m[1]) {
205
+ stack.pop();
206
+ continue;
207
+ }
208
+ const attrs2 = Object.fromEntries([...m[3].matchAll(/([\w:]+)="([^"]*)"/g)].map((a) => [a[1], a[2]]));
209
+ const node = { name: m[2], kids: [], text: "", attrs: attrs2 };
210
+ top.kids.push(node);
211
+ if (!m[4]) stack.push(node);
212
+ }
213
+ return root;
214
+ }
215
+ var unesc = (v) => v.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
216
+ var brace = (v) => v.length === 1 ? v : `{${v}}`;
217
+ function tex(n) {
218
+ const part = (name) => n.kids.find((k) => k.name === name);
219
+ const all = (k) => k ? k.kids.map(tex).join("") : "";
220
+ switch (n.name) {
221
+ case "m:t":
222
+ return [...unesc(n.text)].map((ch) => glyph[ch] ? `\\${glyph[ch]} ` : ch).join("");
223
+ case "m:f":
224
+ return `\\frac{${all(part("m:num"))}}{${all(part("m:den"))}}`;
225
+ case "m:sSup":
226
+ return `${brace(all(part("m:e")))}^${brace(all(part("m:sup")))}`;
227
+ case "m:sSub":
228
+ return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}`;
229
+ case "m:sSubSup":
230
+ return `${brace(all(part("m:e")))}_${brace(all(part("m:sub")))}^${brace(all(part("m:sup")))}`;
231
+ case "m:rad": {
232
+ const deg = all(part("m:deg"));
233
+ return `\\sqrt${deg ? `[${deg}]` : ""}{${all(part("m:e"))}}`;
234
+ }
235
+ case "m:nary": {
236
+ const chr = part("m:naryPr")?.kids.find((k) => k.name === "m:chr")?.attrs["m:val"] ?? "\u222B";
237
+ const sub = all(part("m:sub")), sup = all(part("m:sup"));
238
+ return `${glyph[chr] ? `\\${glyph[chr]}` : chr}${sub ? `_${brace(sub)}` : ""}${sup ? `^${brace(sup)}` : ""} ${all(part("m:e"))}`.trim();
239
+ }
240
+ case "m:d": {
241
+ const pr = part("m:dPr")?.kids ?? [];
242
+ const beg = pr.find((k) => k.name === "m:begChr")?.attrs["m:val"] ?? "(";
243
+ const end = pr.find((k) => k.name === "m:endChr")?.attrs["m:val"] ?? ")";
244
+ return `${beg}${n.kids.filter((k) => k.name === "m:e").map(all).join(",")}${end}`;
245
+ }
246
+ case "m:rPr":
247
+ case "m:ctrlPr":
248
+ case "w:rPr":
249
+ case "m:naryPr":
250
+ case "m:dPr":
251
+ case "m:radPr":
252
+ case "m:fPr":
253
+ case "m:sSupPr":
254
+ case "m:sSubPr":
255
+ case "m:sSubSupPr":
256
+ return "";
257
+ default:
258
+ return n.kids.map(tex).join("");
259
+ }
260
+ }
261
+ var latexOf = (xml) => tex(tree(xml)).replace(/\s+/g, " ").trim();
262
+
3
263
  // src/docx/xml.ts
4
- function parse(s) {
264
+ function parse2(s) {
5
265
  const root = { name: "", start: 0, open: 0, close: s.length, end: s.length, kids: [] };
6
266
  const stack = [root];
7
267
  const n = s.length;
@@ -105,7 +365,7 @@ function opened(s, el) {
105
365
  return el.end === el.open ? tag.replace(/\s*\/>$/, ">") : tag;
106
366
  }
107
367
  function rebuild(pr, tag, order, set) {
108
- const root = parse(pr).kids[0];
368
+ const root = parse2(pr).kids[0];
109
369
  const parts = root ? root.kids.map((k) => ({ name: k.name, xml: pr.slice(k.start, k.end) })) : [];
110
370
  const seen = /* @__PURE__ */ new Set();
111
371
  const out = [];
@@ -242,7 +502,7 @@ function zip(entries) {
242
502
  }
243
503
 
244
504
  // src/docx/pkg.ts
245
- var plain = { b: false, i: false, u: false, s: false, code: false, link: null, hl: null, color: null, size: null, font: null, rev: null };
505
+ var plain = { b: false, i: false, u: false, s: false, code: false, link: null, hl: null, color: null, size: null, font: null, rev: null, va: null };
246
506
  var highlights = {
247
507
  yellow: "ffff00",
248
508
  green: "00ff00",
@@ -294,6 +554,8 @@ function fmtOf(marks) {
294
554
  else if (m.type === "underline") f.u = true;
295
555
  else if (m.type === "strike") f.s = true;
296
556
  else if (m.type === "code") f.code = true;
557
+ else if (m.type === "superscript") f.va = "sup";
558
+ else if (m.type === "subscript") f.va = "sub";
297
559
  else if (m.type === "link" && typeof a.href === "string" && a.href) f.link = a.href;
298
560
  else if (m.type === "highlight") f.hl = color(a.color) ?? "#ffff00";
299
561
  else if (m.type === "textStyle") {
@@ -312,6 +574,7 @@ function marksOf(f) {
312
574
  if (f.u) out.push({ type: "underline" });
313
575
  if (f.s) out.push({ type: "strike" });
314
576
  if (f.code) out.push({ type: "code" });
577
+ if (f.va) out.push({ type: f.va === "sup" ? "superscript" : "subscript" });
315
578
  if (f.link) out.push({ type: "link", attrs: { href: f.link } });
316
579
  if (f.hl) out.push({ type: "highlight", attrs: { color: f.hl } });
317
580
  if (f.color || f.size || f.font) out.push({ type: "textStyle", attrs: { color: f.color, fontSize: f.size, fontFamily: f.font } });
@@ -322,7 +585,7 @@ function marksOf(f) {
322
585
  return out.length ? out : void 0;
323
586
  }
324
587
  function keyOf(f) {
325
- return `${+f.b}${+f.i}${+f.u}${+f.s}${+f.code}|${f.link ?? ""}|${f.hl ?? ""}|${f.color ?? ""}|${f.size ?? ""}|${f.font ?? ""}|${f.rev ?? ""}`;
588
+ return `${+f.b}${+f.i}${+f.u}${+f.s}${+f.code}|${f.link ?? ""}|${f.hl ?? ""}|${f.color ?? ""}|${f.size ?? ""}|${f.font ?? ""}|${f.rev ?? ""}|${f.va ?? ""}`;
326
589
  }
327
590
  var Styles = class {
328
591
  constructor(s, fonts) {
@@ -331,7 +594,7 @@ var Styles = class {
331
594
  this.byId = /* @__PURE__ */ new Map();
332
595
  this.paragraph = null;
333
596
  this.memo = /* @__PURE__ */ new Map();
334
- const root = find(parse(s), "w:styles");
597
+ const root = find(parse2(s), "w:styles");
335
598
  for (const el of root?.kids ?? []) {
336
599
  if (el.name !== "w:style") continue;
337
600
  const id = attr(s, el, "w:styleId");
@@ -469,6 +732,11 @@ function props(s, rPr, fonts) {
469
732
  case "w:sz":
470
733
  out.size = size(+(attr(s, k, "w:val") ?? 0) / 2);
471
734
  break;
735
+ case "w:vertAlign": {
736
+ const v = attr(s, k, "w:val");
737
+ out.va = v === "superscript" ? "sup" : v === "subscript" ? "sub" : null;
738
+ break;
739
+ }
472
740
  case "w:highlight": {
473
741
  const v = attr(s, k, "w:val") ?? "none";
474
742
  out.hl = highlights[v] ? "#" + highlights[v] : null;
@@ -496,7 +764,7 @@ var Numbering = class {
496
764
  this.abs = /* @__PURE__ */ new Map();
497
765
  this.maxNum = 0;
498
766
  this.maxAbs = -1;
499
- const root = find(parse(s), "w:numbering");
767
+ const root = find(parse2(s), "w:numbering");
500
768
  const links = /* @__PURE__ */ new Map();
501
769
  for (const el of root?.kids ?? []) {
502
770
  if (el.name === "w:abstractNum") {
@@ -593,7 +861,7 @@ var Pkg = class {
593
861
  const s = this.text(this.relsPath(part));
594
862
  if (!s) return out;
595
863
  const dir = part.slice(0, part.lastIndexOf("/") + 1);
596
- for (const el of find(parse(s), "Relationships")?.kids ?? []) {
864
+ for (const el of find(parse2(s), "Relationships")?.kids ?? []) {
597
865
  const id = attr(s, el, "Id");
598
866
  const target = attr(s, el, "Target") ?? "";
599
867
  const external = attr(s, el, "TargetMode") === "External";
@@ -613,7 +881,7 @@ function resolve(dir, target) {
613
881
  }
614
882
 
615
883
  // src/docx/read.ts
616
- var blank = () => ({ align: null, indent: 0, ref: null });
884
+ var blank = () => ({ align: null, indent: 0, line: null, after: null, ref: null });
617
885
  var mimes = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", bmp: "image/bmp", webp: "image/webp", svg: "image/svg+xml" };
618
886
  function align(v) {
619
887
  if (v === "center") return "center";
@@ -631,6 +899,7 @@ var Reader = class {
631
899
  this.pkg = pkg;
632
900
  this.n = 0;
633
901
  this.refs = /* @__PURE__ */ new Map();
902
+ this.footnotes = null;
634
903
  this.counters = /* @__PURE__ */ new Map();
635
904
  this.fmts = /* @__PURE__ */ new Map();
636
905
  this.media = /* @__PURE__ */ new Map();
@@ -640,7 +909,7 @@ var Reader = class {
640
909
  return `${this.pkg.fp}.${(this.n++).toString(36)}`;
641
910
  }
642
911
  body() {
643
- const body = find(parse(this.s), "w:body");
912
+ const body = find(parse2(this.s), "w:body");
644
913
  if (!body) throw new Error("DOCX document has no body");
645
914
  const { list, tail } = this.blocks(body);
646
915
  return { body, list, tail, sect: kid(body, "w:sectPr") };
@@ -731,7 +1000,14 @@ var Reader = class {
731
1000
  const src = p.pic && this.src(p.pic.embed);
732
1001
  if (!src) continue;
733
1002
  const meta2 = Object.fromEntries(attrs(/<wp:docPr\b[^>]*>/.exec(p.raw)?.[0] ?? "<x>"));
734
- p.img = { src, alt: meta2.descr ?? null, title: meta2.title ?? null, width: Math.round(p.pic.cx / 9525), height: Math.round(p.pic.cy / 9525) };
1003
+ p.img = {
1004
+ src,
1005
+ alt: meta2.descr ?? null,
1006
+ title: meta2.title ?? null,
1007
+ width: Math.round(p.pic.cx / 9525),
1008
+ height: Math.round(p.pic.cy / 9525),
1009
+ wrap: /<wp:anchor\b/.test(p.raw) ? /<wp:positionH\b[^>]*>\s*<wp:align>right</.test(p.raw) ? "right" : "left" : null
1010
+ };
735
1011
  }
736
1012
  const pPr = kid(el, "w:pPr");
737
1013
  const styles = this.pkg.styles;
@@ -759,7 +1035,11 @@ var Reader = class {
759
1035
  const ind = pPr && kid(pPr, "w:ind");
760
1036
  const left = ind && (attr(s, ind, "w:left") ?? attr(s, ind, "w:start"));
761
1037
  const indent = isList ? 0 : Math.max(0, Math.round((left !== null && left !== void 0 ? +left : styles.left(style)) / 720));
762
- const base = { align: align(jc ? attr(s, jc, "w:val") : styles.jc(style)), indent, ref };
1038
+ const sp = pPr && kid(pPr, "w:spacing");
1039
+ const lineAt = sp && attr(s, sp, "w:line");
1040
+ const afterAt = sp && attr(s, sp, "w:after");
1041
+ const auto = !sp || !attr(s, sp, "w:lineRule") || attr(s, sp, "w:lineRule") === "auto";
1042
+ const base = { align: align(jc ? attr(s, jc, "w:val") : styles.jc(style)), indent, line: lineAt && auto ? Math.round(+lineAt / 2.4) / 100 : null, after: afterAt ? +afterAt / 20 : null, ref };
763
1043
  const node = level ? { type: "heading", attrs: { level, ...base } } : { type: "paragraph", attrs: base };
764
1044
  const content = inline(final);
765
1045
  if (content.length) node.content = content;
@@ -777,6 +1057,14 @@ var Reader = class {
777
1057
  }
778
1058
  return b;
779
1059
  }
1060
+ notes() {
1061
+ if (!this.footnotes) {
1062
+ const rel = this.pkg.byType("/footnotes");
1063
+ const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
1064
+ this.footnotes = new Map([...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"[^>]*>([\s\S]*?)<\/w:footnote>/g)].map((m) => [m[1], noteText(m[2])]));
1065
+ }
1066
+ return this.footnotes;
1067
+ }
780
1068
  src(embed) {
781
1069
  if (!this.media.has(embed)) {
782
1070
  const rel = this.pkg.rels.get(embed);
@@ -822,10 +1110,8 @@ var Reader = class {
822
1110
  const inside = [];
823
1111
  this.walk(k.kids, ctx, k, inside, { lock: null, task: false, box: false });
824
1112
  this.span(s.slice(k.start, k.end), inside, out, ctx, hyperlink(attr(s, k, "w:instr") ?? ""));
825
- } else if (name === "m:oMath") {
826
- const text = s.slice(k.start, k.end).match(/<m:t(?:\s[^>]*)?>[^<]*<\/m:t>/g)?.map((t) => inner(t, parse(t).kids[0])).join("") ?? "";
827
- this.span(s.slice(k.start, k.end), text ? [{ text, raw: null, run: null, ctx, span: null }] : [], out, ctx, null);
828
- } else if (name === "m:oMathPara") st.lock = "Equation";
1113
+ } else if (name === "m:oMath") out.push({ text: "\uE000", raw: s.slice(k.start, k.end), run: null, ctx, span: null, math: latexOf(s.slice(k.start, k.end)) });
1114
+ else if (name === "m:oMathPara") st.lock = "Equation";
829
1115
  else out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
830
1116
  }
831
1117
  }
@@ -846,17 +1132,17 @@ var Reader = class {
846
1132
  out.push({ text: null, raw: s.slice(k.start, k.end), run: null, ctx, span: null });
847
1133
  return;
848
1134
  }
849
- const run = { open: opened(s, k), rPr: rPrEl ? s.slice(rPrEl.start, rPrEl.end) : "", fmt: f, el: k, parent };
1135
+ const run2 = { open: opened(s, k), rPr: rPrEl ? s.slice(rPrEl.start, rPrEl.end) : "", fmt: f, el: k, parent };
850
1136
  const push = (text, raw, extra) => {
851
1137
  if (text !== null && st.box) {
852
1138
  st.box = false;
853
1139
  if (text.startsWith(" ") && raw === null) {
854
- out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run, ctx, span: null, box: true });
1140
+ out.push({ text: null, raw: '<w:t xml:space="preserve"> </w:t>', run: run2, ctx, span: null, box: true });
855
1141
  text = text.slice(1);
856
1142
  if (!text) return;
857
1143
  }
858
1144
  }
859
- out.push({ text, raw, run, ctx, span: null, ...extra });
1145
+ out.push({ text, raw, run: run2, ctx, span: null, ...extra });
860
1146
  };
861
1147
  for (const c of k.kids) {
862
1148
  const raw = s.slice(c.start, c.end);
@@ -889,6 +1175,11 @@ var Reader = class {
889
1175
  else push("\n", raw);
890
1176
  break;
891
1177
  }
1178
+ case "w:footnoteReference": {
1179
+ const id = attr(s, c, "w:id") ?? "";
1180
+ push("\uE001", raw, { note: { id, text: this.notes().get(id) ?? "" } });
1181
+ break;
1182
+ }
892
1183
  case "w:fldChar":
893
1184
  push(null, raw, { fld: attr(s, c, "w:fldCharType") ?? "" });
894
1185
  break;
@@ -967,10 +1258,13 @@ var Reader = class {
967
1258
  const ref = this.ref();
968
1259
  const pr = kid(el, "w:tblPr");
969
1260
  const jc = pr && kid(pr, "w:jc");
970
- const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, ref }, content: [] };
1261
+ const bd = pr && kid(pr, "w:tblBorders");
1262
+ const bare = !!bd && bd.kids.length > 0 && bd.kids.every((k) => /^(none|nil)$/.test(attr(s, k, "w:val") ?? ""));
1263
+ const node = { type: "table", attrs: { align: align(jc ? attr(s, jc, "w:val") : null), indent: 0, borders: bare ? "none" : null, ref }, content: [] };
971
1264
  const b = this.block("tbl", el, node, ref);
972
1265
  const grid2 = kid(el, "w:tblGrid");
973
1266
  b.cols = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").length : 0;
1267
+ const widths = grid2 ? grid2.kids.filter((k) => k.name === "w:gridCol").map((k) => Math.floor(+(attr(s, k, "w:w") ?? 0) / 15)) : [];
974
1268
  const open = [];
975
1269
  let prev = grid2 ? grid2.end : pr ? pr.end : el.open;
976
1270
  for (const tr of el.kids) {
@@ -1006,7 +1300,10 @@ var Reader = class {
1006
1300
  if (vm === "continue") open[col].attrs.rowspan++;
1007
1301
  else {
1008
1302
  const content = assemble(inside.list);
1009
- cell.node = { type: header ? "tableHeader" : "tableCell", attrs: { colspan: span, rowspan: 1, align: null, indent: 0, ref: cref }, content: content.length ? content : [{ type: "paragraph", attrs: blank() }] };
1303
+ const own = widths.slice(col, col + span);
1304
+ const shd = tcPr && kid(tcPr, "w:shd");
1305
+ const fill = shd ? attr(s, shd, "w:fill") : null;
1306
+ cell.node = { type: header ? "tableHeader" : "tableCell", attrs: { colspan: span, rowspan: 1, colwidth: own.length === span && own.every((w) => w > 0) ? own : null, background: fill && /^[0-9a-f]{6}$/i.test(fill) ? `#${fill.toLowerCase()}` : null, align: null, indent: 0, ref: cref }, content: content.length ? content : [{ type: "paragraph", attrs: blank() }] };
1010
1307
  row.node.content.push(cell.node);
1011
1308
  for (let c = col; c < col + span; c++) open[c] = null;
1012
1309
  if (vm === "restart") open[col] = cell.node;
@@ -1087,10 +1384,16 @@ function fmtAt(p) {
1087
1384
  link ?? (link = p.span?.link ?? null);
1088
1385
  return link === f.link && rev === f.rev ? f : { ...f, link, rev };
1089
1386
  }
1387
+ var noteText = (xml) => [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&").trim();
1090
1388
  function inline(pieces) {
1091
1389
  const out = [];
1092
1390
  let key = "";
1093
1391
  for (const p of pieces) {
1392
+ if (p.math !== void 0 || p.note) {
1393
+ out.push(p.note ? { type: "footnote", attrs: { id: p.note.id, text: p.note.text } } : { type: "math", attrs: { latex: p.math } });
1394
+ key = "";
1395
+ continue;
1396
+ }
1094
1397
  if (p.img) {
1095
1398
  out.push({ type: "image", attrs: { ...p.img } });
1096
1399
  key = "";
@@ -1212,20 +1515,23 @@ var TC = ["w:cnfStyle", "w:tcW", "w:gridSpan", "w:hMerge", "w:vMerge", "w:tcBord
1212
1515
  var REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
1213
1516
  var special = { " ": "<w:tab/>", "\n": "<w:br/>", "\u2011": "<w:noBreakHyphen/>", "\xAD": "<w:softHyphen/>" };
1214
1517
  var keys = {
1215
- paragraph: [["align", null], ["indent", 0]],
1216
- heading: [["level", 1], ["align", null], ["indent", 0]],
1217
- table: [["align", null]],
1218
- tableCell: [["colspan", 1], ["rowspan", 1]],
1219
- tableHeader: [["colspan", 1], ["rowspan", 1]],
1518
+ paragraph: [["align", null], ["indent", 0], ["line", null], ["after", null]],
1519
+ heading: [["level", 1], ["align", null], ["indent", 0], ["line", null], ["after", null]],
1520
+ table: [["align", null], ["borders", null]],
1521
+ tableCell: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1522
+ tableHeader: [["colspan", 1], ["rowspan", 1], ["colwidth", null], ["background", null]],
1220
1523
  orderedList: [["start", 1]],
1221
1524
  taskItem: [["checked", false]],
1222
1525
  codeBlock: [["language", null]],
1223
- toc: [["entries", "[]"], ["title", null]]
1526
+ toc: [["entries", "[]"], ["title", null]],
1527
+ image: [["src", null], ["alt", null], ["title", null], ["width", null], ["height", null], ["wrap", null]]
1224
1528
  };
1225
1529
  function value(key, v) {
1226
1530
  if (v === void 0 || v === "" || v === null) return null;
1227
1531
  if (key === "align") return v === "left" ? null : v;
1228
1532
  if (key === "width" || key === "height") return Math.round(Number(v)) || null;
1533
+ if (key === "line" || key === "after") return Number.isFinite(Number(v)) ? Number(v) : null;
1534
+ if (key === "colwidth") return Array.isArray(v) && v.length && v.every((w) => Number(w) > 0) ? v.map((w) => Math.round(Number(w))) : null;
1229
1535
  if (key === "indent" || key === "level" || key === "colspan" || key === "rowspan" || key === "start") return Number(v) || 0;
1230
1536
  if (key === "checked") return !!v;
1231
1537
  return v;
@@ -1252,14 +1558,14 @@ function inlineSig(kids) {
1252
1558
  out += (next === key ? "" : `${next}`) + k.text;
1253
1559
  key = next;
1254
1560
  } else {
1255
- out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : ""}`;
1561
+ out += `${k.type}${k.type === "image" ? picture2(k.attrs ?? {}) : k.type === "math" ? k.attrs?.latex : k.type === "footnote" ? `${k.attrs?.id}:${k.attrs?.text}` : ""}`;
1256
1562
  key = null;
1257
1563
  }
1258
1564
  }
1259
1565
  return out;
1260
1566
  }
1261
1567
  function picture2(a) {
1262
- return JSON.stringify([a.src ?? null, a.alt || null, a.title || null, Math.round(Number(a.width)) || null, Math.round(Number(a.height)) || null]);
1568
+ return JSON.stringify([a.src ?? null, a.alt || null, a.title || null, Math.round(Number(a.width)) || null, Math.round(Number(a.height)) || null, a.wrap || null]);
1263
1569
  }
1264
1570
  var groups = 0;
1265
1571
  function flatten(content, out = [], quote = false) {
@@ -1383,6 +1689,7 @@ var Writer = class {
1383
1689
  this.srcs = null;
1384
1690
  this.tocs = false;
1385
1691
  this.revs = /* @__PURE__ */ new Map();
1692
+ this.lastNote = null;
1386
1693
  this.r = new Reader(pkg);
1387
1694
  this.s = pkg.doc;
1388
1695
  for (const id of pkg.rels.keys()) this.relIds.add(id);
@@ -1393,7 +1700,7 @@ var Writer = class {
1393
1700
  this.docPr = max + 1;
1394
1701
  this.nextRev = Math.max(0, ...[...this.s.matchAll(/\bw:id="(\d+)"/g)].map((m) => +m[1])) + 1;
1395
1702
  }
1396
- run(doc) {
1703
+ run(doc, setup) {
1397
1704
  const s = this.s;
1398
1705
  this.body = this.r.body();
1399
1706
  const { list, tail, body } = this.body;
@@ -1403,8 +1710,9 @@ var Writer = class {
1403
1710
  this.carryOver(list, (x) => rest = x);
1404
1711
  let xml = this.container(flatten(doc.content ?? []), list, null);
1405
1712
  if (this.last === "tbl" && list[list.length - 1]?.kind !== "tbl") xml += "<w:p/>";
1406
- const text = s.slice(0, body.open) + xml + rest + s.slice(tail);
1407
1713
  const changed = /* @__PURE__ */ new Map();
1714
+ const text = this.marginal(s.slice(0, body.open) + xml + rest + s.slice(tail), setup, changed);
1715
+ this.footnotes(doc, changed);
1408
1716
  if (text !== s) changed.set(this.pkg.main, text);
1409
1717
  if (this.rels.length) {
1410
1718
  const path = this.pkg.relsPath(this.pkg.main);
@@ -1530,6 +1838,110 @@ var Writer = class {
1530
1838
  if (o.kind === "toc") return b && sig(o.node) === sig(b.node) ? s.slice(b.start, b.end) : this.toc(o.node);
1531
1839
  return this.code(o);
1532
1840
  }
1841
+ noteId() {
1842
+ const rel = this.pkg.byType("/footnotes");
1843
+ const xml = rel ? this.pkg.text(rel.target) ?? "" : "";
1844
+ this.lastNote ?? (this.lastNote = Math.max(0, ...[...xml.matchAll(/<w:footnote\b[^>]*\bw:id="(-?\d+)"/g)].map((m) => +m[1])));
1845
+ return ++this.lastNote;
1846
+ }
1847
+ footnotes(doc, changed) {
1848
+ const notes = [];
1849
+ const walk = (n) => {
1850
+ if (n.type === "footnote" && n.attrs?.id) notes.push({ id: String(n.attrs.id), text: String(n.attrs.text ?? "") });
1851
+ n.content?.forEach(walk);
1852
+ };
1853
+ walk(doc);
1854
+ const rel = this.pkg.byType("/footnotes");
1855
+ const old = rel ? this.pkg.text(rel.target) : null;
1856
+ if (!notes.length) return;
1857
+ const path = rel ? rel.target : "word/footnotes.xml";
1858
+ let xml = old ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1859
+ <w:footnotes xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}"><w:footnote w:type="separator" w:id="-1"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:separator/></w:r></w:p></w:footnote><w:footnote w:type="continuationSeparator" w:id="0"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:continuationSeparator/></w:r></w:p></w:footnote></w:footnotes>`;
1860
+ const fresh = (id, words2) => `<w:footnote w:id="${id}"><w:p><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:footnoteRef/></w:r><w:r><w:rPr><w:sz w:val="20"/></w:rPr><w:t xml:space="preserve"> ${escape(words2)}</w:t></w:r></w:p></w:footnote>`;
1861
+ for (const n of notes) {
1862
+ const found = new RegExp(`<w:footnote\\b[^>]*\\bw:id="${n.id}"[^>]*>([\\s\\S]*?)</w:footnote>`).exec(xml);
1863
+ if (found && noteText(found[1]) === n.text) continue;
1864
+ xml = found ? xml.replace(found[0], fresh(n.id, n.text)) : xml.replace(/<\/w:footnotes>\s*$/, fresh(n.id, n.text) + "</w:footnotes>");
1865
+ }
1866
+ if (xml === old) return;
1867
+ changed.set(path, xml);
1868
+ if (rel) return;
1869
+ this.rels.push(`<Relationship Id="${this.relId()}" Type="${REL}/footnotes" Target="footnotes.xml"/>`);
1870
+ this.types.add(`<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>`);
1871
+ }
1872
+ marginal(text, setup, changed) {
1873
+ if (!setup || !setup.page && setup.header === void 0 && setup.footer === void 0 && setup.numbers === void 0) return text;
1874
+ const end = text.lastIndexOf("</w:body>");
1875
+ const opens = (i) => /^<w:sectPr[\s>/]/.test(text.slice(i, i + 11));
1876
+ let start = -1;
1877
+ let close = text.lastIndexOf("</w:sectPr>", end);
1878
+ if (close >= 0 && !text.slice(close + 11, end).trim()) {
1879
+ let depth = 1;
1880
+ let i = close;
1881
+ while (depth > 0 && i > 0) {
1882
+ let o = text.lastIndexOf("<w:sectPr", i - 1);
1883
+ while (o >= 0 && !opens(o)) o = text.lastIndexOf("<w:sectPr", o - 1);
1884
+ const c = text.lastIndexOf("</w:sectPr>", i - 1);
1885
+ if (c > o) {
1886
+ depth++;
1887
+ i = c;
1888
+ } else if (o < 0) break;
1889
+ else {
1890
+ if (text[text.indexOf(">", o) - 1] !== "/") depth--;
1891
+ i = o;
1892
+ }
1893
+ }
1894
+ start = i;
1895
+ close += 11;
1896
+ } else {
1897
+ start = close = end;
1898
+ }
1899
+ let sec = start === end ? "<w:sectPr></w:sectPr>" : text.slice(start, close);
1900
+ if (sec.endsWith("/>") && !sec.includes("</w:sectPr>")) sec = sec.slice(0, -2) + "></w:sectPr>";
1901
+ const after = ["w:pgMar", "w:paperSrc", "w:pgBorders", "w:lnNumType", "w:pgNumType", "w:cols", "w:formProt", "w:vAlign", "w:noEndnote", "w:titlePg", "w:textDirection", "w:bidi", "w:rtlGutter", "w:docGrid", "w:printerSettings", "w:sectPrChange"];
1902
+ const put = (name, xml, before) => {
1903
+ const re = new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`);
1904
+ if (re.test(sec)) {
1905
+ sec = sec.replace(re, xml);
1906
+ return;
1907
+ }
1908
+ const at = before.map((b) => sec.search(new RegExp(`<${b}[\\s>/]`))).filter((i2) => i2 >= 0);
1909
+ const i = at.length ? Math.min(...at) : sec.lastIndexOf("</w:sectPr>");
1910
+ sec = sec.slice(0, i) + xml + sec.slice(i);
1911
+ };
1912
+ const tw = (px) => Math.round(px * 15);
1913
+ if (setup.page) {
1914
+ const { width, height, margins: [top, right, bottom, left] } = setup.page;
1915
+ put("w:pgSz", `<w:pgSz w:w="${tw(width)}" w:h="${tw(height)}"${width > height ? ' w:orient="landscape"' : ""}/>`, after);
1916
+ const was = /<w:pgMar\b[^>]*\/>/.exec(sec)?.[0] ?? "";
1917
+ const keep = attrs(was.replace(/^<w:pgMar|\/>$/g, "")).filter(([k]) => !["w:top", "w:right", "w:bottom", "w:left"].includes(k));
1918
+ if (!keep.some(([k]) => k === "w:header")) keep.push(["w:header", "708"], ["w:footer", "708"], ["w:gutter", "0"]);
1919
+ put("w:pgMar", `<w:pgMar w:top="${tw(top)}" w:right="${tw(right)}" w:bottom="${tw(bottom)}" w:left="${tw(left)}" ${keep.map(([k, v]) => `${k}="${escape(v)}"`).join(" ")}/>`, after.slice(1));
1920
+ }
1921
+ const part = (kind, body) => {
1922
+ sec = sec.replace(new RegExp(`<w:${kind}Reference\\b[^>]*\\bw:type="default"[^>]*/>`), "");
1923
+ if (!body) return;
1924
+ let n = 1;
1925
+ while (this.pkg.files.has(`word/${kind}${n}.xml`) || changed.has(`word/${kind}${n}.xml`)) n++;
1926
+ const id = this.relId();
1927
+ const tag = kind === "header" ? "w:hdr" : "w:ftr";
1928
+ changed.set(`word/${kind}${n}.xml`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1929
+ <${tag} xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="${REL}">${body}</${tag}>`);
1930
+ this.rels.push(`<Relationship Id="${id}" Type="${REL}/${kind}" Target="${kind}${n}.xml"/>`);
1931
+ this.types.add(`<Override PartName="/word/${kind}${n}.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${kind}+xml"/>`);
1932
+ const open = sec.indexOf(">") + 1;
1933
+ sec = sec.slice(0, open) + `<w:${kind}Reference w:type="default" r:id="${id}"/>` + sec.slice(open);
1934
+ };
1935
+ const line = (words2, page) => {
1936
+ const field = '<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve"> PAGE </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:t>1</w:t></w:r><w:r><w:fldChar w:fldCharType="end"/></w:r>';
1937
+ const run2 = words2 ? `<w:r><w:t xml:space="preserve">${escape(words2)}</w:t></w:r>` : "";
1938
+ if (!words2 && !page) return "";
1939
+ return `<w:p><w:pPr>${page && words2 ? `<w:tabs><w:tab w:val="right" w:pos="${this.textWidth()}"/></w:tabs>` : page ? '<w:jc w:val="right"/>' : ""}</w:pPr>${run2}${page && words2 ? "<w:r><w:tab/></w:r>" : ""}${page ? field : ""}</w:p>`;
1940
+ };
1941
+ if (setup.header !== void 0) part("header", line(setup.header, false));
1942
+ if (setup.footer !== void 0 || setup.numbers !== void 0) part("footer", line(setup.footer ?? "", !!setup.numbers));
1943
+ return text.slice(0, start) + sec + text.slice(close);
1944
+ }
1533
1945
  toc(node) {
1534
1946
  this.tocs = true;
1535
1947
  const styles = this.pkg.styles;
@@ -1618,7 +2030,7 @@ var Writer = class {
1618
2030
  const rPr = kid(el, "w:rPr");
1619
2031
  xml = rebuild(xml, "w:pPr", P, { "w:sectPr": null, "w:pPrChange": null, "w:rPr": rPr ? rebuild(s.slice(rPr.start, rPr.end), "w:rPr", R, { "w:ins": null, "w:del": null, "w:moveFrom": null, "w:moveTo": null, "w:rPrChange": null }) || null : null });
1620
2032
  }
1621
- const root = xml ? parse(xml).kids[0] : void 0;
2033
+ const root = xml ? parse2(xml).kids[0] : void 0;
1622
2034
  const get = (name) => root && kid(root, name);
1623
2035
  const styleEl = get("w:pStyle");
1624
2036
  const was = { style: styleEl ? attr(xml, styleEl, "w:val") : null, level: src?.level ?? null, quote: src?.quote ?? false, list: src?.list ?? null };
@@ -1647,6 +2059,20 @@ var Writer = class {
1647
2059
  if (align(direct ?? styles.jc(style)) !== want) {
1648
2060
  set["w:jc"] = align(styles.jc(style)) === want ? null : `<w:jc w:val="${{ center: "center", right: "right", justify: "both" }[want ?? ""] ?? "left"}"/>`;
1649
2061
  }
2062
+ const spEl = get("w:spacing");
2063
+ const spacing = spEl ? attrs(xml.slice(spEl.start, spEl.open)) : [];
2064
+ const had = (name) => spacing.find(([k]) => k === name)?.[1] ?? null;
2065
+ const line = value("line", o.node.attrs?.line);
2066
+ const after = value("after", o.node.attrs?.after);
2067
+ const auto = !had("w:lineRule") || had("w:lineRule") === "auto";
2068
+ const drift = (had("w:line") && auto ? Math.round(+had("w:line") / 2.4) / 100 : null) !== line || (had("w:after") ? +had("w:after") / 20 : null) !== after;
2069
+ if ((b || line !== null || after !== null) && drift) {
2070
+ const kept = spacing.filter(([k]) => k !== "w:line" && k !== "w:lineRule" && k !== "w:after" && !(k === "w:afterAutospacing" && after !== null));
2071
+ if (line !== null) kept.push(["w:line", String(Math.round(line * 240))], ["w:lineRule", "auto"]);
2072
+ else if (had("w:line") && !auto) kept.push(["w:line", had("w:line")], ["w:lineRule", had("w:lineRule")]);
2073
+ if (after !== null) kept.push(["w:after", String(Math.round(after * 20))]);
2074
+ set["w:spacing"] = kept.length ? `<w:spacing ${kept.map(([k, v]) => `${k}="${escape(v)}"`).join(" ")}/>` : null;
2075
+ }
1650
2076
  if (!pr) {
1651
2077
  const indEl = "w:ind" in set ? void 0 : get("w:ind");
1652
2078
  const list = indEl ? attrs(xml.slice(indEl.start, indEl.open)).filter(([k]) => k !== "w:left" && k !== "w:start") : [];
@@ -1703,7 +2129,7 @@ var Writer = class {
1703
2129
  const base = p.span ? fmtAt({ ...p, span: null }) : fmt;
1704
2130
  if (p.img) units.push({ ch: "\uFFFC", raw: p.raw, run: p.run, ctx: p.ctx, span: null, idx: n++, fmt, base, img: p.img });
1705
2131
  else if (p.text === null) units.push({ ch: null, raw: p.raw, run: p.run, ctx: p.ctx, span: null, idx: n++, fmt, base, box: p.box });
1706
- else if (p.raw !== null) units.push({ ch: p.text, raw: p.raw, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base });
2132
+ else if (p.raw !== null) units.push({ ch: p.text, raw: p.raw, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base, math: p.math, note: p.note });
1707
2133
  else for (const ch of p.text) units.push({ ch, raw: null, run: p.run, ctx: p.ctx, span: p.span, idx: n++, fmt, base });
1708
2134
  if (p.run) counts.set(p.run, n);
1709
2135
  }
@@ -1718,6 +2144,8 @@ var Writer = class {
1718
2144
  for (const ch of n.text ?? "") B.push({ ch: ch === "\r" ? "\n" : ch, fmt: f, key: k });
1719
2145
  } else if (n.type === "hardBreak") B.push({ ch: "\n", fmt: lastFmt, key: keyOf(lastFmt) });
1720
2146
  else if (n.type === "image") B.push({ ch: "\uFFFC", fmt: lastFmt, key: keyOf(lastFmt), img: n.attrs ?? {} });
2147
+ else if (n.type === "math") B.push({ ch: "\uE000", fmt: lastFmt, key: keyOf(lastFmt), math: String(n.attrs?.latex ?? "") });
2148
+ else if (n.type === "footnote") B.push({ ch: "\uE001", fmt: lastFmt, key: keyOf(lastFmt), note: n.attrs ?? (n.attrs = {}) });
1721
2149
  }
1722
2150
  const boxes = units.filter((u) => u.box);
1723
2151
  let box = null;
@@ -1773,6 +2201,20 @@ var Writer = class {
1773
2201
  } else out.push({ ch: want.ch, raw: this.drawing(want.img), run: { open: "<w:r>", rPr: "", fmt: plain, el: null, parent: null }, ctx: [], u: null, fmt: plain });
1774
2202
  continue;
1775
2203
  }
2204
+ if (want.math !== void 0) {
2205
+ const u = i >= 0 ? A[i] : null;
2206
+ out.push(u?.math === want.math ? { ch: u.ch, raw: u.raw, run: null, ctx: u.ctx, u, fmt: u.fmt } : { ch: want.ch, raw: omml(want.math), run: null, ctx: u?.ctx ?? [], u: null, fmt: plain });
2207
+ continue;
2208
+ }
2209
+ if (want.note) {
2210
+ const u = i >= 0 ? A[i] : null;
2211
+ if (u?.note && u.note.id === want.note.id) out.push({ ch: u.ch, raw: u.raw, run: u.run, ctx: u.ctx, u, fmt: u.fmt });
2212
+ else {
2213
+ want.note.id = typeof want.note.id === "string" && want.note.id ? want.note.id : String(this.noteId());
2214
+ out.push({ ch: want.ch, raw: `<w:footnoteReference w:id="${want.note.id}"/>`, run: { open: "<w:r>", rPr: '<w:rPr><w:vertAlign w:val="superscript"/></w:rPr>', fmt: plain, el: null, parent: null }, ctx: [], u: null, fmt: plain });
2215
+ }
2216
+ continue;
2217
+ }
1776
2218
  if (i >= 0) {
1777
2219
  const u = A[i];
1778
2220
  if (u.span && intact.has(u.span)) {
@@ -1782,18 +2224,18 @@ var Writer = class {
1782
2224
  const from = u.span ? u.base : u.fmt;
1783
2225
  const keep = u.ch === "\n" || keyOf(from) === want.key;
1784
2226
  const fmt = keep ? from : want.fmt;
1785
- const run = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
1786
- out.push({ ch: u.ch, raw: u.raw, run, ctx: this.revised(this.linked(u.ctx, fmt.link, lastChar()), fmt.rev), u: keep && u.run ? u : null, fmt });
2227
+ const run2 = keep && u.run ? u.run : this.derive(u.run ?? paraBase.run, from, want.fmt);
2228
+ out.push({ ch: u.ch, raw: u.raw, run: run2, ctx: this.revised(this.linked(u.ctx, fmt.link, lastChar()), fmt.rev), u: keep && u.run ? u : null, fmt });
1787
2229
  } else {
1788
2230
  const left = lastChar();
1789
2231
  const right = next[j + 1] >= 0 ? A[next[j + 1]] : null;
1790
2232
  const base = left ? { run: left.run, fmt: left.fmt } : right ? { run: right.run ?? paraBase.run, fmt: right.span ? right.base : right.fmt } : paraBase;
1791
- const run = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
2233
+ const run2 = keyOf(base.fmt) === want.key ? base.run : this.derive(base.run, base.fmt, want.fmt);
1792
2234
  const shared = [];
1793
2235
  if (left && right) {
1794
2236
  for (let k = 0; k < left.ctx.length && left.ctx[k] === right.ctx[k]; k++) if (!left.ctx[k].link) shared.push(left.ctx[k]);
1795
2237
  }
1796
- out.push({ ch: want.ch, raw: null, run, ctx: this.revised(this.linked(shared, want.fmt.link, left), want.fmt.rev), u: null, fmt: want.fmt });
2238
+ out.push({ ch: want.ch, raw: null, run: run2, ctx: this.revised(this.linked(shared, want.fmt.link, left), want.fmt.rev), u: null, fmt: want.fmt });
1797
2239
  }
1798
2240
  }
1799
2241
  let xml = "";
@@ -1876,14 +2318,14 @@ var Writer = class {
1876
2318
  this.relIds.add(`rId${n}`);
1877
2319
  return `rId${n}`;
1878
2320
  }
1879
- derive(run, from, to) {
1880
- const cache = run.derived ?? (run.derived = /* @__PURE__ */ new Map());
2321
+ derive(run2, from, to) {
2322
+ const cache = run2.derived ?? (run2.derived = /* @__PURE__ */ new Map());
1881
2323
  const key = keyOf(from) + ">" + keyOf(to);
1882
- if (!cache.has(key)) cache.set(key, { open: run.open, rPr: this.delta(run.rPr, from, to), fmt: to, el: null, parent: null });
2324
+ if (!cache.has(key)) cache.set(key, { open: run2.open, rPr: this.delta(run2.rPr, from, to), fmt: to, el: null, parent: null });
1883
2325
  return cache.get(key);
1884
2326
  }
1885
2327
  delta(rPr, from, to) {
1886
- const root = rPr ? parse(rPr).kids[0] : void 0;
2328
+ const root = rPr ? parse2(rPr).kids[0] : void 0;
1887
2329
  const get = (name) => root && kid(root, name);
1888
2330
  const styleEl = get("w:rStyle");
1889
2331
  const style = styleEl ? attr(rPr, styleEl, "w:val") : null;
@@ -1901,6 +2343,7 @@ var Writer = class {
1901
2343
  set["w:strike"] = to.s ? "<w:strike/>" : sf.s ? '<w:strike w:val="0"/>' : null;
1902
2344
  if (!to.s) set["w:dstrike"] = null;
1903
2345
  }
2346
+ if (to.va !== from.va) set["w:vertAlign"] = to.va ? `<w:vertAlign w:val="${to.va === "sup" ? "superscript" : "subscript"}"/>` : sf.va ? '<w:vertAlign w:val="baseline"/>' : null;
1904
2347
  if (to.color !== from.color) set["w:color"] = to.color ? `<w:color w:val="${to.color.slice(1).toUpperCase()}"/>` : sf.color ? '<w:color w:val="auto"/>' : null;
1905
2348
  if (to.size !== from.size) {
1906
2349
  const hp = to.size ? Math.round(parseFloat(to.size) * 2) : 0;
@@ -1927,8 +2370,8 @@ var Writer = class {
1927
2370
  } else if (!to.link && from.link && this.pkg.styles.isLink(style)) set["w:rStyle"] = null;
1928
2371
  return Object.keys(set).length ? rebuild(rPr, "w:rPr", R, set) : rPr;
1929
2372
  }
1930
- runXml(run, glyphs, counts) {
1931
- if (run.el && glyphs.length === counts.get(run) && glyphs.every((g, n) => g.u && g.u.run === run && g.u.idx === n)) return this.s.slice(run.el.start, run.el.end);
2373
+ runXml(run2, glyphs, counts) {
2374
+ if (run2.el && glyphs.length === counts.get(run2) && glyphs.every((g, n) => g.u && g.u.run === run2 && g.u.idx === n)) return this.s.slice(run2.el.start, run2.el.end);
1932
2375
  let body = "";
1933
2376
  let text = "";
1934
2377
  const tag = glyphs[0]?.ctx.some((w) => w.rev?.startsWith('["del"')) ? "w:delText" : "w:t";
@@ -1943,7 +2386,7 @@ var Writer = class {
1943
2386
  } else text += g.ch;
1944
2387
  }
1945
2388
  flush();
1946
- return run.open + run.rPr + body + "</w:r>";
2389
+ return run2.open + run2.rPr + body + "</w:r>";
1947
2390
  }
1948
2391
  embed(src) {
1949
2392
  if (!this.srcs) {
@@ -1959,6 +2402,17 @@ var Writer = class {
1959
2402
  this.srcs.set(src, added.id);
1960
2403
  return added;
1961
2404
  }
2405
+ wrapped(raw, side) {
2406
+ const anchor = /<wp:anchor\b/.test(raw);
2407
+ if (!side && !anchor) return raw;
2408
+ const ns = (tag) => attrs(/<wp:(?:inline|anchor)\b([^>]*)>/.exec(tag)?.[1] ?? "").filter(([k]) => k.startsWith("xmlns")).map(([k, v]) => ` ${k}="${v}"`).join("");
2409
+ const part = (name) => new RegExp(`<${name}\\b[^>]*?(?:/>|>[\\s\\S]*?</${name}>)`).exec(raw)?.[0] ?? "";
2410
+ const body = part("wp:extent") + part("wp:effectExtent");
2411
+ const rest = part("wp:docPr") + part("wp:cNvGraphicFramePr") + part("a:graphic");
2412
+ if (!side) return raw.replace(/<wp:anchor\b[\s\S]*<\/wp:anchor>/, `<wp:inline distT="0" distB="0" distL="0" distR="0"${ns(raw)}>${body}${rest}</wp:inline>`);
2413
+ const head = `<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1"${ns(raw)}><wp:simplePos x="0" y="0"/><wp:positionH relativeFrom="column"><wp:align>${side === "right" ? "right" : "left"}</wp:align></wp:positionH><wp:positionV relativeFrom="paragraph"><wp:posOffset>0</wp:posOffset></wp:positionV>`;
2414
+ return raw.replace(anchor ? /<wp:anchor\b[\s\S]*<\/wp:anchor>/ : /<wp:inline\b[\s\S]*<\/wp:inline>/, `${head}${body}<wp:wrapSquare wrapText="bothSides"/>${rest}</wp:anchor>`);
2415
+ }
1962
2416
  drawing(img) {
1963
2417
  const media = this.embed(String(img.src ?? ""));
1964
2418
  const max = Math.round(this.textWidth() / 15);
@@ -1970,7 +2424,8 @@ var Writer = class {
1970
2424
  else if (!w) w = Math.round(h * nw / nh);
1971
2425
  const id = this.docPr++;
1972
2426
  const ext = `cx="${Math.round(w * 9525)}" cy="${Math.round(h * 9525)}"`;
1973
- return `<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><wp:extent ${ext}/><wp:effectExtent l="0" t="0" r="0" b="0"/>${meta(`<wp:docPr id="${id}" name="Picture ${id}"/>`, img)}<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="${id}" name="Picture ${id}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${media.id}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext ${ext}/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing>`;
2427
+ const xml = `<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><wp:extent ${ext}/><wp:effectExtent l="0" t="0" r="0" b="0"/>${meta(`<wp:docPr id="${id}" name="Picture ${id}"/>`, img)}<wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/></wp:cNvGraphicFramePr><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="${id}" name="Picture ${id}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${media.id}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext ${ext}/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic></wp:inline></w:drawing>`;
2428
+ return img.wrap ? this.wrapped(xml, img.wrap) : xml;
1974
2429
  }
1975
2430
  patch(raw, old, img) {
1976
2431
  let xml = raw;
@@ -1982,6 +2437,7 @@ var Writer = class {
1982
2437
  }
1983
2438
  if ((img.alt || null) !== (old.alt || null) || (img.title || null) !== (old.title || null)) xml = xml.replace(/<wp:docPr\b[^>]*>/, (tag) => meta(tag, img));
1984
2439
  if (img.src !== old.src) xml = xml.replace(/(<a:blip\b[^>]*\br:embed=")[^"]*"/, `$1${this.embed(String(img.src ?? "")).id}"`);
2440
+ if ((img.wrap || null) !== (old.wrap || null)) xml = this.wrapped(xml, img.wrap);
1985
2441
  return xml;
1986
2442
  }
1987
2443
  textWidth() {
@@ -2047,6 +2503,27 @@ var Writer = class {
2047
2503
  head = `<w:tbl>${tblPr}<w:tblGrid>${`<w:gridCol w:w="${Math.floor(this.textWidth() / cols)}"/>`.repeat(cols)}</w:tblGrid>`;
2048
2504
  }
2049
2505
  const width = Math.floor(this.textWidth() / cols);
2506
+ const sized = [];
2507
+ for (const r of layout) for (const sl of r) {
2508
+ const own2 = sl.cell && value("colwidth", sl.cell.attrs?.colwidth);
2509
+ if (own2 && own2.length === sl.span) own2.forEach((w, k) => {
2510
+ var _a;
2511
+ return sized[_a = sl.col + k] ?? (sized[_a] = w);
2512
+ });
2513
+ }
2514
+ const known = sized.length === cols && sized.every(Boolean);
2515
+ const had = [...head.matchAll(/<w:gridCol\b[^>]*\bw:w="(\d+)"/g)].map((m) => Math.floor(+m[1] / 15));
2516
+ if (known && had.join() !== sized.join()) {
2517
+ const list = sized.map((w) => `<w:gridCol w:w="${Math.round(w * 15)}"/>`).join("");
2518
+ head = head.replace(/(<w:tblGrid\b[^>]*>)[\s\S]*?(<\/w:tblGrid>)/, `$1${list}$2`);
2519
+ }
2520
+ const own = (col, span) => known ? sized.slice(col, col + span) : null;
2521
+ const borders = value("borders", o.node.attrs?.borders);
2522
+ if (borders !== value("borders", b?.node.attrs?.borders)) {
2523
+ const line = (side) => `<w:${side} w:val="${borders === "none" ? "none" : "single"}" w:sz="4" w:space="0" w:color="${borders === "none" ? "auto" : "94A3B8"}"/>`;
2524
+ const all = `<w:tblBorders>${["top", "left", "bottom", "right", "insideH", "insideV"].map(line).join("")}</w:tblBorders>`;
2525
+ head = /<w:tblBorders\b/.test(head) ? head.replace(/<w:tblBorders\b[\s\S]*?<\/w:tblBorders>|<w:tblBorders\/>/, all) : head.replace(/(<w:tblPr\b[^>]*>(?:(?!<\/w:tblPr>)[\s\S])*?)(<w:shd\b|<w:tblLayout\b|<w:tblCellMar\b|<w:tblLook\b|<w:tblCaption\b|<w:tblDescription\b|<w:tblPrChange\b|<\/w:tblPr>)/, `$1${all}$2`);
2526
+ }
2050
2527
  let xml = head;
2051
2528
  let above = [];
2052
2529
  let aboveRow = null;
@@ -2077,7 +2554,7 @@ var Writer = class {
2077
2554
  if (!sl.cell) {
2078
2555
  const cont = R2?.cells.find((c) => c.vm === "continue" && c.col === sl.col);
2079
2556
  if (cont) xml += cont.lead + s.slice(cont.el.start, cont.el.end);
2080
- else xml += `<w:tc>${this.tcPr(cover.get(sl.from) ?? above[sl.col] ?? null, sl.span, "continue", width)}<w:p/></w:tc>`;
2557
+ else xml += `<w:tc>${this.tcPr(cover.get(sl.from) ?? above[sl.col] ?? null, sl.span, "continue", width, true, own(sl.col, sl.span))}<w:p/></w:tc>`;
2081
2558
  now[sl.col] = cover.get(sl.from) ?? null;
2082
2559
  continue;
2083
2560
  }
@@ -2093,7 +2570,7 @@ var Writer = class {
2093
2570
  const fallback = srcCell?.blocks.find((x) => x.kind === "p") ?? null;
2094
2571
  let inside = this.container(flatten(sl.cell.content ?? []), C ? C.blocks : [], fallback) + (C ? this.left.get(C) ?? "" : "");
2095
2572
  if (!this.last || this.last === "tbl") inside += "<w:p/>";
2096
- xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C) + inside + (C ? C.tail : "") + "</w:tc>";
2573
+ xml += (C ? C.lead + opened(s, C.el) : "<w:tc>") + this.tcPr(srcCell, sl.span, vm, width, !C, own(sl.col, sl.span), value("background", sl.cell.attrs?.background)) + inside + (C ? C.tail : "") + "</w:tc>";
2097
2574
  }
2098
2575
  const lastCell = R2?.cells[R2.cells.length - 1];
2099
2576
  xml += (R2 && lastCell ? s.slice(lastCell.el.end, R2.el.close) : "") + "</w:tr>";
@@ -2102,15 +2579,21 @@ var Writer = class {
2102
2579
  });
2103
2580
  return xml + tail + "</w:tbl>";
2104
2581
  }
2105
- tcPr(src, span, vm, width, clone = true) {
2582
+ tcPr(src, span, vm, width, clone = true, own = null, fill) {
2106
2583
  const s = this.s;
2107
2584
  const el = src && kid(src.el, "w:tcPr");
2108
2585
  const xml = el ? s.slice(el.start, el.end) : "";
2109
- if (!clone && src && src.span === span && src.vm === vm) return xml;
2586
+ const tcW = el && kid(el, "w:tcW");
2587
+ const sized = own ? Math.round(own.reduce((a, w) => a + w, 0) * 15) : null;
2588
+ const resized = sized !== null && !(tcW && attr(s, tcW, "w:type") === "dxa" && Math.abs(+(attr(s, tcW, "w:w") ?? 0) - sized) < 15);
2589
+ const was = src?.node ? value("background", src.node.attrs?.background) : null;
2590
+ const painted = fill !== void 0 && fill !== was;
2591
+ if (!clone && src && src.span === span && src.vm === vm && !resized && !painted) return xml;
2110
2592
  const set = { "w:gridSpan": span > 1 ? `<w:gridSpan w:val="${span}"/>` : null, "w:vMerge": vm === "restart" ? '<w:vMerge w:val="restart"/>' : vm ? "<w:vMerge/>" : null, "w:hMerge": null };
2111
2593
  if (clone) Object.assign(set, { "w:cellIns": null, "w:cellDel": null, "w:cellMerge": null, "w:tcPrChange": null });
2112
- const tcW = el && kid(el, "w:tcW");
2113
- if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span}" w:type="dxa"/>`;
2594
+ if (painted) set["w:shd"] = fill ? `<w:shd w:val="clear" w:color="auto" w:fill="${fill.slice(1).toUpperCase()}"/>` : null;
2595
+ if (resized) set["w:tcW"] = `<w:tcW w:w="${sized}" w:type="dxa"/>`;
2596
+ else if (!tcW && !src) set["w:tcW"] = `<w:tcW w:w="${width * span}" w:type="dxa"/>`;
2114
2597
  else if (tcW && src && src.span !== span && attr(xml, tcW, "w:type") === "dxa") set["w:tcW"] = `<w:tcW w:w="${Math.round(+(attr(xml, tcW, "w:w") ?? 0) * span / src.span)}" w:type="dxa"/>`;
2115
2598
  return rebuild(xml, "w:tcPr", TC, set);
2116
2599
  }
@@ -2142,15 +2625,24 @@ async function readDocx(bytes) {
2142
2625
  const size2 = sect && kid(sect, "w:pgSz");
2143
2626
  const mar = sect && kid(sect, "w:pgMar");
2144
2627
  const px = (el, name, fallback) => Math.round(Math.abs(+((el && attr(s, el, name)) ?? fallback)) / 15 * 100) / 100;
2628
+ const words2 = (kind) => {
2629
+ const ref = sect?.kids.find((k) => k.name === `w:${kind}Reference` && attr(s, k, "w:type") === "default");
2630
+ const part = ref && pkg.rels.get(attr(s, ref, "r:id") ?? "");
2631
+ const xml = part ? pkg.text(part.target) ?? "" : "";
2632
+ return { text: [...xml.matchAll(/<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g)].map((m) => m[1]).join("").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").trim(), page: /\bPAGE\b/.test(xml) };
2633
+ };
2634
+ const head = words2("header");
2635
+ const foot = words2("footer");
2145
2636
  return {
2637
+ marginal: { header: head.text, footer: foot.page ? foot.text.replace(/\s*\d+$/, "") : foot.text, numbers: foot.page },
2146
2638
  doc: { type: "doc", content: content.length ? content : [{ type: "paragraph", attrs: { align: null, indent: 0, ref: null } }] },
2147
2639
  styles: pkg.styles.list(),
2148
2640
  page: { width: px(size2, "w:w", 12240), height: px(size2, "w:h", 15840), margins: [px(mar, "w:top", 1440), px(mar, "w:right", 1440), px(mar, "w:bottom", 1440), px(mar, "w:left", 1440)] }
2149
2641
  };
2150
2642
  }
2151
- async function writeDocx(original, doc, load = fetched) {
2643
+ async function writeDocx(original, doc, load = fetched, setup) {
2152
2644
  const pkg = new Pkg(new Uint8Array(original));
2153
- const out = new Writer(pkg, await images(doc, load)).run(doc);
2645
+ const out = new Writer(pkg, await images(doc, load)).run(doc, setup);
2154
2646
  return out ? out.slice().buffer : original.slice(0);
2155
2647
  }
2156
2648
 
@@ -2170,6 +2662,10 @@ var en = {
2170
2662
  versions: "Versions",
2171
2663
  details: "Details",
2172
2664
  noOutline: "This document has no headings",
2665
+ findHeading: "Find a heading",
2666
+ read: "read",
2667
+ showSections: "Show sections",
2668
+ hideSections: "Hide sections",
2173
2669
  current: "Current",
2174
2670
  size: "Size",
2175
2671
  updated: "Updated",
@@ -2217,6 +2713,12 @@ var en = {
2217
2713
  save: "Save",
2218
2714
  saving: "Saving",
2219
2715
  saved: "Saved",
2716
+ align: "Align",
2717
+ moreTools: "More tools",
2718
+ fewerTools: "Fewer tools",
2719
+ typeFilter: "Type",
2720
+ selectAll: "Select all",
2721
+ clearPick: "Clear",
2220
2722
  saveFailed: "Could not save",
2221
2723
  remove: "Remove",
2222
2724
  notePlaceholder: "Write a note",
@@ -2280,6 +2782,14 @@ var en = {
2280
2782
  chooseFile: "Choose a file",
2281
2783
  put: "Insert",
2282
2784
  link: "Link",
2785
+ footnote: "Footnote",
2786
+ footnoteText: "Footnote text",
2787
+ formula: "Formula",
2788
+ formulaHint: "Saved as a Word equation",
2789
+ symbols: "Special characters",
2790
+ symbolSearch: "Search, for example arrow",
2791
+ update: "Update",
2792
+ removeFootnote: "Remove footnote",
2283
2793
  linkAddress: "Link address",
2284
2794
  apply: "Apply",
2285
2795
  unlink: "Remove link",
@@ -2326,6 +2836,11 @@ var en = {
2326
2836
  someone: "Someone",
2327
2837
  copyAs: "Make an XLSX copy",
2328
2838
  copyFailed: "Could not make the copy",
2839
+ downloadAs: "Download as",
2840
+ makeCopy: "Make a copy",
2841
+ copyOf: "Copy of",
2842
+ rename: "Rename",
2843
+ renameFailed: "Could not rename",
2329
2844
  editComment: "Edit",
2330
2845
  delete: "Delete",
2331
2846
  deleteAsk: "Delete this comment?",
@@ -2411,7 +2926,52 @@ var en = {
2411
2926
  untitled: "Untitled",
2412
2927
  kindHints: { docx: "Word, DOCX", markdown: "MD, same editor", sheet: "Excel, XLSX", slides: "HTML slides" },
2413
2928
  newKinds: { docx: "Document", markdown: "Markdown", sheet: "Spreadsheet", slides: "Presentation" },
2414
- templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" }
2929
+ templates: { blank: "Blank", letter: "Letter", contract: "Contract", notes: "Meeting notes", invoice: "Invoice", report: "Report" },
2930
+ menuFile: "File",
2931
+ menuEdit: "Edit",
2932
+ menuFormat: "Format",
2933
+ menuTools: "Tools",
2934
+ zoom: "Zoom",
2935
+ font: "Font",
2936
+ fontSize: "Font size",
2937
+ defaultFont: "Default",
2938
+ lineSpacing: "Line and paragraph spacing",
2939
+ single: "Single",
2940
+ double: "Double",
2941
+ spaceAfter: "Add space after paragraph",
2942
+ noSpaceAfter: "Remove space after paragraph",
2943
+ superscript: "Superscript",
2944
+ subscript: "Subscript",
2945
+ painter: "Paint format",
2946
+ painterHint: "Select text to paint, double click keeps it on, Esc stops",
2947
+ pageSetup: "Page setup",
2948
+ orientation: "Orientation",
2949
+ portrait: "Portrait",
2950
+ landscape: "Landscape",
2951
+ marginsCm: "Margins, cm",
2952
+ mTop: "Top",
2953
+ mRight: "Right",
2954
+ mBottom: "Bottom",
2955
+ mLeft: "Left",
2956
+ headerText: "Header",
2957
+ footerText: "Footer",
2958
+ pageNumbers: "Page numbers in the footer",
2959
+ wrapInline: "In line with text",
2960
+ wrapLeft: "Text wraps on the right",
2961
+ wrapRight: "Text wraps on the left",
2962
+ cellFill: "Cell fill",
2963
+ tableBorders: "Table borders",
2964
+ findReplace: "Find and replace",
2965
+ replaceWith: "Replace with",
2966
+ replaceOne: "Replace",
2967
+ replaceAll: "Replace all",
2968
+ matchCase: "Match case",
2969
+ words: "Words",
2970
+ print: "Print",
2971
+ autosavedNote: "Autosaved",
2972
+ uploadFile: "Upload a file",
2973
+ uploading: "Uploading",
2974
+ uploadFailed: "Could not upload the file"
2415
2975
  };
2416
2976
  var pl = {
2417
2977
  documents: "Dokumenty",
@@ -2428,6 +2988,10 @@ var pl = {
2428
2988
  versions: "Wersje",
2429
2989
  details: "Szczeg\xF3\u0142y",
2430
2990
  noOutline: "Ten dokument nie ma nag\u0142\xF3wk\xF3w",
2991
+ findHeading: "Znajd\u017A nag\u0142\xF3wek",
2992
+ read: "przeczytano",
2993
+ showSections: "Poka\u017C sekcje",
2994
+ hideSections: "Ukryj sekcje",
2431
2995
  current: "Bie\u017C\u0105ca",
2432
2996
  size: "Rozmiar",
2433
2997
  updated: "Zmieniono",
@@ -2475,6 +3039,12 @@ var pl = {
2475
3039
  save: "Zapisz",
2476
3040
  saving: "Zapisywanie",
2477
3041
  saved: "Zapisano",
3042
+ align: "Wyr\xF3wnanie",
3043
+ moreTools: "Wi\u0119cej narz\u0119dzi",
3044
+ fewerTools: "Mniej narz\u0119dzi",
3045
+ typeFilter: "Typ",
3046
+ selectAll: "Zaznacz wszystkie",
3047
+ clearPick: "Wyczy\u015B\u0107",
2478
3048
  saveFailed: "Nie uda\u0142o si\u0119 zapisa\u0107",
2479
3049
  remove: "Usu\u0144",
2480
3050
  notePlaceholder: "Napisz notatk\u0119",
@@ -2538,6 +3108,14 @@ var pl = {
2538
3108
  chooseFile: "Wybierz plik",
2539
3109
  put: "Wstaw",
2540
3110
  link: "Link",
3111
+ footnote: "Przypis",
3112
+ footnoteText: "Tekst przypisu",
3113
+ formula: "Wz\xF3r",
3114
+ formulaHint: "Zapisany jako r\xF3wnanie Word",
3115
+ symbols: "Znaki specjalne",
3116
+ symbolSearch: "Szukaj, na przyk\u0142ad strza\u0142ka",
3117
+ update: "Zmie\u0144",
3118
+ removeFootnote: "Usu\u0144 przypis",
2541
3119
  linkAddress: "Adres linku",
2542
3120
  apply: "Zastosuj",
2543
3121
  unlink: "Usu\u0144 link",
@@ -2583,6 +3161,11 @@ var pl = {
2583
3161
  removed: "Usuni\u0119to",
2584
3162
  someone: "Kto\u015B",
2585
3163
  copyAs: "Zr\xF3b kopi\u0119 XLSX",
3164
+ downloadAs: "Pobierz jako",
3165
+ makeCopy: "Utw\xF3rz kopi\u0119",
3166
+ copyOf: "Kopia",
3167
+ rename: "Zmie\u0144 nazw\u0119",
3168
+ renameFailed: "Nie uda\u0142o si\u0119 zmieni\u0107 nazwy",
2586
3169
  copyFailed: "Nie uda\u0142o si\u0119 zrobi\u0107 kopii",
2587
3170
  editComment: "Edytuj",
2588
3171
  delete: "Usu\u0144",
@@ -2669,7 +3252,52 @@ var pl = {
2669
3252
  untitled: "Bez tytu\u0142u",
2670
3253
  kindHints: { docx: "Word, DOCX", markdown: "MD, ten sam edytor", sheet: "Excel, XLSX", slides: "Slajdy HTML" },
2671
3254
  newKinds: { docx: "Dokument", markdown: "Markdown", sheet: "Arkusz", slides: "Prezentacja" },
2672
- templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" }
3255
+ templates: { blank: "Pusty", letter: "List", contract: "Umowa", notes: "Notatki ze spotkania", invoice: "Faktura", report: "Raport" },
3256
+ menuFile: "Plik",
3257
+ menuEdit: "Edycja",
3258
+ menuFormat: "Format",
3259
+ menuTools: "Narz\u0119dzia",
3260
+ zoom: "Powi\u0119kszenie",
3261
+ font: "Czcionka",
3262
+ fontSize: "Rozmiar czcionki",
3263
+ defaultFont: "Domy\u015Blna",
3264
+ lineSpacing: "Interlinia i odst\u0119py",
3265
+ single: "Pojedyncza",
3266
+ double: "Podw\xF3jna",
3267
+ spaceAfter: "Dodaj odst\u0119p po akapicie",
3268
+ noSpaceAfter: "Usu\u0144 odst\u0119p po akapicie",
3269
+ superscript: "Indeks g\xF3rny",
3270
+ subscript: "Indeks dolny",
3271
+ painter: "Malarz format\xF3w",
3272
+ painterHint: "Zaznacz tekst, dwuklik zostawia w\u0142\u0105czone, Esc ko\u0144czy",
3273
+ pageSetup: "Ustawienia strony",
3274
+ orientation: "Orientacja",
3275
+ portrait: "Pionowa",
3276
+ landscape: "Pozioma",
3277
+ marginsCm: "Marginesy, cm",
3278
+ mTop: "G\xF3rny",
3279
+ mRight: "Prawy",
3280
+ mBottom: "Dolny",
3281
+ mLeft: "Lewy",
3282
+ headerText: "Nag\u0142\xF3wek",
3283
+ footerText: "Stopka",
3284
+ pageNumbers: "Numery stron w stopce",
3285
+ wrapInline: "W linii z tekstem",
3286
+ wrapLeft: "Tekst op\u0142ywa z prawej",
3287
+ wrapRight: "Tekst op\u0142ywa z lewej",
3288
+ cellFill: "Wype\u0142nienie kom\xF3rki",
3289
+ tableBorders: "Obramowanie tabeli",
3290
+ findReplace: "Znajd\u017A i zamie\u0144",
3291
+ replaceWith: "Zamie\u0144 na",
3292
+ replaceOne: "Zamie\u0144",
3293
+ replaceAll: "Zamie\u0144 wszystko",
3294
+ matchCase: "Uwzgl\u0119dnij wielko\u015B\u0107 liter",
3295
+ words: "S\u0142owa",
3296
+ print: "Drukuj",
3297
+ autosavedNote: "Zapisano automatycznie",
3298
+ uploadFile: "Wgraj plik",
3299
+ uploading: "Wysy\u0142anie",
3300
+ uploadFailed: "Nie uda\u0142o si\u0119 wgra\u0107 pliku"
2673
3301
  };
2674
3302
  var uk = {
2675
3303
  documents: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0438",
@@ -2686,6 +3314,10 @@ var uk = {
2686
3314
  versions: "\u0412\u0435\u0440\u0441\u0456\u0457",
2687
3315
  details: "\u0414\u0435\u0442\u0430\u043B\u0456",
2688
3316
  noOutline: "\u0423 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0456 \u043D\u0435\u043C\u0430\u0454 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0456\u0432",
3317
+ findHeading: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A",
3318
+ read: "\u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043E",
3319
+ showSections: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
3320
+ hideSections: "\u0421\u0445\u043E\u0432\u0430\u0442\u0438 \u0440\u043E\u0437\u0434\u0456\u043B\u0438",
2689
3321
  current: "\u041F\u043E\u0442\u043E\u0447\u043D\u0430",
2690
3322
  size: "\u0420\u043E\u0437\u043C\u0456\u0440",
2691
3323
  updated: "\u0417\u043C\u0456\u043D\u0435\u043D\u043E",
@@ -2733,6 +3365,12 @@ var uk = {
2733
3365
  save: "\u0417\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
2734
3366
  saving: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043D\u044F",
2735
3367
  saved: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E",
3368
+ align: "\u0412\u0438\u0440\u0456\u0432\u043D\u044E\u0432\u0430\u043D\u043D\u044F",
3369
+ moreTools: "\u0411\u0456\u043B\u044C\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
3370
+ fewerTools: "\u041C\u0435\u043D\u0448\u0435 \u0456\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0456\u0432",
3371
+ typeFilter: "\u0422\u0438\u043F",
3372
+ selectAll: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0441\u0456",
3373
+ clearPick: "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",
2736
3374
  saveFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0431\u0435\u0440\u0435\u0433\u0442\u0438",
2737
3375
  remove: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
2738
3376
  notePlaceholder: "\u041D\u0430\u043F\u0438\u0448\u0456\u0442\u044C \u043D\u043E\u0442\u0430\u0442\u043A\u0443",
@@ -2795,6 +3433,14 @@ var uk = {
2795
3433
  imageLink: "\u0410\u0434\u0440\u0435\u0441\u0430 \u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u043D\u044F",
2796
3434
  chooseFile: "\u0412\u0438\u0431\u0440\u0430\u0442\u0438 \u0444\u0430\u0439\u043B",
2797
3435
  put: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u0438",
3436
+ footnote: "\u0412\u0438\u043D\u043E\u0441\u043A\u0430",
3437
+ footnoteText: "\u0422\u0435\u043A\u0441\u0442 \u0432\u0438\u043D\u043E\u0441\u043A\u0438",
3438
+ formula: "\u0424\u043E\u0440\u043C\u0443\u043B\u0430",
3439
+ formulaHint: "\u0417\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044C\u0441\u044F \u044F\u043A \u0440\u0456\u0432\u043D\u044F\u043D\u043D\u044F Word",
3440
+ symbols: "\u0421\u043F\u0435\u0446\u0441\u0438\u043C\u0432\u043E\u043B\u0438",
3441
+ symbolSearch: "\u041F\u043E\u0448\u0443\u043A, \u043D\u0430\u043F\u0440\u0438\u043A\u043B\u0430\u0434 \u0441\u0442\u0440\u0456\u043B\u043A\u0430",
3442
+ update: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
3443
+ removeFootnote: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0432\u0438\u043D\u043E\u0441\u043A\u0443",
2798
3444
  link: "\u041F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
2799
3445
  linkAddress: "\u0410\u0434\u0440\u0435\u0441\u0430 \u043F\u043E\u0441\u0438\u043B\u0430\u043D\u043D\u044F",
2800
3446
  apply: "\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438",
@@ -2841,6 +3487,11 @@ var uk = {
2841
3487
  removed: "\u0412\u0438\u0434\u0430\u043B\u0435\u043D\u043E",
2842
3488
  someone: "\u0425\u0442\u043E\u0441\u044C",
2843
3489
  copyAs: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E XLSX",
3490
+ downloadAs: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u044F\u043A",
3491
+ makeCopy: "\u0417\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
3492
+ copyOf: "\u041A\u043E\u043F\u0456\u044F",
3493
+ rename: "\u041F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
3494
+ renameFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u043F\u0435\u0440\u0435\u0439\u043C\u0435\u043D\u0443\u0432\u0430\u0442\u0438",
2844
3495
  copyFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0440\u043E\u0431\u0438\u0442\u0438 \u043A\u043E\u043F\u0456\u044E",
2845
3496
  editComment: "\u0417\u043C\u0456\u043D\u0438\u0442\u0438",
2846
3497
  delete: "\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438",
@@ -2927,12 +3578,57 @@ var uk = {
2927
3578
  untitled: "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0438",
2928
3579
  kindHints: { docx: "Word, DOCX", markdown: "MD, \u0442\u043E\u0439 \u0441\u0430\u043C\u0438\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440", sheet: "Excel, XLSX", slides: "HTML-\u0441\u043B\u0430\u0439\u0434\u0438" },
2929
3580
  newKinds: { docx: "\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442", markdown: "Markdown", sheet: "\u0422\u0430\u0431\u043B\u0438\u0446\u044F", slides: "\u041F\u0440\u0435\u0437\u0435\u043D\u0442\u0430\u0446\u0456\u044F" },
2930
- templates: { blank: "\u041F\u043E\u0440\u043E\u0436\u043D\u0456\u0439", letter: "\u041B\u0438\u0441\u0442", contract: "\u0414\u043E\u0433\u043E\u0432\u0456\u0440", notes: "\u041D\u043E\u0442\u0430\u0442\u043A\u0438 \u0437\u0443\u0441\u0442\u0440\u0456\u0447\u0456", invoice: "\u0420\u0430\u0445\u0443\u043D\u043E\u043A", report: "\u0417\u0432\u0456\u0442" }
3581
+ templates: { blank: "\u041F\u043E\u0440\u043E\u0436\u043D\u0456\u0439", letter: "\u041B\u0438\u0441\u0442", contract: "\u0414\u043E\u0433\u043E\u0432\u0456\u0440", notes: "\u041D\u043E\u0442\u0430\u0442\u043A\u0438 \u0437\u0443\u0441\u0442\u0440\u0456\u0447\u0456", invoice: "\u0420\u0430\u0445\u0443\u043D\u043E\u043A", report: "\u0417\u0432\u0456\u0442" },
3582
+ menuFile: "\u0424\u0430\u0439\u043B",
3583
+ menuEdit: "\u041F\u0440\u0430\u0432\u043A\u0430",
3584
+ menuFormat: "\u0424\u043E\u0440\u043C\u0430\u0442",
3585
+ menuTools: "\u0406\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0438",
3586
+ zoom: "\u041C\u0430\u0441\u0448\u0442\u0430\u0431",
3587
+ font: "\u0428\u0440\u0438\u0444\u0442",
3588
+ fontSize: "\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443",
3589
+ defaultFont: "\u0422\u0438\u043F\u043E\u0432\u0438\u0439",
3590
+ lineSpacing: "\u041C\u0456\u0436\u0440\u044F\u0434\u043A\u043E\u0432\u0438\u0439 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B \u0456 \u0432\u0456\u0434\u0441\u0442\u0443\u043F\u0438",
3591
+ single: "\u041E\u0434\u0438\u043D\u0430\u0440\u043D\u0438\u0439",
3592
+ double: "\u041F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439",
3593
+ spaceAfter: "\u0414\u043E\u0434\u0430\u0442\u0438 \u0432\u0456\u0434\u0441\u0442\u0443\u043F \u043F\u0456\u0441\u043B\u044F \u0430\u0431\u0437\u0430\u0446\u0443",
3594
+ noSpaceAfter: "\u041F\u0440\u0438\u0431\u0440\u0430\u0442\u0438 \u0432\u0456\u0434\u0441\u0442\u0443\u043F \u043F\u0456\u0441\u043B\u044F \u0430\u0431\u0437\u0430\u0446\u0443",
3595
+ superscript: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
3596
+ subscript: "\u041D\u0438\u0436\u043D\u0456\u0439 \u0456\u043D\u0434\u0435\u043A\u0441",
3597
+ painter: "\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438 \u0444\u043E\u0440\u043C\u0430\u0442",
3598
+ painterHint: "\u0412\u0438\u0434\u0456\u043B\u0456\u0442\u044C \u0442\u0435\u043A\u0441\u0442, \u043F\u043E\u0434\u0432\u0456\u0439\u043D\u0438\u0439 \u043A\u043B\u0456\u043A \u043B\u0438\u0448\u0430\u0454 \u0443\u0432\u0456\u043C\u043A\u043D\u0435\u043D\u0438\u043C, Esc \u0432\u0438\u043C\u0438\u043A\u0430\u0454",
3599
+ pageSetup: "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0438",
3600
+ orientation: "\u041E\u0440\u0456\u0454\u043D\u0442\u0430\u0446\u0456\u044F",
3601
+ portrait: "\u041A\u043D\u0438\u0436\u043A\u043E\u0432\u0430",
3602
+ landscape: "\u0410\u043B\u044C\u0431\u043E\u043C\u043D\u0430",
3603
+ marginsCm: "\u041F\u043E\u043B\u044F, \u0441\u043C",
3604
+ mTop: "\u0412\u0435\u0440\u0445\u043D\u0454",
3605
+ mRight: "\u041F\u0440\u0430\u0432\u0435",
3606
+ mBottom: "\u041D\u0438\u0436\u043D\u0454",
3607
+ mLeft: "\u041B\u0456\u0432\u0435",
3608
+ headerText: "\u0412\u0435\u0440\u0445\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
3609
+ footerText: "\u041D\u0438\u0436\u043D\u0456\u0439 \u043A\u043E\u043B\u043E\u043D\u0442\u0438\u0442\u0443\u043B",
3610
+ pageNumbers: "\u041D\u043E\u043C\u0435\u0440\u0438 \u0441\u0442\u043E\u0440\u0456\u043D\u043E\u043A \u0443\u043D\u0438\u0437\u0443",
3611
+ wrapInline: "\u0423 \u0440\u044F\u0434\u043A\u0443 \u0437 \u0442\u0435\u043A\u0441\u0442\u043E\u043C",
3612
+ wrapLeft: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043F\u0440\u0430\u0432\u043E\u0440\u0443\u0447",
3613
+ wrapRight: "\u0422\u0435\u043A\u0441\u0442 \u043E\u0431\u0442\u0456\u043A\u0430\u0454 \u043B\u0456\u0432\u043E\u0440\u0443\u0447",
3614
+ cellFill: "\u0417\u0430\u043B\u0438\u0432\u043A\u0430 \u043A\u043B\u0456\u0442\u0438\u043D\u043A\u0438",
3615
+ tableBorders: "\u041C\u0435\u0436\u0456 \u0442\u0430\u0431\u043B\u0438\u0446\u0456",
3616
+ findReplace: "\u0417\u043D\u0430\u0439\u0442\u0438 \u0439 \u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
3617
+ replaceWith: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u043D\u0430",
3618
+ replaceOne: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438",
3619
+ replaceAll: "\u0417\u0430\u043C\u0456\u043D\u0438\u0442\u0438 \u0432\u0441\u0456",
3620
+ matchCase: "\u0417 \u0443\u0440\u0430\u0445\u0443\u0432\u0430\u043D\u043D\u044F\u043C \u0440\u0435\u0433\u0456\u0441\u0442\u0440\u0443",
3621
+ words: "\u0421\u043B\u043E\u0432\u0430",
3622
+ print: "\u0414\u0440\u0443\u043A",
3623
+ autosavedNote: "\u0417\u0431\u0435\u0440\u0435\u0436\u0435\u043D\u043E \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u043D\u043E",
3624
+ uploadFile: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B",
3625
+ uploading: "\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",
3626
+ uploadFailed: "\u041D\u0435 \u0432\u0434\u0430\u043B\u043E\u0441\u044F \u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0444\u0430\u0439\u043B"
2931
3627
  };
2932
3628
  var texts = { en, pl, uk };
2933
3629
 
2934
3630
  export {
2935
- parse,
3631
+ parse2 as parse,
2936
3632
  attr,
2937
3633
  attrs,
2938
3634
  unescape,
@@ -2941,8 +3637,9 @@ export {
2941
3637
  inflate,
2942
3638
  entry,
2943
3639
  zip,
3640
+ mathml,
2944
3641
  readDocx,
2945
3642
  writeDocx,
2946
3643
  texts
2947
3644
  };
2948
- //# sourceMappingURL=chunk-WR3MT7KP.js.map
3645
+ //# sourceMappingURL=chunk-M4OQG3EN.js.map