@silurus/ooxml 0.85.3 → 0.86.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +39 -7
  2. package/dist/assets/render-worker-D21h5TGR.js +10 -0
  3. package/dist/assets/render-worker-Dsfekaht.js +11 -0
  4. package/dist/assets/render-worker-DxU7IrKo.js +31 -0
  5. package/dist/bounded-raw-part-cache-BfbSxRIL.js +119 -0
  6. package/dist/{canvas-viewer-mechanics-CDNMJ-Yz.js → canvas-viewer-mechanics-DN5SqWGS.js} +329 -192
  7. package/dist/{comment-ui-runtime-DAKBCpsM.js → comment-ui-runtime-DEtgcmj7.js} +5 -5
  8. package/dist/comment-ui-runtime-TLHustXJ.js +2 -0
  9. package/dist/{comment-ui-runtime-CAbpuWi_.js → comment-ui-runtime-lXwVOgjW.js} +4 -4
  10. package/dist/{comments-Brfxa3hQ.js → comments-CAn2A_Xh.js} +1 -1
  11. package/dist/delimited-text-worker-host-DcHj_JZt.js +27 -0
  12. package/dist/{document-pull-client-F3ox_VXK.js → document-pull-client-uopDjRde.js} +4477 -4431
  13. package/dist/{docx-BYvm3TWw.js → docx-wPzeF76A.js} +519 -334
  14. package/dist/docx.mjs +7 -7
  15. package/dist/docx_parser_bg.wasm +0 -0
  16. package/dist/{dom-interaction-boundary-CDGegIB5.js → dom-interaction-boundary-CswB9Tzi.js} +60 -57
  17. package/dist/{line-metrics-BGtFM-ec.js → hyperlink-BR1NCO7S.js} +954 -935
  18. package/dist/index.mjs +4 -4
  19. package/dist/{line-distribute-BsV4MVZ2.js → line-distribute-IsUGfHXm.js} +10 -10
  20. package/dist/line-metrics-CBbw80Ko.js +60 -0
  21. package/dist/node.mjs +266 -266
  22. package/dist/{pptx-BqpVTP8p.js → pptx-BxJ_RBSY.js} +173 -165
  23. package/dist/pptx.mjs +5 -5
  24. package/dist/pptx_parser_bg.wasm +0 -0
  25. package/dist/{render-DeZpRCfx.js → render-DEiun_AH.js} +1 -1
  26. package/dist/{render-worker-host-BKtXmlEF.js → render-worker-host-BEfLZvSL.js} +1 -1
  27. package/dist/{render-worker-host-CNKQ76tu.js → render-worker-host-Ba6Fchqr.js} +1 -1
  28. package/dist/{render-worker-host-CBcQXsR5.js → render-worker-host-C3xwtHnv.js} +1 -1
  29. package/dist/{resource-measurement-D41R-0Bl.js → resource-measurement-CclArDRs.js} +10 -10
  30. package/dist/{session-n2p5_jxV.js → session-BuJL_xcp.js} +87 -87
  31. package/dist/{slide-pull-client-Dwek7xW8.js → slide-pull-client-Ck8wfRT_.js} +1239 -1165
  32. package/dist/types/chart-ex.d.ts +2 -2
  33. package/dist/types/docx.d.ts +10 -11
  34. package/dist/types/index.d.ts +38 -19
  35. package/dist/types/math.d.ts +1 -1
  36. package/dist/types/node.d.ts +6 -5
  37. package/dist/types/pptx.d.ts +10 -10
  38. package/dist/types/region-map.d.ts +2 -2
  39. package/dist/types/three-d.d.ts +2 -2
  40. package/dist/types/tiff.d.ts +1 -1
  41. package/dist/types/xlsx.d.ts +34 -14
  42. package/dist/{worksheet-pull-client-C9sC36Vu.js → worksheet-pull-client-CAvuf22q.js} +72 -69
  43. package/dist/{xlsx-DSU6pV1O.js → xlsx-Bblm5r1h.js} +1752 -1592
  44. package/dist/xlsx.mjs +5 -5
  45. package/dist/xlsx_parser_bg.wasm +0 -0
  46. package/package.json +1 -1
  47. package/dist/assets/render-worker-D1O73gYW.js +0 -10
  48. package/dist/assets/render-worker-DHP0rgcW.js +0 -24
  49. package/dist/assets/render-worker-V2wWYA4O.js +0 -11
  50. package/dist/bounded-raw-part-cache-C6ro6Ezf.js +0 -254
  51. package/dist/comment-ui-runtime-DTaaZdXC.js +0 -2
  52. /package/dist/{comment-occurrence-tj54AXXB.js → comment-occurrence-CqejEuts.js} +0 -0
  53. /package/dist/{highlight-rect-DBcYVJDv.js → highlight-rect-FuUSmL3a.js} +0 -0
  54. /package/dist/{read-only-comment-decoration-Mv_SAiHy.js → read-only-comment-decoration-BTnWEeo5.js} +0 -0
  55. /package/dist/{read-only-comment-margin-Cqu-Ir0C.js → read-only-comment-margin-plStyGfE.js} +0 -0
  56. /package/dist/{source-key-BkBB3X82.js → source-key-Ktb1GRE5.js} +0 -0
@@ -1,22 +1,155 @@
1
1
  import { t as e } from "./chunk-DmhlhrBa.js";
2
- import { B as t, R as n, W as r, Zt as i, a, cn as o, et as s, pt as c, sn as l, ut as u, vt as d, z as f } from "./line-metrics-BGtFM-ec.js";
3
- import { C as p, D as m, E as h, S as g, T as _, _ as v, a as y, b, c as x, d as ee, f as te, g as ne, h as re, i as S, l as C, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as fe, w as pe, x as me, y as he } from "./canvas-viewer-mechanics-CDNMJ-Yz.js";
4
- import { a as ge, i as _e, t as ve } from "./bounded-raw-part-cache-C6ro6Ezf.js";
5
- import { c as ye, i as be, l as xe, n as Se, o as w, r as Ce, s as we, t as Te } from "./dom-interaction-boundary-CDGegIB5.js";
6
- import { A as Ee, C as T, D as E, E as De, O as D, S as Oe, T as O, _ as ke, a as Ae, b as je, c as Me, d as Ne, f as Pe, g as Fe, h as Ie, j as Le, k as Re, l as ze, m as Be, n as k, o as Ve, p as He, s as Ue, t as A, v as We, w as Ge, x as Ke, y as qe } from "./document-pull-client-F3ox_VXK.js";
7
- import { l as Je, s as Ye } from "./pixel-budget-Dgjw269h.js";
8
- import { a as j } from "./units-EJdC96r6.js";
9
- import { i as Xe, s as Ze } from "./raster-target-ojDdQizC.js";
10
- import { n as Qe } from "./renderer-module-contract-Cu-GKuPd.js";
11
- import { n as $e, t as M } from "./highlight-rect-DBcYVJDv.js";
12
- import { o as N } from "./source-key-BkBB3X82.js";
13
- import { i as et, n as P, r as tt, t as nt } from "./comments-Brfxa3hQ.js";
2
+ import { $ as t, L as n, R as r, U as i, Zt as a, _t as o, cn as s, ft as c, lt as l, r as u, sn as d, z as f } from "./hyperlink-BR1NCO7S.js";
3
+ import { C as p, D as m, M as h, N as g, O as _, S as v, T as y, _ as b, a as x, b as ee, c as S, d as te, f as ne, g as re, h as ie, i as C, l as w, m as ae, n as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as pe, w as me, x as he, y as ge } from "./canvas-viewer-mechanics-DN5SqWGS.js";
4
+ import { c as _e, d as ve, i as ye, l as be, n as xe, o as T, r as Se, s as Ce, t as we, u as Te } from "./dom-interaction-boundary-CswB9Tzi.js";
5
+ import { A as Ee, C as E, D as De, E as Oe, M as ke, O as D, S as Ae, T as je, _ as Me, a as Ne, b as Pe, c as Fe, d as Ie, f as Le, g as Re, h as ze, j as Be, k as Ve, l as He, m as Ue, n as O, o as We, p as Ge, s as Ke, t as k, v as qe, w as Je, x as Ye, y as Xe } from "./document-pull-client-uopDjRde.js";
6
+ import { l as Ze, s as Qe } from "./pixel-budget-Dgjw269h.js";
7
+ import { a as A } from "./units-EJdC96r6.js";
8
+ import { i as $e, s as et } from "./raster-target-ojDdQizC.js";
9
+ import { n as tt } from "./renderer-module-contract-Cu-GKuPd.js";
10
+ import { n as nt, t as j } from "./highlight-rect-FuUSmL3a.js";
11
+ import { t as rt } from "./bounded-raw-part-cache-BfbSxRIL.js";
12
+ import { o as M } from "./source-key-Ktb1GRE5.js";
13
+ import { i as it, n as N, r as at, t as ot } from "./comments-CAn2A_Xh.js";
14
+ //#region packages/core/src/fonts/open-type-metrics.ts
15
+ var P = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCodeAt(2) << 8 | e.charCodeAt(3)) >>> 0, st = P("ttcf"), ct = P("OTTO"), lt = P("true"), ut = P("typ1"), dt = P("head"), ft = P("hhea"), pt = P("OS/2"), mt = P("cmap"), F = [
16
+ [4352, 4607],
17
+ [11904, 12287],
18
+ [12352, 12543],
19
+ [12544, 12591],
20
+ [12592, 12687],
21
+ [12704, 12735],
22
+ [12784, 12799],
23
+ [13312, 19903],
24
+ [19968, 40959],
25
+ [40960, 42191],
26
+ [43360, 43391],
27
+ [44032, 55203],
28
+ [63744, 64255],
29
+ [131072, 205743]
30
+ ];
31
+ function I(e, t, n) {
32
+ return Number.isSafeInteger(t) && Number.isSafeInteger(n) && t >= 0 && n >= 0 && t <= e - n;
33
+ }
34
+ function ht(e, t, n) {
35
+ if (n < 16) return !1;
36
+ let r = e.getUint16(t + 2);
37
+ if (r < 16 || r > n) return !1;
38
+ let i = e.getUint16(t + 6);
39
+ if (i === 0 || i % 2 != 0) return !1;
40
+ let a = i / 2, o = t + 14, s = o + a * 2 + 2, c = s + a * 2, l = c + a * 2;
41
+ if (l + a * 2 > t + r) return !1;
42
+ let u = -1;
43
+ for (let t = 0; t < a; t++) {
44
+ let n = e.getUint16(s + t * 2), r = e.getUint16(o + t * 2);
45
+ if (n > r || n <= u) return !1;
46
+ u = r;
47
+ }
48
+ for (let n = 0; n < a; n++) {
49
+ let i = e.getUint16(s + n * 2), a = e.getUint16(o + n * 2), u = e.getInt16(c + n * 2), d = l + n * 2, f = e.getUint16(d);
50
+ for (let [n, o] of F) {
51
+ let s = Math.max(i, n), c = Math.min(a, o);
52
+ if (!(s > c)) {
53
+ if (f === 0) {
54
+ if (s < c || s + u & 65535) return !0;
55
+ continue;
56
+ }
57
+ for (let n = s; n <= c; n++) {
58
+ let a = d + f + (n - i) * 2;
59
+ if (a + 2 > t + r) break;
60
+ let o = e.getUint16(a);
61
+ if (o !== 0 && o + u & 65535) return !0;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ return !1;
67
+ }
68
+ function gt(e, t, n, r) {
69
+ if (n < 16) return !1;
70
+ let i = e.getUint32(t + 4), a = e.getUint32(t + 12);
71
+ if (i < 16 || i > n || a > (i - 16) / 12) return !1;
72
+ let o = -1;
73
+ for (let n = 0; n < a; n++) {
74
+ let i = t + 16 + n * 12, a = e.getUint32(i), s = e.getUint32(i + 4), c = e.getUint32(i + 8);
75
+ if (a > s || s > 1114111 || a <= o) return !1;
76
+ if (o = s, a > F[F.length - 1][1]) break;
77
+ for (let [e, t] of F) {
78
+ let n = Math.max(a, e), i = Math.min(s, t);
79
+ if (!(n > i)) {
80
+ if (r) {
81
+ if (c !== 0) return !0;
82
+ } else if (n < i || c + (n - a) !== 0) return !0;
83
+ }
84
+ }
85
+ }
86
+ return !1;
87
+ }
88
+ function _t(e, t) {
89
+ if (!t || t.length < 4) return !1;
90
+ let n = e.getUint16(t.offset + 2);
91
+ if (4 + n * 8 > t.length) return !1;
92
+ for (let r = 0; r < n; r++) {
93
+ let n = t.offset + 4 + r * 8, i = e.getUint16(n), a = e.getUint16(n + 2);
94
+ if (i !== 0 && !(i === 3 && (a === 1 || a === 10))) continue;
95
+ let o = e.getUint32(n + 4);
96
+ if (o > t.length - 2) continue;
97
+ let s = t.offset + o, c = t.length - o, l = e.getUint16(s);
98
+ if (l === 4 && ht(e, s, c) || l === 12 && gt(e, s, c, !1) || l === 13 && gt(e, s, c, !0)) return !0;
99
+ }
100
+ return !1;
101
+ }
102
+ function vt(e, t) {
103
+ if (t !== void 0 && (!Number.isSafeInteger(t) || t < 0) || e.byteLength < 12) return null;
104
+ let n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = 0;
105
+ if (n.getUint32(0) === st) {
106
+ if (t === void 0 || e.byteLength < 12) return null;
107
+ let i = n.getUint32(8);
108
+ if (t >= i || !I(e.byteLength, 12, i * 4)) return null;
109
+ r = n.getUint32(12 + t * 4);
110
+ } else if (t !== void 0 && t !== 0) return null;
111
+ if (!I(e.byteLength, r, 12)) return null;
112
+ let i = n.getUint32(r);
113
+ if (i !== 65536 && i !== ct && i !== lt && i !== ut) return null;
114
+ let a = n.getUint16(r + 4);
115
+ if (!I(e.byteLength, r + 12, a * 16)) return null;
116
+ let o = /* @__PURE__ */ new Map();
117
+ for (let t = 0; t < a; t++) {
118
+ let i = r + 12 + t * 16, a = n.getUint32(i), s = n.getUint32(i + 8), c = n.getUint32(i + 12);
119
+ if (o.has(a) || !I(e.byteLength, s, c)) return null;
120
+ o.set(a, {
121
+ offset: s,
122
+ length: c
123
+ });
124
+ }
125
+ let s = o.get(dt), c = o.get(ft);
126
+ if (!s || s.length < 20 || !c || c.length < 10) return null;
127
+ let l = n.getUint16(s.offset + 18);
128
+ if (l < 16 || l > 16384) return null;
129
+ let u = o.get(pt), d = u !== void 0 && u.length >= 78;
130
+ return Object.freeze({
131
+ unitsPerEm: l,
132
+ hheaAscent: n.getInt16(c.offset + 4),
133
+ hheaDescent: n.getInt16(c.offset + 6),
134
+ hheaLineGap: n.getInt16(c.offset + 8),
135
+ hasEastAsianCmap: _t(n, o.get(mt)),
136
+ ...d ? {
137
+ typoAscent: n.getInt16(u.offset + 68),
138
+ typoDescent: n.getInt16(u.offset + 70),
139
+ typoLineGap: n.getInt16(u.offset + 72),
140
+ winAscent: n.getUint16(u.offset + 74),
141
+ winDescent: n.getUint16(u.offset + 76),
142
+ useTypoMetrics: (n.getUint16(u.offset + 62) & 128) != 0
143
+ } : {}
144
+ });
145
+ }
146
+ //#endregion
14
147
  //#region packages/docx/src/worker.ts?worker&inline
15
- var rt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};const J=67108864;var De=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>{let e=this.executeArchive(e=>e.document_cursor_resource_usage?.());return e?I(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Y(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new De(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Y(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", it = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", rt], { type: "text/javascript;charset=utf-8" });
16
- function at(e) {
148
+ var yt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};const J=67108864;var De=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>{let e=this.executeArchive(e=>e.document_cursor_resource_usage?.());return e?I(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Y(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new De(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Y(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", bt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", yt], { type: "text/javascript;charset=utf-8" });
149
+ function xt(e) {
17
150
  let t;
18
151
  try {
19
- if (t = it && (self.URL || self.webkitURL).createObjectURL(it), !t) throw "";
152
+ if (t = bt && (self.URL || self.webkitURL).createObjectURL(bt), !t) throw "";
20
153
  let n = new Worker(t, {
21
154
  type: "module",
22
155
  name: e?.name
@@ -25,7 +158,7 @@ function at(e) {
25
158
  (self.URL || self.webkitURL).revokeObjectURL(t);
26
159
  }), n;
27
160
  } catch {
28
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(rt), {
161
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(yt), {
29
162
  type: "module",
30
163
  name: e?.name
31
164
  });
@@ -33,46 +166,97 @@ function at(e) {
33
166
  }
34
167
  //#endregion
35
168
  //#region packages/docx/src/wasm/docx_parser_bg.wasm?url
36
- var ot = new URL("docx_parser_bg.wasm", import.meta.url).href;
169
+ var St = new URL("docx_parser_bg.wasm", import.meta.url).href;
37
170
  //#endregion
38
171
  //#region packages/docx/src/bookmark-nav.ts
39
- function st(e) {
172
+ function Ct(e) {
40
173
  let t = /* @__PURE__ */ new Map();
41
174
  for (let n of e.pages) for (let e of n.bookmarkStarts) e.name !== "" && !t.has(e.name) && t.set(e.name, n.pageIndex);
42
175
  return t;
43
176
  }
44
177
  //#endregion
45
178
  //#region packages/docx/src/embedded-fonts.ts
46
- async function ct(e, t) {
179
+ async function wt(e, t) {
47
180
  let n = e.embeddedFonts;
48
- if (!n || n.length === 0) return [];
49
- let r = (await Promise.all(n.map(async (e) => {
181
+ if (!n || n.length === 0) return {
182
+ faces: [],
183
+ metrics: {}
184
+ };
185
+ let r = [], i = /* @__PURE__ */ new Set();
186
+ for (let e of n) {
187
+ let t = Tt(e.style) === "bold" ? 700 : 400, n = Et(e.style), a = `${ke(e.fontName)}:${t}:${n}`;
188
+ i.has(a) || (i.add(a), r.push(e));
189
+ }
190
+ let a = (await Promise.all(r.map(async (e) => {
50
191
  try {
51
- let n = await t(e.partPath);
52
- return {
192
+ let n = await t(e.partPath), r = e.partPath.toLowerCase().endsWith(".odttf"), i = {
53
193
  family: e.fontName,
54
194
  bytes: n,
55
- odttf: e.partPath.toLowerCase().endsWith(".odttf"),
195
+ odttf: r,
56
196
  fontKey: e.fontKey,
57
- weight: lt(e.style),
58
- style: ut(e.style)
197
+ weight: Tt(e.style),
198
+ style: Et(e.style)
199
+ };
200
+ if (!be(n)) return {
201
+ face: i,
202
+ metric: null
203
+ };
204
+ let a = i, o = null;
205
+ try {
206
+ let t = r ? _e(n, e.fontKey ?? "") : n;
207
+ a = {
208
+ ...i,
209
+ bytes: t,
210
+ odttf: !1,
211
+ fontKey: ""
212
+ };
213
+ let s = vt(t), c = s?.hasEastAsianCmap ? je(s) : 0;
214
+ c > 0 && (o = Object.freeze({
215
+ family: e.fontName,
216
+ requestedFamily: e.fontName,
217
+ weight: a.weight === "bold" ? 700 : 400,
218
+ style: a.style,
219
+ sourceIdentity: `embedded:${e.partPath}`,
220
+ synthesized: !1,
221
+ eastAsianLineHeightRatio: c
222
+ }));
223
+ } catch {}
224
+ return {
225
+ face: a,
226
+ metric: o
59
227
  };
60
228
  } catch {
61
229
  return null;
62
230
  }
63
231
  }))).filter((e) => e !== null);
64
- return r.length === 0 ? [] : ye(r);
232
+ if (a.length === 0) return {
233
+ faces: [],
234
+ metrics: {}
235
+ };
236
+ let o = await Te(a.map((e) => e.face)), s = new Set(o.map((e) => {
237
+ let t = e.family.trim().replace(/^(['"])(.*)\1$/, "$2"), n = e.weight === "bold" ? 700 : Number(e.weight) || 400, r = e.style === "italic" ? "italic" : "normal";
238
+ return `${ke(t)}:${n}:${r}`;
239
+ })), c = {};
240
+ for (let e of a) {
241
+ if (!e.metric) continue;
242
+ let t = ke(e.face.family), n = e.face.weight === "bold" ? 700 : 400, r = e.face.style, i = `${t}:${n}:${r}`;
243
+ s.has(i) && (c[n === 400 && r === "normal" ? t : i] = e.metric);
244
+ }
245
+ return {
246
+ faces: o,
247
+ metrics: Object.freeze(c)
248
+ };
65
249
  }
66
- function lt(e) {
250
+ function Tt(e) {
67
251
  return e === "bold" || e === "boldItalic" ? "bold" : "normal";
68
252
  }
69
- function ut(e) {
253
+ function Et(e) {
70
254
  return e === "italic" || e === "boldItalic" ? "italic" : "normal";
71
255
  }
72
256
  //#endregion
73
257
  //#region packages/docx/src/element-context.ts
74
- var F = de, dt = 16384;
75
- function ft(e, t) {
258
+ var L = fe, Dt = 16384;
259
+ function Ot(e, t) {
76
260
  let n = Math.min(e.length, t);
77
261
  if (n > 0 && n < e.length) {
78
262
  let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
@@ -80,7 +264,7 @@ function ft(e, t) {
80
264
  }
81
265
  return e.slice(0, n);
82
266
  }
83
- function pt(e, t) {
267
+ function kt(e, t) {
84
268
  let n = [], r = 0, i = !1;
85
269
  for (let a of e) {
86
270
  if (a.length === 0) continue;
@@ -91,7 +275,7 @@ function pt(e, t) {
91
275
  }
92
276
  n.push("\n"), r++;
93
277
  }
94
- let e = ft(a, Math.max(0, t - r));
278
+ let e = Ot(a, Math.max(0, t - r));
95
279
  if (n.push(e), r += e.length, e.length < a.length) {
96
280
  i = !0;
97
281
  break;
@@ -103,7 +287,7 @@ function pt(e, t) {
103
287
  truncated: i
104
288
  };
105
289
  }
106
- function* I(e) {
290
+ function* R(e) {
107
291
  if (e.kind === "paragraph") {
108
292
  for (let t of e.lines) {
109
293
  let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
@@ -112,42 +296,42 @@ function* I(e) {
112
296
  return;
113
297
  }
114
298
  if (e.kind === "table") {
115
- for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* I(t.layout);
299
+ for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* R(t.layout);
116
300
  return;
117
301
  }
118
- if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* I(t);
302
+ if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* R(t);
119
303
  }
120
- function* mt(e) {
304
+ function* At(e) {
121
305
  for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
122
- for (let t of e.textBoxes) yield* I(t);
306
+ for (let t of e.textBoxes) yield* R(t);
123
307
  }
124
- function ht(e) {
125
- let t = e ?? dt;
308
+ function jt(e) {
309
+ let t = e ?? Dt;
126
310
  if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
127
- return Math.min(F, Math.floor(t));
311
+ return Math.min(L, Math.floor(t));
128
312
  }
129
- function gt(e) {
313
+ function Mt(e) {
130
314
  return {
131
315
  story: e.story,
132
316
  storyInstance: e.storyInstance,
133
317
  path: [...e.path]
134
318
  };
135
319
  }
136
- function _t(e) {
320
+ function Nt(e) {
137
321
  return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
138
322
  }
139
- function vt(e) {
140
- let t = _t(e), n = [
141
- T(e.pointToPage, t),
142
- T(e.pointToPage, {
323
+ function Pt(e) {
324
+ let t = Nt(e), n = [
325
+ E(e.pointToPage, t),
326
+ E(e.pointToPage, {
143
327
  xPt: t.xPt + t.widthPt,
144
328
  yPt: t.yPt
145
329
  }),
146
- T(e.pointToPage, {
330
+ E(e.pointToPage, {
147
331
  xPt: t.xPt,
148
332
  yPt: t.yPt + t.heightPt
149
333
  }),
150
- T(e.pointToPage, {
334
+ E(e.pointToPage, {
151
335
  xPt: t.xPt + t.widthPt,
152
336
  yPt: t.yPt + t.heightPt
153
337
  })
@@ -159,10 +343,10 @@ function vt(e) {
159
343
  heightPt: o - i
160
344
  };
161
345
  }
162
- function L(e, t) {
346
+ function z(e, t) {
163
347
  return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
164
348
  }
165
- function yt(e, t) {
349
+ function Ft(e, t) {
166
350
  let n = !1;
167
351
  for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
168
352
  let a = t[r], o = t[i];
@@ -170,35 +354,35 @@ function yt(e, t) {
170
354
  }
171
355
  return n;
172
356
  }
173
- function bt(e, t) {
174
- return L(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? L(e.clip.rect, t) : yt(t, e.clip.points) : !0 : !1;
357
+ function It(e, t) {
358
+ return z(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? z(e.clip.rect, t) : Ft(t, e.clip.points) : !0 : !1;
175
359
  }
176
- function xt(e, t, n) {
360
+ function Lt(e, t, n) {
177
361
  for (let n of e.clips) {
178
- let e = Oe(n.pointToPage, t);
179
- if (!e || !L(n.bounds, e)) return !1;
362
+ let e = Ae(n.pointToPage, t);
363
+ if (!e || !z(n.bounds, e)) return !1;
180
364
  }
181
- return "drawing" in e ? bt(e.drawing, n) : L(e.placement.bounds, n);
365
+ return "drawing" in e ? It(e.drawing, n) : z(e.placement.bounds, n);
182
366
  }
183
- function R(e, t) {
367
+ function B(e, t) {
184
368
  return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
185
369
  }
186
- function St(e) {
187
- return R(e, "chart") ? "chart" : e.commands.some((e) => e.kind === "drawingml-shape" || e.kind === "drawingml-image-fill" || e.kind === "fill-rect" || e.kind === "stroke-rect" || e.kind === "text" || e.kind === "watermark-text") ? "shape" : R(e, "image") ? "image" : null;
370
+ function Rt(e) {
371
+ return B(e, "chart") ? "chart" : e.commands.some((e) => e.kind === "drawingml-shape" || e.kind === "drawingml-image-fill" || e.kind === "fill-rect" || e.kind === "stroke-rect" || e.kind === "text" || e.kind === "watermark-text") ? "shape" : B(e, "image") ? "image" : null;
188
372
  }
189
- function Ct(e, t, n, r, i, a) {
190
- let o = "drawing" in e ? St(e.drawing) : e.placement.resourceKind;
373
+ function zt(e, t, n, r, i, a) {
374
+ let o = "drawing" in e ? Rt(e.drawing) : e.placement.resourceKind;
191
375
  if (!o) return null;
192
376
  let s, c = !1, l, u;
193
377
  if (o === "chart") {
194
- let t = "drawing" in e ? R(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = ee(n.model, a);
378
+ let t = "drawing" in e ? B(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = te(n.model, a);
195
379
  s = r.text, c = r.truncated, u = n.model.series.length;
196
380
  } else if (o === "image") {
197
- let t = "drawing" in e ? R(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
381
+ let t = "drawing" in e ? B(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
198
382
  if (!n) throw Error(`Unknown image paint resource: ${t}`);
199
383
  l = n.mimeType;
200
384
  } else {
201
- let t = pt(mt(e), a);
385
+ let t = kt(At(e), a);
202
386
  s = t.text, c = t.truncated;
203
387
  }
204
388
  return {
@@ -208,8 +392,8 @@ function Ct(e, t, n, r, i, a) {
208
392
  elementIndex: n,
209
393
  elementType: o,
210
394
  point: { ...r },
211
- bounds: vt(e),
212
- source: gt("drawing" in e ? e.drawing.source : e.source),
395
+ bounds: Pt(e),
396
+ source: Mt("drawing" in e ? e.drawing.source : e.source),
213
397
  ...s === void 0 ? {} : { text: s },
214
398
  ...l === void 0 ? {} : { mimeType: l },
215
399
  ...u === void 0 ? {} : { seriesCount: u },
@@ -219,26 +403,26 @@ function Ct(e, t, n, r, i, a) {
219
403
  maxTextCharacters: a
220
404
  };
221
405
  }
222
- function wt(e, t, n, r, i = {}) {
406
+ function Bt(e, t, n, r, i = {}) {
223
407
  if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
224
- let a = ht(i.maxTextCharacters), o = je(e, t);
408
+ let a = jt(i.maxTextCharacters), o = Pe(e, t);
225
409
  for (let e = o.length - 1; e >= 0; e--) {
226
- let i = o[e], s = Oe(i.pointToPage, n);
227
- if (!s || !xt(i, n, s)) continue;
228
- let c = Ct(i, t, e, n, r, a);
410
+ let i = o[e], s = Ae(i.pointToPage, n);
411
+ if (!s || !Lt(i, n, s)) continue;
412
+ let c = zt(i, t, e, n, r, a);
229
413
  if (c) return c;
230
414
  }
231
415
  return null;
232
416
  }
233
- function Tt(e, t, n, r) {
234
- return wt(Ge(e, {
417
+ function Vt(e, t, n, r) {
418
+ return Bt(Je(e, {
235
419
  currentDate: r.currentDate,
236
420
  defaultCurrentDateMs: r.defaultCurrentDateMs,
237
421
  showTrackedChanges: r.showTrackedChanges
238
- }, t).layout, t, n, Re(e), r);
422
+ }, t).layout, t, n, Ee(e), r);
239
423
  }
240
- function Et(e, t) {
241
- let n = ht(t), r = e.text === void 0 ? void 0 : ft(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
424
+ function Ht(e, t) {
425
+ let n = jt(t), r = e.text === void 0 ? void 0 : Ot(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
242
426
  return {
243
427
  ...structuredClone(e),
244
428
  ...r === void 0 ? {} : { text: r },
@@ -250,20 +434,20 @@ function Et(e, t) {
250
434
  }
251
435
  //#endregion
252
436
  //#region packages/docx/src/revisions.ts
253
- function z(e) {
254
- let t = et(e.id);
437
+ function Ut(e) {
438
+ let t = it(e.id);
255
439
  return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
256
440
  }
257
- function B(e) {
441
+ function V(e) {
258
442
  return Object.freeze({
259
443
  ...e,
260
444
  path: Object.freeze([...e.path])
261
445
  });
262
446
  }
263
- function Dt(e, t) {
447
+ function Wt(e, t) {
264
448
  return e !== void 0 && e.story === t.story && e.storyInstance === t.storyInstance && e.path.length === t.path.length && e.path.every((e, n) => e === t.path[n]);
265
449
  }
266
- function V(e, t) {
450
+ function Gt(e, t) {
267
451
  let n = 0, r = e.length;
268
452
  for (; n < r;) {
269
453
  let i = n + Math.floor((r - n) / 2);
@@ -271,22 +455,22 @@ function V(e, t) {
271
455
  }
272
456
  return n;
273
457
  }
274
- function Ot(e, t) {
458
+ function Kt(e, t) {
275
459
  let n = Array(e.length), r;
276
460
  for (let i = e.length - 1; i >= 0; --i) {
277
461
  n[i] = r;
278
- let a = e[i], o = t.get(N(a.source))?.[0];
462
+ let a = e[i], o = t.get(M(a.source))?.[0];
279
463
  o !== void 0 && (r = Object.freeze({
280
- source: B(a.source),
464
+ source: V(a.source),
281
465
  sourceRunIndex: o
282
466
  }));
283
467
  }
284
468
  let i = Array(e.length), a;
285
469
  for (let n = 0; n < e.length; n += 1) {
286
470
  i[n] = a;
287
- let r = e[n], o = t.get(N(r.source))?.at(-1);
471
+ let r = e[n], o = t.get(M(r.source))?.at(-1);
288
472
  o !== void 0 && (a = Object.freeze({
289
- source: B(r.source),
473
+ source: V(r.source),
290
474
  sourceRunIndex: o
291
475
  }));
292
476
  }
@@ -295,17 +479,17 @@ function Ot(e, t) {
295
479
  preceding: i
296
480
  };
297
481
  }
298
- function kt(e, t, n, r, i, a) {
299
- let o = r[e], s = i.get(N(o.source)) ?? [], c = s[V(s, n)], l = s[V(s, t) - 1], u = c ?? l;
482
+ function qt(e, t, n, r, i, a) {
483
+ let o = r[e], s = i.get(M(o.source)) ?? [], c = s[Gt(s, n)], l = s[Gt(s, t) - 1], u = c ?? l;
300
484
  return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
301
- source: B(o.source),
485
+ source: V(o.source),
302
486
  sourceRunIndex: u
303
487
  });
304
488
  }
305
- function At(e, t, n = /* @__PURE__ */ new Map()) {
489
+ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
306
490
  let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
307
491
  e.forEach((e, t) => {
308
- let n = z(e);
492
+ let n = Ut(e);
309
493
  n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
310
494
  });
311
495
  let a = t.blocks.sources.flatMap((e) => {
@@ -315,11 +499,11 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
315
499
  source: e,
316
500
  runs: n.runs
317
501
  }] : [];
318
- }), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Ot(a, o), c = [];
502
+ }), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Kt(a, o), c = [];
319
503
  for (let [e, t] of a.entries()) {
320
504
  let n = 0;
321
505
  for (; n < t.runs.length;) {
322
- let i = t.runs[n], l = i.revision?.kind ? z({
506
+ let i = t.runs[n], l = i.revision?.kind ? Ut({
323
507
  kind: i.revision.kind,
324
508
  id: i.revision.id
325
509
  }) : void 0, u = l === void 0 ? void 0 : r.get(l);
@@ -330,16 +514,16 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
330
514
  let d = n;
331
515
  for (n += 1; n < t.runs.length;) {
332
516
  let e = t.runs[n].revision;
333
- if (!e?.kind || z({
517
+ if (!e?.kind || Ut({
334
518
  kind: e.kind,
335
519
  id: e.id
336
520
  }) !== l) break;
337
521
  n += 1;
338
522
  }
339
- let f = n, p = o.get(N(t.source)) ?? [], m = (p[V(p, d)] ?? f) < f ? void 0 : kt(e, d, f, a, o, s);
523
+ let f = n, p = o.get(M(t.source)) ?? [], m = (p[Gt(p, d)] ?? f) < f ? void 0 : qt(e, d, f, a, o, s);
340
524
  c.push(Object.freeze({
341
525
  revisionIndex: u,
342
- source: B(t.source),
526
+ source: V(t.source),
343
527
  startRunIndex: d,
344
528
  endRunIndex: f,
345
529
  ...m === void 0 ? {} : { geometryFallback: m }
@@ -348,26 +532,26 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
348
532
  }
349
533
  return c;
350
534
  }
351
- function jt(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
535
+ function Yt(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
352
536
  if ((e?.length ?? 0) === 0) return [];
353
- let i = At(e ?? [], t, n), a = r.completedSourceKeys;
537
+ let i = Jt(e ?? [], t, n), a = r.completedSourceKeys;
354
538
  return a === void 0 ? i : i.filter((e) => {
355
- let t = n.get(N(e.source));
356
- return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(N(e.source));
539
+ let t = n.get(M(e.source));
540
+ return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(M(e.source));
357
541
  });
358
542
  }
359
- function Mt(e, t) {
360
- let n = t.filter((t) => t.sourceRunIndex !== void 0 && Dt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
543
+ function Xt(e, t) {
544
+ let n = t.filter((t) => t.sourceRunIndex !== void 0 && Wt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
361
545
  if (n.length > 0) return n;
362
546
  let r = e.geometryFallback;
363
- return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && Dt(e.source, r.source));
547
+ return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && Wt(e.source, r.source));
364
548
  }
365
549
  //#endregion
366
550
  //#region packages/docx/src/layout/progressive.ts
367
- var Nt = 12;
368
- async function Pt(e, t, n, r = {}) {
551
+ var Zt = 12;
552
+ async function Qt(e, t, n, r = {}) {
369
553
  let { onPreview: i, scheduler: a } = r;
370
- return Fe(ke(e, t, n, i && e.sequence.length > Nt ? { onPages: (e, t) => {
554
+ return Re(Me(e, t, n, i && e.sequence.length > Zt ? { onPages: (e, t) => {
371
555
  i(Object.freeze({
372
556
  layout: e,
373
557
  exact: !1,
@@ -388,7 +572,7 @@ function U(e, t) {
388
572
  } catch {}
389
573
  }
390
574
  }
391
- function Ft(e, t, n, r) {
575
+ function $t(e, t, n, r) {
392
576
  let i = H.get(e);
393
577
  i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
394
578
  let a = Object.freeze({
@@ -409,30 +593,30 @@ function Ft(e, t, n, r) {
409
593
  }
410
594
  //#endregion
411
595
  //#region packages/docx/src/document-layout-view.ts
412
- var W = /* @__PURE__ */ new WeakMap(), It = /* @__PURE__ */ new WeakMap(), Lt = Symbol("docxLayoutViewRequester");
596
+ var W = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap(), tn = Symbol("docxLayoutViewRequester");
413
597
  function G(e) {
414
- let t = E(e), n = t.activeLayoutOptions;
598
+ let t = D(e), n = t.activeLayoutOptions;
415
599
  return {
416
600
  showTrackedChanges: n?.showTrackedChanges === !0,
417
601
  currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
418
602
  };
419
603
  }
420
604
  async function K(e, t, n) {
421
- let r = E(e), i = O(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
605
+ let r = D(e), i = Oe(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
422
606
  showTrackedChanges: i.showTrackedChanges === !0,
423
607
  currentDate: i.currentDateMs
424
608
  }), o = {
425
609
  showTrackedChanges: a.showTrackedChanges,
426
610
  currentDate: a.currentDate,
427
- [Lt]: n
611
+ [tn]: n
428
612
  };
429
613
  await e.setLayoutView(o);
430
614
  let s = G(e);
431
615
  return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
432
616
  }
433
- function Rt(e, t) {
434
- let n = Object.freeze({ ...G(e) }), r = (It.get(e) ?? 0) + 1;
435
- It.set(e, r);
617
+ function nn(e, t) {
618
+ let n = Object.freeze({ ...G(e) }), r = (en.get(e) ?? 0) + 1;
619
+ en.set(e, r);
436
620
  let i = Object.freeze({
437
621
  view: n,
438
622
  generation: r,
@@ -446,7 +630,7 @@ function Rt(e, t) {
446
630
  } catch {}
447
631
  }
448
632
  }
449
- function zt(e, t, n) {
633
+ function rn(e, t, n) {
450
634
  let r = W.get(e);
451
635
  r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
452
636
  let i = Object.freeze({
@@ -459,10 +643,10 @@ function zt(e, t, n) {
459
643
  }
460
644
  //#endregion
461
645
  //#region packages/docx/src/document.ts
462
- function Bt(e, t) {
646
+ function an(e, t) {
463
647
  return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
464
648
  }
465
- function Vt() {
649
+ function on() {
466
650
  let e, t;
467
651
  return {
468
652
  promise: new Promise((n, r) => {
@@ -472,12 +656,12 @@ function Vt() {
472
656
  reject: t
473
657
  };
474
658
  }
475
- var Ht = Object.freeze([]), Ut = Object.freeze([]), Wt = Object.freeze({
659
+ var sn = Object.freeze([]), cn = Object.freeze([]), ln = Object.freeze({
476
660
  comments: Object.freeze([]),
477
661
  revisions: Object.freeze([])
478
662
  });
479
663
  function q(e, t) {
480
- return Ee({
664
+ return Be({
481
665
  comments: e,
482
666
  revisions: t
483
667
  }, "DOCX review metadata");
@@ -487,9 +671,9 @@ var J = class e {
487
671
  _document = null;
488
672
  _source = null;
489
673
  _meta = null;
490
- _review = Wt;
491
- _layoutLifecycle = new be();
492
- _layoutObservers = new Ce();
674
+ _review = ln;
675
+ _layoutLifecycle = new ye();
676
+ _layoutObservers = new Se();
493
677
  _layoutCompletion = null;
494
678
  _layoutAbort = null;
495
679
  _bookmarkPages = null;
@@ -508,20 +692,19 @@ var J = class e {
508
692
  _tiff;
509
693
  _worker;
510
694
  _bridge;
511
- _rawParts = new ve({
695
+ _rawParts = new rt({
512
696
  maxEntries: 64,
513
- maxBytes: i
697
+ maxBytes: a
514
698
  });
515
699
  _embeddedFontFaces = [];
516
700
  _googleFontFaces = [];
517
- _localMetricFontFaces = [];
518
701
  _fetchImage = (e, t) => this.getImage(e, t);
519
- constructor(e, t, n, i) {
520
- this._worker = e, this._mode = t, De(this, n), this._bridge = new pe(this._worker, {
702
+ constructor(e, t, n, r) {
703
+ this._worker = e, this._mode = t, De(this, n), this._bridge = new me(this._worker, {
521
704
  correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
522
705
  onUnsolicited: (e) => this._onWorkerLayoutPush(e),
523
706
  toError: (e) => {
524
- if (!("protocol" in e || e.type !== "error")) return Object.assign(r(e), {
707
+ if (!("protocol" in e || e.type !== "error")) return Object.assign(i(e), {
525
708
  ...e.reason === void 0 ? {} : { reason: e.reason },
526
709
  ...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
527
710
  ...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
@@ -529,80 +712,82 @@ var J = class e {
529
712
  });
530
713
  }
531
714
  });
532
- let a = new URL(i ?? ot, location.href).href;
715
+ let a = new URL(r ?? St, location.href).href;
533
716
  this._bridge.post({
534
717
  type: "init",
535
718
  wasmUrl: a
536
719
  });
537
720
  }
538
- static async load(r, i = {}) {
539
- let a = t(i), o = Date.now(), s = i.mode ?? "main", c = new n({
721
+ static async load(t, r = {}) {
722
+ let i = f(r), a = Date.now(), o = r.mode ?? "main", s = new n({
540
723
  enabled: !0,
541
724
  format: "docx",
542
- mode: s,
543
- policy: a.policy,
544
- onMetrics: a.onResourceMetrics,
545
- emitToConsole: a.debug
725
+ mode: o,
726
+ policy: i.policy,
727
+ onMetrics: i.onResourceMetrics,
728
+ emitToConsole: i.debug
546
729
  });
547
730
  try {
548
- if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
549
- let t;
550
- if (typeof r == "string") {
551
- let e = await fetch(r);
731
+ if (o === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
732
+ let n;
733
+ if (typeof t == "string") {
734
+ let e = await fetch(t);
552
735
  if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
553
- t = await e.arrayBuffer();
554
- } else t = r;
555
- t = m(await h(t, i.password)), c.setSourceBytes(t.byteLength), c.checkpoint("container ready");
556
- let n = s === "worker" ? (await import("./render-worker-host-CBcQXsR5.js")).createRenderWorker() : new at(), l = s === "worker" ? Qe(i) : void 0, u = s === "worker" && !!i.progressiveLayout, d;
736
+ n = await e.arrayBuffer();
737
+ } else n = t;
738
+ n = g(await h(n, r.password)), s.setSourceBytes(n.byteLength), s.checkpoint("container ready");
739
+ let c = o === "worker" ? (await import("./render-worker-host-C3xwtHnv.js")).createRenderWorker() : new xt(), l = o === "worker" ? tt(r) : void 0, u = o === "worker" && !!r.progressiveLayout, d;
557
740
  try {
558
- d = new e(n, s, o, i.wasmUrl), d._metrics = c;
559
- let r = E(d), f = O(i.currentDate, r.defaultCurrentDateMs, i.showTrackedChanges === !0);
560
- if (r.activeLayoutOptions = f, await d._parse(t, a.policy, s === "worker" ? !!i.useGoogleFonts : !1, i.workerTimeoutMs, (e) => c.observeUsage(e), l, u ? {
561
- onPartial: i.onLayoutPartial,
562
- onComplete: i.onLayoutComplete,
563
- onProgress: i.onLayoutProgress,
741
+ d = new e(c, o, a, r.wasmUrl), d._metrics = s;
742
+ let t = D(d), f = Oe(r.currentDate, t.defaultCurrentDateMs, r.showTrackedChanges === !0);
743
+ t.activeLayoutOptions = f, await d._parse(n, i.policy, o === "worker" ? !!r.useGoogleFonts : !1, r.workerTimeoutMs, (e) => s.observeUsage(e), l, u ? {
744
+ onPartial: r.onLayoutPartial,
745
+ onComplete: r.onLayoutComplete,
746
+ onProgress: r.onLayoutProgress,
564
747
  layoutOptions: f,
565
748
  abort: new AbortController(),
566
- firstPublication: Vt(),
749
+ firstPublication: on(),
567
750
  published: !1,
568
751
  settled: !1
569
- } : void 0), s === "worker" && d._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), i.math && d._mode === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), i.threeD && d._mode === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), d._threeD = d._mode === "worker" ? void 0 : i.threeD, i.regionMap && d._mode === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), d._regionMap = d._mode === "worker" ? void 0 : i.regionMap, i.chartEx && d._mode === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), d._chartEx = d._mode === "worker" ? void 0 : i.chartEx, i.tiff && d._mode === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), d._tiff = d._mode === "worker" ? void 0 : i.tiff, d._mode === "main" && i.useGoogleFonts && d._document && (d._googleFontFaces = await _e(He(d._document), Pe)), d._mode === "main" && d._document?.embeddedFonts?.length) {
570
- let e = d;
571
- d._embeddedFontFaces = await ct(d._document, (t) => e.getFontBytes(t));
572
- }
752
+ } : void 0), o === "worker" && d._mode === "main" && (s.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), r.math && d._mode === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), r.threeD && d._mode === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), d._threeD = d._mode === "worker" ? void 0 : r.threeD, r.regionMap && d._mode === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), d._regionMap = d._mode === "worker" ? void 0 : r.regionMap, r.chartEx && d._mode === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), d._chartEx = d._mode === "worker" ? void 0 : r.chartEx, r.tiff && d._mode === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), d._tiff = d._mode === "worker" ? void 0 : r.tiff, d._mode === "main" && r.useGoogleFonts && d._document && (d._googleFontFaces = await m(Le(d._document), Ie));
573
753
  let p;
574
- d._mode === "main" && d._document && (p = await Ne(d._document), d._localMetricFontFaces = p.faces);
575
- let m;
576
- if (d._mode === "main" && i.math && d._document && Ve(d._document) && (m = await Ue(d._document, i.math)), d._mode === "main" && d._document && d._source) {
577
- let e = d, t = E(d);
578
- t.services = ze(d._source, {
579
- localMetrics: p?.metrics,
580
- useGoogleFonts: !!i.useGoogleFonts,
754
+ if (d._mode === "main" && d._document?.embeddedFonts?.length) {
755
+ let e = d, t = await wt(d._document, (t) => e.getFontBytes(t));
756
+ d._embeddedFontFaces = t.faces, p = t.metrics;
757
+ }
758
+ let h;
759
+ if (d._mode === "main" && r.math && d._document && We(d._document) && (h = await Ke(d._document, r.math)), d._mode === "main" && d._document && d._source) {
760
+ let e = d, t = D(d);
761
+ t.services = He(d._source, {
762
+ fontMetrics: p,
763
+ measureResolvedFontMetrics: !0,
764
+ resolvedFontMetricCandidates: Ge(d._document, d._source.fontFamilyCharsets),
765
+ useGoogleFonts: !!r.useGoogleFonts,
581
766
  embeddedFaces: d._embeddedFontFaces,
582
767
  googleFaces: d._googleFontFaces,
583
- mathResources: m?.records,
584
- mathDrawables: m?.drawables
768
+ mathResources: h?.records,
769
+ mathDrawables: h?.drawables
585
770
  });
586
- let n = t.services, r = Ae(d._source, n, t.defaultCurrentDateMs), a = d._source.fatalParse === null, o = t.activeLayoutOptions;
771
+ let n = t.services, i = Ne(d._source, n, t.defaultCurrentDateMs), a = d._source.fatalParse === null, o = t.activeLayoutOptions;
587
772
  if (!o) throw Error("Active layout view was not recorded at load");
588
- let s = { onProgress: i.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", i.onLayoutProgress, { committedUnits: t }) : void 0 };
589
- if (a && i.progressiveLayout) {
590
- let e = r.layoutVariants, t = d, a = new AbortController();
773
+ let s = { onProgress: r.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", r.onLayoutProgress, { committedUnits: t }) : void 0 };
774
+ if (a && r.progressiveLayout) {
775
+ let e = i.layoutVariants, t = d, a = new AbortController();
591
776
  t._layoutAbort = a;
592
- let c = Vt(), l = null, u = !0;
593
- t._layoutCompletion = Pt(d._source.bodyLayoutInput, n, o, {
777
+ let c = on(), l = null, u = !0;
778
+ t._layoutCompletion = Qt(d._source.bodyLayoutInput, n, o, {
594
779
  scheduler: {
595
780
  ...s,
596
781
  signal: a.signal
597
782
  },
598
783
  onPreview: (n) => {
599
784
  if (!u) return;
600
- let r = l === null, a = t._replaceMainLayoutPublication(e, o, l, n.layout);
785
+ let i = l === null, a = t._replaceMainLayoutPublication(e, o, l, n.layout);
601
786
  if (a === null) {
602
787
  u = !1;
603
788
  return;
604
789
  }
605
- if (l = a, r) t._layoutLifecycle.begin(), U(t, {
790
+ if (l = a, i) t._layoutLifecycle.begin(), U(t, {
606
791
  pageCount: n.layout.pages.length,
607
792
  exact: n.exact,
608
793
  complete: !1
@@ -613,7 +798,7 @@ var J = class e {
613
798
  pageCount: n.layout.pages.length,
614
799
  exact: n.exact,
615
800
  complete: !1
616
- }), t._layoutObservers.notify("onLayoutPartial", i.onLayoutPartial, {
801
+ }), t._layoutObservers.notify("onLayoutPartial", r.onLayoutPartial, {
617
802
  availableUnits: n.layout.pages.length,
618
803
  exact: n.exact
619
804
  });
@@ -624,13 +809,13 @@ var J = class e {
624
809
  pageCount: t.pageCount,
625
810
  exact: !0,
626
811
  complete: !0
627
- }), l !== null && t._layoutObservers.notify("onLayoutComplete", i.onLayoutComplete), c.resolve();
812
+ }), l !== null && t._layoutObservers.notify("onLayoutComplete", r.onLayoutComplete), c.resolve();
628
813
  }).catch((e) => {
629
814
  if (l === null) {
630
815
  c.reject(e);
631
816
  return;
632
817
  }
633
- if (e instanceof Ie) {
818
+ if (e instanceof ze) {
634
819
  t._layoutLifecycle.succeed();
635
820
  return;
636
821
  }
@@ -640,20 +825,20 @@ var J = class e {
640
825
  exact: !1,
641
826
  complete: !1,
642
827
  error: n
643
- }), t._layoutObservers.notify("onLayoutComplete", i.onLayoutComplete, n);
828
+ }), t._layoutObservers.notify("onLayoutComplete", r.onLayoutComplete, n);
644
829
  }), await c.promise;
645
- } else if (a && (i.sliceLayout || i.onLayoutProgress)) {
646
- let e = await Be(d._source.bodyLayoutInput, n, o, s);
647
- r.layoutVariants.prime(o, e);
648
- } else r.layoutVariants.layoutFor(o);
830
+ } else if (a && (r.sliceLayout || r.onLayoutProgress)) {
831
+ let e = await Ue(d._source.bodyLayoutInput, n, o, s);
832
+ i.layoutVariants.prime(o, e);
833
+ } else i.layoutVariants.layoutFor(o);
649
834
  }
650
- return await d._resourceUsage(i.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: d.pageCount }), d;
835
+ return await d._resourceUsage(r.workerTimeoutMs ?? 1e3).then((e) => s.observeUsage(e), () => void 0), s.checkpoint("model and layout ready"), s.succeed({ pages: d.pageCount }), d;
651
836
  } catch (e) {
652
837
  let t = d;
653
- throw p(n, t ? () => t.destroy() : void 0), e;
838
+ throw p(c, t ? () => t.destroy() : void 0), e;
654
839
  }
655
840
  } catch (e) {
656
- throw c.fail(e), e;
841
+ throw s.fail(e), e;
657
842
  }
658
843
  }
659
844
  async _parse(e, t, n = !1, r, i, a, o) {
@@ -667,7 +852,7 @@ var J = class e {
667
852
  data: e,
668
853
  resourcePolicy: t,
669
854
  useGoogleFonts: n,
670
- defaultCurrentDateMs: E(this).defaultCurrentDateMs,
855
+ defaultCurrentDateMs: D(this).defaultCurrentDateMs,
671
856
  ...this._parseViewFields(),
672
857
  renderers: a
673
858
  } : {
@@ -678,14 +863,14 @@ var J = class e {
678
863
  }, [e], { timeoutMs: r });
679
864
  if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
680
865
  if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
681
- let e = await k(this._bridge.transport(A), s, {
866
+ let e = await O(this._bridge.transport(k), s, {
682
867
  timeoutMs: r,
683
868
  onUsage: i
684
869
  });
685
870
  this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
686
871
  } else this._meta = s.meta;
687
872
  else {
688
- let e = s, t = await k(this._bridge.transport(A), e, {
873
+ let e = s, t = await O(this._bridge.transport(k), e, {
689
874
  timeoutMs: r,
690
875
  onUsage: i
691
876
  });
@@ -694,7 +879,7 @@ var J = class e {
694
879
  this._review = q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []);
695
880
  }
696
881
  _onWorkerLayoutPush(e) {
697
- if (g((e, t) => this._worker.postMessage(e, t), e) || !("forId" in e) || e.forId !== this._parseRequestId) return;
882
+ if (v((e, t) => this._worker.postMessage(e, t), e) || !("forId" in e) || e.forId !== this._parseRequestId) return;
698
883
  this._rearmParseWatchdog();
699
884
  let t = this._progressive;
700
885
  if (t?.settled) return;
@@ -767,7 +952,7 @@ var J = class e {
767
952
  return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
768
953
  }
769
954
  _isLayoutViewActive(e) {
770
- return Bt(E(this).activeLayoutOptions, e);
955
+ return an(D(this).activeLayoutOptions, e);
771
956
  }
772
957
  _rearmParseWatchdog() {
773
958
  this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
@@ -796,7 +981,7 @@ var J = class e {
796
981
  }), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
797
982
  }
798
983
  _parseViewFields() {
799
- let e = E(this), t = e.activeLayoutOptions;
984
+ let e = D(this), t = e.activeLayoutOptions;
800
985
  return t ? {
801
986
  ...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
802
987
  ...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
@@ -809,7 +994,7 @@ var J = class e {
809
994
  data: e,
810
995
  resourcePolicy: t,
811
996
  useGoogleFonts: n,
812
- defaultCurrentDateMs: E(this).defaultCurrentDateMs,
997
+ defaultCurrentDateMs: D(this).defaultCurrentDateMs,
813
998
  ...this._parseViewFields(),
814
999
  renderers: a,
815
1000
  progressiveLayout: !0
@@ -817,7 +1002,7 @@ var J = class e {
817
1002
  if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
818
1003
  if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
819
1004
  this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
820
- let t = await k(this._bridge.transport(A), e, {
1005
+ let t = await O(this._bridge.transport(k), e, {
821
1006
  timeoutMs: r,
822
1007
  onUsage: i
823
1008
  });
@@ -836,7 +1021,7 @@ var J = class e {
836
1021
  }), this._rearmParseWatchdog(), await o.firstPublication.promise;
837
1022
  }
838
1023
  destroy() {
839
- this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review = Wt, E(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (xe(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (ge(this._googleFontFaces), this._googleFontFaces = []), this._localMetricFontFaces.length > 0 && (Le(this._localMetricFontFaces), this._localMetricFontFaces = []), c(this._fetchImage), u(this._fetchImage);
1024
+ this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review = ln, D(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (ve(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (_(this._googleFontFaces), this._googleFontFaces = []), c(this._fetchImage), l(this._fetchImage);
840
1025
  }
841
1026
  async getImage(e, t) {
842
1027
  return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
@@ -865,7 +1050,7 @@ var J = class e {
865
1050
  async getResourceMetrics() {
866
1051
  let e = this._metrics;
867
1052
  if (!e) throw Error("Document not loaded");
868
- return f(e, (e) => this._resourceUsage(e));
1053
+ return r(e, (e) => this._resourceUsage(e));
869
1054
  }
870
1055
  async toMarkdown() {
871
1056
  return (await this._bridge.request((e) => ({
@@ -897,32 +1082,32 @@ var J = class e {
897
1082
  return this._reviewSnapshot().revisions;
898
1083
  }
899
1084
  commentAnchorRanges() {
900
- if (this._meta) return this._meta.commentAnchorRanges ?? Ht;
1085
+ if (this._meta) return this._meta.commentAnchorRanges ?? sn;
901
1086
  if (!this._document || !this._source) return [];
902
1087
  let e = this._reviewSnapshot().comments;
903
- if (e.length === 0) return Ht;
904
- let t = E(this), n = t.services;
1088
+ if (e.length === 0) return sn;
1089
+ let t = D(this), n = t.services;
905
1090
  if (!n) throw Error("Document layout services are not initialized");
906
- let r = D(n);
1091
+ let r = Ve(n);
907
1092
  if (!r) throw Error("Document layout variant store is not initialized");
908
1093
  let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
909
- this._reviewProjectionIndex ??= Ke(a);
1094
+ this._reviewProjectionIndex ??= Ye(a);
910
1095
  let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
911
- return this._commentAnchorRanges ??= nt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
1096
+ return this._commentAnchorRanges ??= ot(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
912
1097
  }
913
1098
  revisionAnchorRanges() {
914
- if (this._meta) return this._meta.revisionAnchorRanges ?? Ut;
1099
+ if (this._meta) return this._meta.revisionAnchorRanges ?? cn;
915
1100
  if (!this._document || !this._source) return [];
916
1101
  let e = this._reviewSnapshot().revisions;
917
- if (e.length === 0) return Ut;
918
- let t = E(this), n = t.services;
1102
+ if (e.length === 0) return cn;
1103
+ let t = D(this), n = t.services;
919
1104
  if (!n) throw Error("Document layout services are not initialized");
920
- let r = D(n);
1105
+ let r = Ve(n);
921
1106
  if (!r) throw Error("Document layout variant store is not initialized");
922
1107
  let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
923
- this._reviewProjectionIndex ??= Ke(a);
1108
+ this._reviewProjectionIndex ??= Ye(a);
924
1109
  let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
925
- return this._revisionAnchorRanges ??= jt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
1110
+ return this._revisionAnchorRanges ??= Yt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
926
1111
  }
927
1112
  _reviewSnapshot() {
928
1113
  return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
@@ -935,16 +1120,16 @@ var J = class e {
935
1120
  }
936
1121
  _getLayout() {
937
1122
  if (!this._document) return null;
938
- let e = E(this), t = e.services;
1123
+ let e = D(this), t = e.services;
939
1124
  if (!t) throw Error("Document layout services are not initialized");
940
- let n = D(t);
1125
+ let n = Ve(t);
941
1126
  if (!n) throw Error("Document layout variant store is not initialized");
942
1127
  let r = e.activeLayoutOptions;
943
1128
  return r ? n.layoutFor(r) : n.defaultLayout;
944
1129
  }
945
1130
  async setLayoutView(e = {}) {
946
- let t = e[Lt], n = E(this), r = O(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
947
- if (!Bt(a, r)) {
1131
+ let t = e[tn], n = D(this), r = Oe(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
1132
+ if (!an(a, r)) {
948
1133
  if (this._mode === "worker" && this._meta) {
949
1134
  let e = await this._bridge.request((e) => ({
950
1135
  type: "selectLayoutView",
@@ -957,17 +1142,17 @@ var J = class e {
957
1142
  n.activeLayoutOptions = r, this._meta = {
958
1143
  ...this._meta,
959
1144
  ...a.meta
960
- }, this._invalidateLayoutDerivedCaches(), Rt(this, t);
1145
+ }, this._invalidateLayoutDerivedCaches(), nn(this, t);
961
1146
  return;
962
1147
  }
963
- n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), Rt(this, t);
1148
+ n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), nn(this, t);
964
1149
  }
965
1150
  }
966
1151
  _getBookmarkPages() {
967
1152
  if (this._bookmarkPages) return this._bookmarkPages;
968
1153
  if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
969
1154
  let e = this._getLayout();
970
- return e ? (this._bookmarkPages = st(e), this._bookmarkPages) : null;
1155
+ return e ? (this._bookmarkPages = Ct(e), this._bookmarkPages) : null;
971
1156
  }
972
1157
  getBookmarkPage(e) {
973
1158
  return this._getBookmarkPages()?.get(e);
@@ -999,7 +1184,7 @@ var J = class e {
999
1184
  };
1000
1185
  }
1001
1186
  _withActiveView(e) {
1002
- let t = E(this).activeLayoutOptions;
1187
+ let t = D(this).activeLayoutOptions;
1003
1188
  if (!t) return e;
1004
1189
  let n = { ...e };
1005
1190
  return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
@@ -1007,41 +1192,41 @@ var J = class e {
1007
1192
  renderPage(e, t, n = {}) {
1008
1193
  if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
1009
1194
  if (!this._source) throw Error("Document not loaded");
1010
- return Me(this._source, e, t, {
1195
+ return Fe(this._source, e, t, {
1011
1196
  ...this._withActiveView(n),
1012
1197
  fetchImage: this._fetchImage,
1013
- layoutServices: E(this).services ?? void 0,
1014
- defaultCurrentDateMs: E(this).defaultCurrentDateMs,
1198
+ layoutServices: D(this).services ?? void 0,
1199
+ defaultCurrentDateMs: D(this).defaultCurrentDateMs,
1015
1200
  threeD: this._threeD,
1016
1201
  regionMap: this._regionMap,
1017
1202
  chartEx: this._chartEx,
1018
1203
  tiff: this._tiff
1019
1204
  });
1020
1205
  }
1021
- async renderPageToBitmap(e, t = {}) {
1022
- let { onTextRun: n, ...r } = t, i = {
1023
- ...this._withActiveView(r),
1024
- dpr: r.dpr ?? s()
1206
+ async renderPageToBitmap(e, n = {}) {
1207
+ let { onTextRun: r, ...i } = n, a = {
1208
+ ...this._withActiveView(i),
1209
+ dpr: i.dpr ?? t()
1025
1210
  };
1026
1211
  if (this._mode === "worker") {
1027
1212
  let t = await this._bridge.request((t) => ({
1028
1213
  type: "renderPage",
1029
1214
  id: t,
1030
1215
  pageIndex: e,
1031
- opts: i
1216
+ opts: a
1032
1217
  }));
1033
1218
  try {
1034
- if (n) for (let e of t.runs) n(e);
1219
+ if (r) for (let e of t.runs) r(e);
1035
1220
  } catch (e) {
1036
- throw d(t.bitmap), e;
1221
+ throw o(t.bitmap), e;
1037
1222
  }
1038
1223
  return t.bitmap;
1039
1224
  }
1040
- let a = new OffscreenCanvas(1, 1);
1041
- return await this.renderPage(a, e, {
1042
- ...i,
1043
- onTextRun: n
1044
- }), a.transferToImageBitmap();
1225
+ let s = new OffscreenCanvas(1, 1);
1226
+ return await this.renderPage(s, e, {
1227
+ ...a,
1228
+ onTextRun: r
1229
+ }), s.transferToImageBitmap();
1045
1230
  }
1046
1231
  async collectPageRuns(e, t = {}) {
1047
1232
  let n = { ...this._withActiveView(t) };
@@ -1051,9 +1236,9 @@ var J = class e {
1051
1236
  pageIndex: e,
1052
1237
  opts: n
1053
1238
  }))).runs;
1054
- let r = E(this), i = r.services;
1239
+ let r = D(this), i = r.services;
1055
1240
  if (!i) throw Error("Document layout services are not initialized");
1056
- return qe(i, e, {
1241
+ return Xe(i, e, {
1057
1242
  currentDate: n.currentDate,
1058
1243
  defaultCurrentDateMs: r.defaultCurrentDateMs,
1059
1244
  width: n.width,
@@ -1062,7 +1247,7 @@ var J = class e {
1062
1247
  }
1063
1248
  async getCommentThreads(e, t = {}) {
1064
1249
  let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
1065
- return tt(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
1250
+ return at(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
1066
1251
  }
1067
1252
  async getElementContextAt(e, t, n = {}) {
1068
1253
  let r = this._withActiveView(n);
@@ -1073,9 +1258,9 @@ var J = class e {
1073
1258
  point: t,
1074
1259
  opts: r
1075
1260
  }))).context;
1076
- let i = E(this), a = i.services;
1261
+ let i = D(this), a = i.services;
1077
1262
  if (!a) throw Error("Document layout services are not initialized");
1078
- return Tt(a, e, t, {
1263
+ return Vt(a, e, t, {
1079
1264
  ...r,
1080
1265
  defaultCurrentDateMs: i.defaultCurrentDateMs
1081
1266
  });
@@ -1083,7 +1268,7 @@ var J = class e {
1083
1268
  };
1084
1269
  //#endregion
1085
1270
  //#region packages/docx/src/tate-chu-yoko-overlay.ts
1086
- function Gt(e, t) {
1271
+ function un(e, t) {
1087
1272
  if (!e.eastAsianVert) return 1;
1088
1273
  let n = t(e.text);
1089
1274
  return !(n > 0) || e.w >= n ? 1 : e.w / n;
@@ -1101,11 +1286,11 @@ function X(e, t, n, r, i, a, o) {
1101
1286
  Y(t, "ooxmlSelectionRun", "docx"), Y(t, "runIndex", String(o)), c.paragraphId !== void 0 && Y(t, "paragraphId", c.paragraphId), c.source !== void 0 && (Y(t, "sourceStory", c.source.story), Y(t, "sourceStoryInstance", c.source.storyInstance), Y(t, "sourcePath", JSON.stringify(c.source.path))), t.textContent = c.text;
1102
1287
  let l = c.transform ?? "";
1103
1288
  if (a && c.eastAsianVert) {
1104
- let e = Gt(c, a(c.font));
1289
+ let e = un(c, a(c.font));
1105
1290
  e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
1106
1291
  }
1107
1292
  let u = l ? `transform:${l};transform-origin:top left;` : "", d = i ? c.hyperlink : void 0, f = d ? "pointer" : "text", p = c.letterSpacingPx === void 0 ? "0" : `${c.letterSpacingPx}px`;
1108
- t.style.cssText = `position:absolute;left:${M(c.x, n)};top:${M(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
1293
+ t.style.cssText = `position:absolute;left:${j(c.x, n)};top:${j(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
1109
1294
  e.preventDefault(), i(d);
1110
1295
  })), e.appendChild(t);
1111
1296
  }
@@ -1118,16 +1303,16 @@ function Z(e, t, n, r, i, a, o = {}) {
1118
1303
  for (let s of o.slices) {
1119
1304
  let o = t[s.runIndex];
1120
1305
  if (!o) continue;
1121
- let c = a(o.font), l = $e(o.text, s.start, s.end, c), u = o.letterSpacingPx ?? 0, d = Math.max(0, Math.min(s.start, o.text.length)), f = Math.max(d, Math.min(s.end, o.text.length)), p = [...o.text.slice(0, d)].length, m = [...o.text.slice(d, f)].length, h = l.x + p * u, g = l.width + Math.max(0, m - 1) * u, _ = Gt(o, c), v = h * _, y = g * _;
1306
+ let c = a(o.font), l = nt(o.text, s.start, s.end, c), u = o.letterSpacingPx ?? 0, d = Math.max(0, Math.min(s.start, o.text.length)), f = Math.max(d, Math.min(s.end, o.text.length)), p = [...o.text.slice(0, d)].length, m = [...o.text.slice(d, f)].length, h = l.x + p * u, g = l.width + Math.max(0, m - 1) * u, _ = un(o, c), v = h * _, y = g * _;
1122
1307
  if (y <= 0) continue;
1123
1308
  let b = document.createElement("div"), x = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
1124
- b.style.cssText = `position:absolute;left:${M(o.x + v, r)};top:${M(o.y, i)};width:${M(y, r)};height:${M(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
1309
+ b.style.cssText = `position:absolute;left:${j(o.x + v, r)};top:${j(o.y, i)};width:${j(y, r)};height:${j(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
1125
1310
  }
1126
1311
  }
1127
1312
  }
1128
1313
  //#endregion
1129
1314
  //#region packages/docx/src/find.ts
1130
- var Kt = class {
1315
+ var dn = class {
1131
1316
  _pageRuns = /* @__PURE__ */ new Map();
1132
1317
  _matches = [];
1133
1318
  _active = -1;
@@ -1190,8 +1375,8 @@ var Kt = class {
1190
1375
  if (n !== this._generation) return [];
1191
1376
  let o = r === this._runsRevision ? i : new Map([...i, ...this._pageRuns]), s = [];
1192
1377
  for (let n = 0; n < a; n++) {
1193
- let r = o.get(n) ?? [], i = ie(r);
1194
- for (let a of re(i, e, t)) {
1378
+ let r = o.get(n) ?? [], i = ae(r);
1379
+ for (let a of ie(i, e, t)) {
1195
1380
  let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
1196
1381
  s.push({
1197
1382
  page: n,
@@ -1203,10 +1388,10 @@ var Kt = class {
1203
1388
  return this._runsRevision++, this._pageRuns = o, this._matches = s, this._active = -1, this.matches();
1204
1389
  }
1205
1390
  next() {
1206
- return this._active = te(this._active, this._matches.length), this._activePublic();
1391
+ return this._active = ne(this._active, this._matches.length), this._activePublic();
1207
1392
  }
1208
1393
  prev() {
1209
- return this._active = se(this._active, this._matches.length), this._activePublic();
1394
+ return this._active = ce(this._active, this._matches.length), this._activePublic();
1210
1395
  }
1211
1396
  _activePublic() {
1212
1397
  let e = this._matchAt(this._active);
@@ -1219,7 +1404,7 @@ var Kt = class {
1219
1404
  };
1220
1405
  //#endregion
1221
1406
  //#region packages/docx/src/selection-context.ts
1222
- function qt(e, t, n, r, i = {}) {
1407
+ function fn(e, t, n, r, i = {}) {
1223
1408
  let a = e.find((e) => e.id === n && e.parentId === void 0);
1224
1409
  if (!a) return null;
1225
1410
  let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
@@ -1233,7 +1418,7 @@ function qt(e, t, n, r, i = {}) {
1233
1418
  t = e;
1234
1419
  }
1235
1420
  return !1;
1236
- }), c = Se({
1421
+ }), c = xe({
1237
1422
  id: a.id,
1238
1423
  author: a.author,
1239
1424
  date: a.date,
@@ -1262,19 +1447,19 @@ function qt(e, t, n, r, i = {}) {
1262
1447
  maxTextCharacters: c.maxTextCharacters
1263
1448
  });
1264
1449
  }
1265
- function Jt(e) {
1450
+ function pn(e) {
1266
1451
  if (e === void 0 || !/^\d+$/.test(e)) return null;
1267
1452
  let t = Number(e);
1268
1453
  return Number.isSafeInteger(t) ? t : null;
1269
1454
  }
1270
- function Yt(e) {
1455
+ function mn(e) {
1271
1456
  for (let t = e; t; t = t.parentElement) {
1272
- let e = Jt(t.dataset.pageIndex);
1457
+ let e = pn(t.dataset.pageIndex);
1273
1458
  if (e !== null) return e;
1274
1459
  }
1275
1460
  return null;
1276
1461
  }
1277
- var Xt = new Set([
1462
+ var hn = new Set([
1278
1463
  "body",
1279
1464
  "header",
1280
1465
  "footer",
@@ -1282,9 +1467,9 @@ var Xt = new Set([
1282
1467
  "endnote",
1283
1468
  "textbox"
1284
1469
  ]);
1285
- function Zt(e) {
1470
+ function gn(e) {
1286
1471
  let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
1287
- if (!t || !Xt.has(t) || !n || !r) return null;
1472
+ if (!t || !hn.has(t) || !n || !r) return null;
1288
1473
  try {
1289
1474
  let e = JSON.parse(r);
1290
1475
  return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
@@ -1297,13 +1482,13 @@ function Zt(e) {
1297
1482
  }
1298
1483
  }
1299
1484
  function Q(e, t, n = {}) {
1300
- let r = le(e, t, (e) => {
1301
- let t = Yt(e), n = Jt(e.dataset.runIndex);
1485
+ let r = ue(e, t, (e) => {
1486
+ let t = mn(e), n = pn(e.dataset.runIndex);
1302
1487
  return t === null || n === null ? null : {
1303
1488
  pageIndex: t,
1304
1489
  runIndex: n,
1305
1490
  ...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
1306
- ...Zt(e) === null ? {} : { source: Zt(e) }
1491
+ ...gn(e) === null ? {} : { source: gn(e) }
1307
1492
  };
1308
1493
  }, {
1309
1494
  maxChars: n.maxTextCharacters,
@@ -1332,7 +1517,7 @@ function $(e, t, n, r, i) {
1332
1517
  }
1333
1518
  //#endregion
1334
1519
  //#region packages/docx/src/viewer.ts
1335
- var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1520
+ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
1336
1521
  _documentOwner;
1337
1522
  get _doc() {
1338
1523
  return this._documentOwner.current;
@@ -1375,20 +1560,20 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1375
1560
  ...r,
1376
1561
  currentDate: i.currentDate,
1377
1562
  showTrackedChanges: i.showTrackedChanges,
1378
- [Qt]: n
1563
+ [_n]: n
1379
1564
  });
1380
1565
  }
1381
1566
  constructor(e, t = {}) {
1382
1567
  this._canvas = e, this._opts = t;
1383
- let n = t[Qt];
1384
- this._borrowed = n !== void 0, this._mode = C("DocxViewer", t.mode, n), this._documentOwner = new y("DocxViewer", n ?? null, !1);
1568
+ let n = t[_n];
1569
+ this._borrowed = n !== void 0, this._mode = w("DocxViewer", t.mode, n), this._documentOwner = new x("DocxViewer", n ?? null, !1);
1385
1570
  let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
1386
1571
  if (!r) throw Error("DocxViewer requires a canvas with an active Window");
1387
- this._hostWindow = r, this._canvasMount = new ue(e, {
1572
+ this._hostWindow = r, this._canvasMount = new de(e, {
1388
1573
  wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
1389
1574
  forceDisplayBlock: !0
1390
- }), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new S(e, this._mode === "worker"), this._errorRouter = new ce("DocxViewer", t.onError);
1391
- let i = new ae(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
1575
+ }), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new C(e, this._mode === "worker"), this._errorRouter = new le("DocxViewer", t.onError);
1576
+ let i = new oe(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
1392
1577
  this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
1393
1578
  "position:absolute",
1394
1579
  "inset:0",
@@ -1402,7 +1587,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1402
1587
  let a = this._wrapper.ownerDocument.createElement("progress");
1403
1588
  a.setAttribute("aria-hidden", "true"), this._loadingLayer.appendChild(a), this._wrapper.insertBefore(this._loadingLayer, this._elementLayer), this._textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
1404
1589
  this._onElementClick(e).catch((e) => this._reportRenderError(e));
1405
- }, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new Kt(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
1590
+ }, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new dn(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
1406
1591
  }
1407
1592
  async load(e) {
1408
1593
  if (this._destroyed) throw Error("DocxViewer is destroyed");
@@ -1482,7 +1667,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1482
1667
  await this.goToPage(this._currentPage - 1);
1483
1668
  }
1484
1669
  _naturalWidthPx() {
1485
- return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * j;
1670
+ return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * A;
1486
1671
  }
1487
1672
  _renderWidth() {
1488
1673
  if (this._scale === null) return this._opts.width;
@@ -1501,14 +1686,14 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1501
1686
  return this._opts.zoomMax ?? 4;
1502
1687
  }
1503
1688
  async setScale(e) {
1504
- let t = ne(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
1689
+ let t = re(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
1505
1690
  this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
1506
1691
  }
1507
1692
  async zoomIn() {
1508
- await this.setScale(fe(this.getScale()));
1693
+ await this.setScale(pe(this.getScale()));
1509
1694
  }
1510
1695
  async zoomOut() {
1511
- await this.setScale(he(this.getScale()));
1696
+ await this.setScale(ge(this.getScale()));
1512
1697
  }
1513
1698
  async fitWidth() {
1514
1699
  await this._fit("width");
@@ -1520,9 +1705,9 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1520
1705
  if (!this._doc || this._doc.pageCount === 0) return;
1521
1706
  let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
1522
1707
  if (!n) return;
1523
- let r = v({
1524
- contentWidth: t.widthPt * j,
1525
- contentHeight: t.heightPt * j,
1708
+ let r = b({
1709
+ contentWidth: t.widthPt * A,
1710
+ contentHeight: t.heightPt * A,
1526
1711
  containerWidth: n.clientWidth,
1527
1712
  containerHeight: n.clientHeight
1528
1713
  }, e);
@@ -1561,7 +1746,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1561
1746
  }
1562
1747
  getSelectionContext(e = {}) {
1563
1748
  if (this._destroyed) throw Error("DocxViewer is destroyed");
1564
- return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Et(this._elementContext, e.maxTextCharacters) : null);
1749
+ return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Ht(this._elementContext, e.maxTextCharacters) : null);
1565
1750
  }
1566
1751
  _emitSelectionContextChange() {
1567
1752
  let e = this.getSelectionContext();
@@ -1578,11 +1763,11 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1578
1763
  _redrawElementOutline() {
1579
1764
  let e = this._elementContext, t = this._doc;
1580
1765
  if (!e || !t || e.pageIndex !== this._currentPage) {
1581
- x(this._elementLayer, null);
1766
+ S(this._elementLayer, null);
1582
1767
  return;
1583
1768
  }
1584
1769
  let n = t.pageSize(e.pageIndex);
1585
- x(this._elementLayer, {
1770
+ S(this._elementLayer, {
1586
1771
  x: e.bounds.xPt / n.widthPt,
1587
1772
  y: e.bounds.yPt / n.heightPt,
1588
1773
  width: e.bounds.widthPt / n.widthPt,
@@ -1616,7 +1801,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1616
1801
  }, {
1617
1802
  currentDate: this._opts.currentDate,
1618
1803
  showTrackedChanges: this._opts.showTrackedChanges,
1619
- maxTextCharacters: F
1804
+ maxTextCharacters: L
1620
1805
  });
1621
1806
  } catch (e) {
1622
1807
  if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
@@ -1625,7 +1810,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1625
1810
  return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
1626
1811
  }
1627
1812
  destroy() {
1628
- this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), We(this._canvas), this._documentOwner.close(), this._find.invalidate(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._wrapper.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._wrapper.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._canvasMount.restore());
1813
+ this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), qe(this._canvas), this._documentOwner.close(), this._find.invalidate(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._wrapper.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._wrapper.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._canvasMount.restore());
1629
1814
  }
1630
1815
  async _render() {
1631
1816
  let e = this._renderDispatcher.begin();
@@ -1661,7 +1846,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1661
1846
  }
1662
1847
  _bindLayoutDocument(e) {
1663
1848
  this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
1664
- let t = zt(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Ft(e, () => ({
1849
+ let t = rn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = $t(e, () => ({
1665
1850
  pageCount: e.pageCount,
1666
1851
  exact: e.layoutComplete,
1667
1852
  complete: e.layoutComplete
@@ -1763,7 +1948,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1763
1948
  _hyperlinkHandler() {
1764
1949
  return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
1765
1950
  if (e.kind === "external") {
1766
- a(e.url, void 0, this._hostWindow);
1951
+ u(e.url, void 0, this._hostWindow);
1767
1952
  return;
1768
1953
  }
1769
1954
  let t = this._doc;
@@ -1777,11 +1962,11 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
1777
1962
  let r = e.getBookmarkPage(t);
1778
1963
  r !== void 0 && await this.goToPage(r);
1779
1964
  }
1780
- }, en = 150, tn = "0 1px 3px rgba(0,0,0,0.2)", nn = 12, rn = 13, an = Symbol("DocxScrollViewer.borrowedDocument"), on;
1781
- function sn() {
1782
- return on ??= import("./comment-ui-runtime-DAKBCpsM.js");
1965
+ }, yn = 150, bn = "0 1px 3px rgba(0,0,0,0.2)", xn = 12, Sn = 13, Cn = Symbol("DocxScrollViewer.borrowedDocument"), wn;
1966
+ function Tn() {
1967
+ return wn ??= import("./comment-ui-runtime-DEtgcmj7.js");
1783
1968
  }
1784
- var cn = class e {
1969
+ var En = class e {
1785
1970
  _documentOwner;
1786
1971
  get _doc() {
1787
1972
  return this._documentOwner.current;
@@ -1844,7 +2029,7 @@ var cn = class e {
1844
2029
  _prevBase = 0;
1845
2030
  _lastFitWidth = 0;
1846
2031
  _pageShadow;
1847
- _find = new Kt(() => this.pageCount, (e) => this._collectPageRuns(e));
2032
+ _find = new dn(() => this.pageCount, (e) => this._collectPageRuns(e));
1848
2033
  _findActive = !1;
1849
2034
  _findRequestGeneration = 0;
1850
2035
  _showTrackedChanges;
@@ -1857,14 +2042,14 @@ var cn = class e {
1857
2042
  ...r,
1858
2043
  currentDate: i.currentDate,
1859
2044
  showTrackedChanges: i.showTrackedChanges,
1860
- [an]: n
2045
+ [Cn]: n
1861
2046
  });
1862
2047
  }
1863
2048
  constructor(e, t = {}) {
1864
2049
  if (e.tagName === "CANVAS") throw Error("DocxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-page canvas API use DocxViewer.");
1865
- this._container = e, this._opts = t, this._errorRouter = new ce("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ?? tn;
1866
- let n = t[an];
1867
- this._borrowed = n !== void 0, n ? (this._documentOwner = new y("DocxScrollViewer", n, !1), this._mode = C("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new y("DocxScrollViewer"), this._mode = C("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && sn().then((e) => {
2050
+ this._container = e, this._opts = t, this._errorRouter = new le("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ?? bn;
2051
+ let n = t[Cn];
2052
+ this._borrowed = n !== void 0, n ? (this._documentOwner = new x("DocxScrollViewer", n, !1), this._mode = w("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new x("DocxScrollViewer"), this._mode = w("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && Tn().then((e) => {
1868
2053
  if (!this._destroyed) {
1869
2054
  this._commentUi = e;
1870
2055
  for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
@@ -1872,7 +2057,7 @@ var cn = class e {
1872
2057
  }).catch((e) => this._reportRenderError(e)), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
1873
2058
  this._onElementClick(e).catch((e) => this._reportRenderError(e));
1874
2059
  }, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), t.comments && (this._commentOutsidePointerListener = (e) => {
1875
- if (!Te(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
2060
+ if (!we(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
1876
2061
  this._activeCommentId = null, this._activeCommentPage = null;
1877
2062
  for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
1878
2063
  this._emitSelectionContextChange();
@@ -1883,7 +2068,7 @@ var cn = class e {
1883
2068
  this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
1884
2069
  x: n,
1885
2070
  y: r
1886
- } : null, this.setScale(me(this._scale, e.deltaY, e.deltaMode));
2071
+ } : null, this.setScale(he(this._scale, e.deltaY, e.deltaMode));
1887
2072
  }, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && (this._bindLayoutDocument(n), this.relayout());
1888
2073
  }
1889
2074
  async load(e) {
@@ -1942,7 +2127,7 @@ var cn = class e {
1942
2127
  }
1943
2128
  _bindLayoutDocument(e) {
1944
2129
  this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount;
1945
- let t = zt(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Ft(e, () => ({
2130
+ let t = rn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = $t(e, () => ({
1946
2131
  pageCount: e.pageCount,
1947
2132
  exact: e.layoutComplete,
1948
2133
  complete: e.layoutComplete
@@ -1988,10 +2173,10 @@ var cn = class e {
1988
2173
  for (let [e, n] of t) e >= this._presentedPageCount || this._slots.get(e) !== n || this._refreshSlotAtomically(e, n);
1989
2174
  }
1990
2175
  _pageWidthPx(e) {
1991
- return this._doc.pageSize(e).widthPt * j * this._scale;
2176
+ return this._doc.pageSize(e).widthPt * A * this._scale;
1992
2177
  }
1993
2178
  _pageHeightPx(e) {
1994
- return this._doc.pageSize(e).heightPt * j * this._scale;
2179
+ return this._doc.pageSize(e).heightPt * A * this._scale;
1995
2180
  }
1996
2181
  _fitWidthPx() {
1997
2182
  if (this._opts.width && this._opts.width > 0) return this._opts.width;
@@ -2013,7 +2198,7 @@ var cn = class e {
2013
2198
  return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
2014
2199
  }
2015
2200
  _commentMarginExtent() {
2016
- return this._hasCommentMargin() ? (nn + 280) * this._commentZoom() : 0;
2201
+ return this._hasCommentMargin() ? (xn + 280) * this._commentZoom() : 0;
2017
2202
  }
2018
2203
  _commentZoom() {
2019
2204
  return this._scaleEstablished ? this._scale : 1;
@@ -2031,8 +2216,8 @@ var cn = class e {
2031
2216
  _syncCommentMarginGeometry(e) {
2032
2217
  if (!e) return;
2033
2218
  e.style.display = this._hasCommentMargin() ? "" : "none";
2034
- let t = this._commentZoom(), n = `calc(100% + ${nn * t}px)`;
2035
- e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${rn}px`, e.dataset.ooxmlCommentZoom = String(t);
2219
+ let t = this._commentZoom(), n = `calc(100% + ${xn * t}px)`;
2220
+ e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${Sn}px`, e.dataset.ooxmlCommentZoom = String(t);
2036
2221
  }
2037
2222
  _widestPageWidthPt() {
2038
2223
  if (!this._doc) return 0;
@@ -2048,7 +2233,7 @@ var cn = class e {
2048
2233
  let e = this._fitWidthPx();
2049
2234
  if (e <= 0) return 0;
2050
2235
  let t = this._widestPageWidthPt();
2051
- return t <= 0 ? 0 : e / (t * j);
2236
+ return t <= 0 ? 0 : e / (t * A);
2052
2237
  }
2053
2238
  relayout() {
2054
2239
  this._relayout();
@@ -2077,7 +2262,7 @@ var cn = class e {
2077
2262
  _recomputeHeights() {
2078
2263
  let e = Math.min(this._presentedPageCount, this._doc.pageCount), t = Array(e);
2079
2264
  for (let n = 0; n < e; n++) t[n] = this._pageHeightPx(n);
2080
- this._heights = t, this._scrollGeometry = we(t, this._gap(), this._pad());
2265
+ this._heights = t, this._scrollGeometry = Ce(t, this._gap(), this._pad());
2081
2266
  }
2082
2267
  _gap() {
2083
2268
  return this._opts.gap ?? 16;
@@ -2108,7 +2293,7 @@ var cn = class e {
2108
2293
  return a;
2109
2294
  }
2110
2295
  _range() {
2111
- return w(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
2296
+ return T(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
2112
2297
  }
2113
2298
  _syncSpacer() {
2114
2299
  let e = this._range();
@@ -2165,7 +2350,7 @@ var cn = class e {
2165
2350
  i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
2166
2351
  let a = null, o = null, s = null;
2167
2352
  this._commentsEnabled() && (a = document.createElement("div"), a.style.cssText = "position:absolute;inset:0;overflow:hidden;pointer-events:none;", t.appendChild(a), this._commentsOptions()?.cards !== !1 && (o = document.createElement("div"), o.style.cssText = "position:absolute;top:0;height:100%;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;pointer-events:auto;", this._syncCommentMarginGeometry(o), this._commentsOptions()?.connectors !== void 0 && (s = document.createElement("div"), s.style.cssText = "position:absolute;top:0;left:0;overflow:visible;pointer-events:none;", t.appendChild(s)), t.appendChild(o)));
2168
- let c = oe(t, this._opts.enableElementSelection === !0);
2353
+ let c = se(t, this._opts.enableElementSelection === !0);
2169
2354
  return this._scrollHost.appendChild(t), {
2170
2355
  wrapper: t,
2171
2356
  canvas: n,
@@ -2179,11 +2364,11 @@ var cn = class e {
2179
2364
  commentGeometry: null,
2180
2365
  renderedPage: -1,
2181
2366
  renderedScale: -1,
2182
- dispatcher: new S(n, this._mode === "worker")
2367
+ dispatcher: new C(n, this._mode === "worker")
2183
2368
  };
2184
2369
  }
2185
2370
  _recycleSlot(e, t) {
2186
- this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new S(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", this._clearTextLayerPreview(t.textLayer)), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.commentTintLayer && (t.commentTintLayer.replaceChildren(), t.commentTintLayer.style.transform = "", t.commentTintLayer.style.transformOrigin = "", t.commentTintLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren()), t.commentRuns = Object.freeze([]), t.commentGeometry = null, x(t.elementLayer, null), t.renderedPage = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
2371
+ this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new C(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", this._clearTextLayerPreview(t.textLayer)), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.commentTintLayer && (t.commentTintLayer.replaceChildren(), t.commentTintLayer.style.transform = "", t.commentTintLayer.style.transformOrigin = "", t.commentTintLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren()), t.commentRuns = Object.freeze([]), t.commentGeometry = null, S(t.elementLayer, null), t.renderedPage = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
2187
2372
  }
2188
2373
  _positionSlot(e, t, n) {
2189
2374
  e.wrapper.style.top = `${n.offsets[t]}px`;
@@ -2234,7 +2419,7 @@ var cn = class e {
2234
2419
  _hyperlinkHandler() {
2235
2420
  return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
2236
2421
  if (e.kind === "external") {
2237
- a(e.url);
2422
+ u(e.url);
2238
2423
  return;
2239
2424
  }
2240
2425
  let t = this._doc;
@@ -2313,12 +2498,12 @@ var cn = class e {
2313
2498
  f = Math.min(1, Math.max(0, f));
2314
2499
  let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
2315
2500
  this._renderEpoch++, this._scale = r, this._recomputeHeights();
2316
- let h = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
2501
+ let h = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
2317
2502
  this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
2318
2503
  let g = Math.max(0, h.totalHeight - this._scrollHost.clientHeight), _ = (h.offsets[u] ?? 0) + f * (this._heights[u] || 0), v = l < (s.offsets[0] ?? 0) ? c : _ - o;
2319
2504
  if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
2320
2505
  let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
2321
- this._scrollHost.scrollLeft = b(m, i.x - p, a, r, { maxScroll: e });
2506
+ this._scrollHost.scrollLeft = ee(m, i.x - p, a, r, { maxScroll: e });
2322
2507
  }
2323
2508
  this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
2324
2509
  }
@@ -2326,10 +2511,10 @@ var cn = class e {
2326
2511
  return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
2327
2512
  }
2328
2513
  zoomIn() {
2329
- this.setScale(fe(this.getScale()));
2514
+ this.setScale(pe(this.getScale()));
2330
2515
  }
2331
2516
  zoomOut() {
2332
- this.setScale(he(this.getScale(), this._effectiveZoomMin()));
2517
+ this.setScale(ge(this.getScale(), this._effectiveZoomMin()));
2333
2518
  }
2334
2519
  _effectiveZoomMin() {
2335
2520
  let e = this._opts.zoomMin ?? .1;
@@ -2343,9 +2528,9 @@ var cn = class e {
2343
2528
  }
2344
2529
  _fit(e) {
2345
2530
  if (!this._doc || this._doc.pageCount === 0) return;
2346
- let t = this._doc.pageSize(0), n = v({
2347
- contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) * j,
2348
- contentHeight: t.heightPt * j,
2531
+ let t = this._doc.pageSize(0), n = b({
2532
+ contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) * A,
2533
+ contentHeight: t.heightPt * A,
2349
2534
  containerWidth: this._fitWidthPx(),
2350
2535
  containerHeight: this._scrollHost.clientHeight
2351
2536
  }, e);
@@ -2382,7 +2567,7 @@ var cn = class e {
2382
2567
  _scheduleSettle() {
2383
2568
  this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
2384
2569
  this._settleTimer = null, this._settleRender();
2385
- }, en);
2570
+ }, yn);
2386
2571
  }
2387
2572
  _settleRender() {
2388
2573
  if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._refreshSlotAtomically(e, t);
@@ -2396,7 +2581,7 @@ var cn = class e {
2396
2581
  }
2397
2582
  let o = document.createElement("canvas");
2398
2583
  o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
2399
- let s = new S(o, !1), c = s.begin(), l = [], u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive || !!t.commentTintLayer, f = d ? (e) => l.push(e) : void 0;
2584
+ let s = new C(o, !1), c = s.begin(), l = [], u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive || !!t.commentTintLayer, f = d ? (e) => l.push(e) : void 0;
2400
2585
  $(this._doc, o, e, "main", {
2401
2586
  width: r,
2402
2587
  dpr: n,
@@ -2440,14 +2625,14 @@ var cn = class e {
2440
2625
  }
2441
2626
  scrollToPage(e, t) {
2442
2627
  if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
2443
- let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = r.offsets[n] ?? 0, a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
2628
+ let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = r.offsets[n] ?? 0, a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
2444
2629
  typeof s.scrollTo == "function" ? s.scrollTo({
2445
2630
  top: o,
2446
2631
  behavior: t?.behavior ?? "auto"
2447
2632
  }) : this._scrollHost.scrollTop = o, this._mountVisible();
2448
2633
  }
2449
2634
  _scrollToPageTarget(e, t, n) {
2450
- let r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = this._pageWidthPx(e), { left: a } = this._padH(), o = Math.max(a, (this._scrollHost.clientWidth - i) / 2) + this._reviewOriginPx, s = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), c = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, l = Math.max(0, c - this._scrollHost.clientWidth), u = Math.min(s, Math.max(0, (r.offsets[e] ?? 0) + t.y + t.h / 2 - this._scrollHost.clientHeight / 2)), d = Math.min(l, Math.max(0, o + t.x + t.w / 2 - this._scrollHost.clientWidth / 2)), f = this._scrollHost;
2635
+ let r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = this._pageWidthPx(e), { left: a } = this._padH(), o = Math.max(a, (this._scrollHost.clientWidth - i) / 2) + this._reviewOriginPx, s = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), c = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, l = Math.max(0, c - this._scrollHost.clientWidth), u = Math.min(s, Math.max(0, (r.offsets[e] ?? 0) + t.y + t.h / 2 - this._scrollHost.clientHeight / 2)), d = Math.min(l, Math.max(0, o + t.x + t.w / 2 - this._scrollHost.clientWidth / 2)), f = this._scrollHost;
2451
2636
  typeof f.scrollTo == "function" ? f.scrollTo({
2452
2637
  top: u,
2453
2638
  left: d,
@@ -2462,7 +2647,7 @@ var cn = class e {
2462
2647
  }
2463
2648
  _indexCommentPages(e, t, n) {
2464
2649
  if (!this._commentIndexedPages.has(e)) {
2465
- for (let r of n) this._commentPageById.has(r.commentId) || P(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
2650
+ for (let r of n) this._commentPageById.has(r.commentId) || N(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
2466
2651
  this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
2467
2652
  }
2468
2653
  }
@@ -2512,7 +2697,7 @@ var cn = class e {
2512
2697
  if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
2513
2698
  let u = await this._commentRunsForPage(s, n);
2514
2699
  if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
2515
- if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => P(e, u))[0], !c)) return !1;
2700
+ if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => N(e, u))[0], !c)) return !1;
2516
2701
  this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
2517
2702
  for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
2518
2703
  return this._emitSelectionContextChange(), !0;
@@ -2689,7 +2874,7 @@ var cn = class e {
2689
2874
  }
2690
2875
  getSelectionContext(e = {}) {
2691
2876
  if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
2692
- return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? qt(this._doc.comments, this._doc.commentAnchorRanges(), this._activeCommentId, this._activeCommentPage, e) : null) || ((this._opts.enableTextSelection ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Et(this._elementContext, e.maxTextCharacters) : null));
2877
+ return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? fn(this._doc.comments, this._doc.commentAnchorRanges(), this._activeCommentId, this._activeCommentPage, e) : null) || ((this._opts.enableTextSelection ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Ht(this._elementContext, e.maxTextCharacters) : null));
2693
2878
  }
2694
2879
  _emitSelectionContextChange() {
2695
2880
  let e = this.getSelectionContext();
@@ -2709,11 +2894,11 @@ var cn = class e {
2709
2894
  _redrawElementOutlineForSlot(e, t) {
2710
2895
  let n = this._elementContext, r = this._doc;
2711
2896
  if (!n || !r || n.pageIndex !== e) {
2712
- x(t.elementLayer, null);
2897
+ S(t.elementLayer, null);
2713
2898
  return;
2714
2899
  }
2715
2900
  let i = r.pageSize(e);
2716
- x(t.elementLayer, {
2901
+ S(t.elementLayer, {
2717
2902
  x: n.bounds.xPt / i.widthPt,
2718
2903
  y: n.bounds.yPt / i.heightPt,
2719
2904
  width: n.bounds.widthPt / i.widthPt,
@@ -2749,7 +2934,7 @@ var cn = class e {
2749
2934
  }, {
2750
2935
  currentDate: this._currentDate,
2751
2936
  ...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
2752
- maxTextCharacters: F
2937
+ maxTextCharacters: L
2753
2938
  });
2754
2939
  } catch (e) {
2755
2940
  if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
@@ -2767,7 +2952,7 @@ var cn = class e {
2767
2952
  };
2768
2953
  //#endregion
2769
2954
  //#region packages/docx/src/types.ts
2770
- function ln(e) {
2955
+ function Dn(e) {
2771
2956
  let t = [];
2772
2957
  for (let n of e.content) {
2773
2958
  if (n.type !== "paragraph") continue;
@@ -2779,25 +2964,25 @@ function ln(e) {
2779
2964
  }
2780
2965
  //#endregion
2781
2966
  //#region src/docx.ts
2782
- var un = /* @__PURE__ */ e({
2967
+ var On = /* @__PURE__ */ e({
2783
2968
  DocxDocument: () => J,
2784
- DocxScrollViewer: () => cn,
2785
- DocxViewer: () => $t,
2786
- OoxmlDecodedImageLimitError: () => Ye,
2787
- OoxmlError: () => l,
2788
- OoxmlResourceLimitError: () => o,
2789
- TiffDecodeError: () => Xe,
2790
- autoResize: () => _,
2969
+ DocxScrollViewer: () => En,
2970
+ DocxViewer: () => vn,
2971
+ OoxmlDecodedImageLimitError: () => Qe,
2972
+ OoxmlError: () => d,
2973
+ OoxmlResourceLimitError: () => s,
2974
+ TiffDecodeError: () => $e,
2975
+ autoResize: () => y,
2791
2976
  buildDocxHighlightLayer: () => Z,
2792
2977
  buildDocxTextLayer: () => X,
2793
- isOoxmlDecodedImageLimitError: () => Je,
2794
- isTiffDecodeError: () => Ze,
2795
- noteText: () => ln,
2796
- openExternalHyperlink: () => a,
2978
+ isOoxmlDecodedImageLimitError: () => Ze,
2979
+ isTiffDecodeError: () => et,
2980
+ noteText: () => Dn,
2981
+ openExternalHyperlink: () => u,
2797
2982
  readDocxTextSelectionContext: () => Q,
2798
- resolveCommentAnchorRuns: () => P,
2799
- resolveDocxCommentThreads: () => tt,
2800
- resolveRevisionAnchorRuns: () => Mt
2983
+ resolveCommentAnchorRuns: () => N,
2984
+ resolveDocxCommentThreads: () => at,
2985
+ resolveRevisionAnchorRuns: () => Xt
2801
2986
  });
2802
2987
  //#endregion
2803
- export { Q as a, J as c, $t as i, Mt as l, ln as n, Z as o, cn as r, X as s, un as t };
2988
+ export { Q as a, J as c, vn as i, Xt as l, Dn as n, Z as o, En as r, X as s, On as t };