@silurus/ooxml 0.86.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/assets/render-worker-CeK_iqK3.js +10 -0
- package/dist/assets/render-worker-DusrDhPk.js +11 -0
- package/dist/assets/render-worker-n2ZG0lrQ.js +31 -0
- package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +119 -0
- package/dist/{canvas-viewer-mechanics-B3A7KLLi.js → canvas-viewer-mechanics-Cpk0YFvM.js} +301 -155
- package/dist/chart-ex.mjs +1 -1
- package/dist/cjk-fallback-bLI3z70h.js +46 -0
- package/dist/{comment-ui-runtime-ssI6IE39.js → comment-ui-runtime-BfE7MJZn.js} +4 -4
- package/dist/comment-ui-runtime-BsK8pmUT.js +2 -0
- package/dist/{comment-ui-runtime-DEtgcmj7.js → comment-ui-runtime-DcJOYlw-.js} +5 -5
- package/dist/{comments-CAn2A_Xh.js → comments-Diid5ujN.js} +1 -1
- package/dist/{document-pull-client-xZrA2IjM.js → document-pull-client-yKxI8aDH.js} +4326 -4238
- package/dist/{docx-DzDiGvqe.js → docx-BkSRiy07.js} +541 -349
- package/dist/docx.mjs +7 -7
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-DK1JLkrz.js → dom-interaction-boundary-CBUQJsIM.js} +63 -57
- package/dist/{hyperlink-enyPbflR.js → hyperlink-ArrU3ArU.js} +1014 -951
- package/dist/index.mjs +4 -4
- package/dist/line-distribute-Dtudnqhs.js +1023 -0
- package/dist/math.mjs +2 -2
- package/dist/node.mjs +380 -376
- package/dist/{pptx-D_U62nl-.js → pptx-62MmVbYB.js} +462 -447
- package/dist/pptx.mjs +7 -7
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +1 -1
- package/dist/{render-DSn0d35X.js → render-8Zo7dnds.js} +31 -29
- package/dist/{render-worker-host-CbYDBg7U.js → render-worker-host-BfbnEChF.js} +1 -1
- package/dist/{render-worker-host-CO0UYoQh.js → render-worker-host-DNL9dWRh.js} +1 -1
- package/dist/{render-worker-host-BHz9vjxB.js → render-worker-host-IkHrYOci.js} +1 -1
- package/dist/{resource-measurement-Do07ZRcR.js → resource-measurement-CJsgolre.js} +9 -9
- package/dist/{session-C1GYhr6n.js → session-CrU8f8DI.js} +91 -91
- package/dist/{slide-pull-client-DuEaUxPw.js → slide-pull-client-B9KA8bU6.js} +1069 -966
- package/dist/three-d.mjs +1 -1
- package/dist/tiff.mjs +1 -1
- package/dist/types/chart-ex.d.ts +2 -2
- package/dist/types/docx.d.ts +15 -12
- package/dist/types/index.d.ts +23 -18
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +12 -6
- package/dist/types/pptx.d.ts +15 -11
- package/dist/types/region-map.d.ts +2 -2
- package/dist/types/three-d.d.ts +2 -2
- package/dist/types/tiff.d.ts +1 -1
- package/dist/types/xlsx.d.ts +15 -11
- package/dist/{worksheet-pull-client-eDiHHEG2.js → worksheet-pull-client-eIcQ-xlD.js} +65 -65
- package/dist/{xlsx-CMHmYTHP.js → xlsx-CRcSzZNq.js} +1656 -1630
- package/dist/xlsx.mjs +4 -4
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/assets/render-worker-BCGnuBLj.js +0 -10
- package/dist/assets/render-worker-CB4DxjXg.js +0 -31
- package/dist/assets/render-worker-CHW0F0n6.js +0 -11
- package/dist/bounded-raw-part-cache-DVx3Camo.js +0 -256
- package/dist/comment-ui-runtime-TLHustXJ.js +0 -2
- package/dist/line-distribute-BFB575d6.js +0 -1023
- /package/dist/{comment-occurrence-Dhdplprg.js → comment-occurrence-C8Y2uoVr.js} +0 -0
- /package/dist/{delimited-text-worker-host-DcHj_JZt.js → delimited-text-worker-host-BVY-Ecni.js} +0 -0
- /package/dist/{highlight-rect-FuUSmL3a.js → highlight-rect-C5hkRqUr.js} +0 -0
- /package/dist/{line-metrics-CBbw80Ko.js → line-metrics-B60C86uh.js} +0 -0
- /package/dist/{mathjax-DS69BmJd.js → mathjax-DoyWZbSp.js} +0 -0
- /package/dist/{read-only-comment-decoration-BTnWEeo5.js → read-only-comment-decoration-Dz7eTQ4d.js} +0 -0
- /package/dist/{read-only-comment-margin-plStyGfE.js → read-only-comment-margin-DkgzASAl.js} +0 -0
- /package/dist/{renderer-module-contract-Cu-GKuPd.js → renderer-module-contract-D91rkYHH.js} +0 -0
- /package/dist/{source-key-Ktb1GRE5.js → source-key-DIJG8BA0.js} +0 -0
- /package/dist/{transfer-mIj7E7NB.js → transfer-p6iCC2R7.js} +0 -0
- /package/dist/{visible-index-DPoQYSDt.js → visible-index-BgiHEc1z.js} +0 -0
|
@@ -1,22 +1,156 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import {
|
|
3
|
-
import { C as p, D as m,
|
|
4
|
-
import {
|
|
5
|
-
import { c as
|
|
6
|
-
import {
|
|
7
|
-
import { l as
|
|
8
|
-
import { a as
|
|
9
|
-
import { i as
|
|
10
|
-
import { n as
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
2
|
+
import { $ as t, $t as n, L as r, R as i, U as a, _t as o, ft as s, ln as c, lt as l, r as u, un as d, z as f } from "./hyperlink-ArrU3ArU.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-Cpk0YFvM.js";
|
|
4
|
+
import { c as _e, d as ve, f as ye, i as be, l as xe, n as Se, o as T, r as Ce, s as we, t as Te, u as Ee } from "./dom-interaction-boundary-CBUQJsIM.js";
|
|
5
|
+
import { A as De, C as E, D as Oe, E as ke, M as Ae, O as D, S as je, T as Me, _ as Ne, a as Pe, b as Fe, c as Ie, d as Le, f as Re, g as ze, h as Be, j as Ve, k as He, l as Ue, m as We, n as Ge, o as Ke, p as qe, s as Je, t as O, v as Ye, w as Xe, x as Ze, y as Qe } from "./document-pull-client-yKxI8aDH.js";
|
|
6
|
+
import { n as $e } from "./cjk-fallback-bLI3z70h.js";
|
|
7
|
+
import { l as et, s as tt } from "./pixel-budget-Dgjw269h.js";
|
|
8
|
+
import { a as k } from "./units-EJdC96r6.js";
|
|
9
|
+
import { i as nt, s as rt } from "./raster-target-ojDdQizC.js";
|
|
10
|
+
import { n as it } from "./renderer-module-contract-D91rkYHH.js";
|
|
11
|
+
import { n as at, t as A } from "./highlight-rect-C5hkRqUr.js";
|
|
12
|
+
import { t as ot } from "./bounded-raw-part-cache-Cg1BsSZQ.js";
|
|
13
|
+
import { o as j } from "./source-key-DIJG8BA0.js";
|
|
14
|
+
import { i as st, n as M, r as ct, t as lt } from "./comments-Diid5ujN.js";
|
|
15
|
+
//#region packages/core/src/fonts/open-type-metrics.ts
|
|
16
|
+
var N = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCodeAt(2) << 8 | e.charCodeAt(3)) >>> 0, ut = N("ttcf"), dt = N("OTTO"), ft = N("true"), pt = N("typ1"), mt = N("head"), ht = N("hhea"), gt = N("OS/2"), _t = N("cmap"), P = [
|
|
17
|
+
[4352, 4607],
|
|
18
|
+
[11904, 12287],
|
|
19
|
+
[12352, 12543],
|
|
20
|
+
[12544, 12591],
|
|
21
|
+
[12592, 12687],
|
|
22
|
+
[12704, 12735],
|
|
23
|
+
[12784, 12799],
|
|
24
|
+
[13312, 19903],
|
|
25
|
+
[19968, 40959],
|
|
26
|
+
[40960, 42191],
|
|
27
|
+
[43360, 43391],
|
|
28
|
+
[44032, 55203],
|
|
29
|
+
[63744, 64255],
|
|
30
|
+
[131072, 205743]
|
|
31
|
+
];
|
|
32
|
+
function F(e, t, n) {
|
|
33
|
+
return Number.isSafeInteger(t) && Number.isSafeInteger(n) && t >= 0 && n >= 0 && t <= e - n;
|
|
34
|
+
}
|
|
35
|
+
function vt(e, t, n) {
|
|
36
|
+
if (n < 16) return !1;
|
|
37
|
+
let r = e.getUint16(t + 2);
|
|
38
|
+
if (r < 16 || r > n) return !1;
|
|
39
|
+
let i = e.getUint16(t + 6);
|
|
40
|
+
if (i === 0 || i % 2 != 0) return !1;
|
|
41
|
+
let a = i / 2, o = t + 14, s = o + a * 2 + 2, c = s + a * 2, l = c + a * 2;
|
|
42
|
+
if (l + a * 2 > t + r) return !1;
|
|
43
|
+
let u = -1;
|
|
44
|
+
for (let t = 0; t < a; t++) {
|
|
45
|
+
let n = e.getUint16(s + t * 2), r = e.getUint16(o + t * 2);
|
|
46
|
+
if (n > r || n <= u) return !1;
|
|
47
|
+
u = r;
|
|
48
|
+
}
|
|
49
|
+
for (let n = 0; n < a; n++) {
|
|
50
|
+
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);
|
|
51
|
+
for (let [n, o] of P) {
|
|
52
|
+
let s = Math.max(i, n), c = Math.min(a, o);
|
|
53
|
+
if (!(s > c)) {
|
|
54
|
+
if (f === 0) {
|
|
55
|
+
if (s < c || s + u & 65535) return !0;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
for (let n = s; n <= c; n++) {
|
|
59
|
+
let a = d + f + (n - i) * 2;
|
|
60
|
+
if (a + 2 > t + r) break;
|
|
61
|
+
let o = e.getUint16(a);
|
|
62
|
+
if (o !== 0 && o + u & 65535) return !0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return !1;
|
|
68
|
+
}
|
|
69
|
+
function yt(e, t, n, r) {
|
|
70
|
+
if (n < 16) return !1;
|
|
71
|
+
let i = e.getUint32(t + 4), a = e.getUint32(t + 12);
|
|
72
|
+
if (i < 16 || i > n || a > (i - 16) / 12) return !1;
|
|
73
|
+
let o = -1;
|
|
74
|
+
for (let n = 0; n < a; n++) {
|
|
75
|
+
let i = t + 16 + n * 12, a = e.getUint32(i), s = e.getUint32(i + 4), c = e.getUint32(i + 8);
|
|
76
|
+
if (a > s || s > 1114111 || a <= o) return !1;
|
|
77
|
+
if (o = s, a > P[P.length - 1][1]) break;
|
|
78
|
+
for (let [e, t] of P) {
|
|
79
|
+
let n = Math.max(a, e), i = Math.min(s, t);
|
|
80
|
+
if (!(n > i)) {
|
|
81
|
+
if (r) {
|
|
82
|
+
if (c !== 0) return !0;
|
|
83
|
+
} else if (n < i || c + (n - a) !== 0) return !0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return !1;
|
|
88
|
+
}
|
|
89
|
+
function bt(e, t) {
|
|
90
|
+
if (!t || t.length < 4) return !1;
|
|
91
|
+
let n = e.getUint16(t.offset + 2);
|
|
92
|
+
if (4 + n * 8 > t.length) return !1;
|
|
93
|
+
for (let r = 0; r < n; r++) {
|
|
94
|
+
let n = t.offset + 4 + r * 8, i = e.getUint16(n), a = e.getUint16(n + 2);
|
|
95
|
+
if (i !== 0 && !(i === 3 && (a === 1 || a === 10))) continue;
|
|
96
|
+
let o = e.getUint32(n + 4);
|
|
97
|
+
if (o > t.length - 2) continue;
|
|
98
|
+
let s = t.offset + o, c = t.length - o, l = e.getUint16(s);
|
|
99
|
+
if (l === 4 && vt(e, s, c) || l === 12 && yt(e, s, c, !1) || l === 13 && yt(e, s, c, !0)) return !0;
|
|
100
|
+
}
|
|
101
|
+
return !1;
|
|
102
|
+
}
|
|
103
|
+
function xt(e, t) {
|
|
104
|
+
if (t !== void 0 && (!Number.isSafeInteger(t) || t < 0) || e.byteLength < 12) return null;
|
|
105
|
+
let n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = 0;
|
|
106
|
+
if (n.getUint32(0) === ut) {
|
|
107
|
+
if (t === void 0 || e.byteLength < 12) return null;
|
|
108
|
+
let i = n.getUint32(8);
|
|
109
|
+
if (t >= i || !F(e.byteLength, 12, i * 4)) return null;
|
|
110
|
+
r = n.getUint32(12 + t * 4);
|
|
111
|
+
} else if (t !== void 0 && t !== 0) return null;
|
|
112
|
+
if (!F(e.byteLength, r, 12)) return null;
|
|
113
|
+
let i = n.getUint32(r);
|
|
114
|
+
if (i !== 65536 && i !== dt && i !== ft && i !== pt) return null;
|
|
115
|
+
let a = n.getUint16(r + 4);
|
|
116
|
+
if (!F(e.byteLength, r + 12, a * 16)) return null;
|
|
117
|
+
let o = /* @__PURE__ */ new Map();
|
|
118
|
+
for (let t = 0; t < a; t++) {
|
|
119
|
+
let i = r + 12 + t * 16, a = n.getUint32(i), s = n.getUint32(i + 8), c = n.getUint32(i + 12);
|
|
120
|
+
if (o.has(a) || !F(e.byteLength, s, c)) return null;
|
|
121
|
+
o.set(a, {
|
|
122
|
+
offset: s,
|
|
123
|
+
length: c
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
let s = o.get(mt), c = o.get(ht);
|
|
127
|
+
if (!s || s.length < 20 || !c || c.length < 10) return null;
|
|
128
|
+
let l = n.getUint16(s.offset + 18);
|
|
129
|
+
if (l < 16 || l > 16384) return null;
|
|
130
|
+
let u = o.get(gt), d = u !== void 0 && u.length >= 78;
|
|
131
|
+
return Object.freeze({
|
|
132
|
+
unitsPerEm: l,
|
|
133
|
+
hheaAscent: n.getInt16(c.offset + 4),
|
|
134
|
+
hheaDescent: n.getInt16(c.offset + 6),
|
|
135
|
+
hheaLineGap: n.getInt16(c.offset + 8),
|
|
136
|
+
hasEastAsianCmap: bt(n, o.get(_t)),
|
|
137
|
+
...d ? {
|
|
138
|
+
typoAscent: n.getInt16(u.offset + 68),
|
|
139
|
+
typoDescent: n.getInt16(u.offset + 70),
|
|
140
|
+
typoLineGap: n.getInt16(u.offset + 72),
|
|
141
|
+
winAscent: n.getUint16(u.offset + 74),
|
|
142
|
+
winDescent: n.getUint16(u.offset + 76),
|
|
143
|
+
useTypoMetrics: (n.getUint16(u.offset + 62) & 128) != 0
|
|
144
|
+
} : {}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
14
148
|
//#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
|
|
149
|
+
var St = "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}}};function De(e){try{let t=e(e=>e.document_cursor_resource_usage?.());return t?I(t):void 0}catch(e){if(String(e).includes(`document cursor usage is unavailable`))return;throw e}}const J=67108864;var Y=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:()=>De(this.executeArchive)}})}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 Oe(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new Y(()=>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(Oe(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)})}};", Ct = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", St], { type: "text/javascript;charset=utf-8" });
|
|
150
|
+
function wt(e) {
|
|
17
151
|
let t;
|
|
18
152
|
try {
|
|
19
|
-
if (t =
|
|
153
|
+
if (t = Ct && (self.URL || self.webkitURL).createObjectURL(Ct), !t) throw "";
|
|
20
154
|
let n = new Worker(t, {
|
|
21
155
|
type: "module",
|
|
22
156
|
name: e?.name
|
|
@@ -25,7 +159,7 @@ function at(e) {
|
|
|
25
159
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
26
160
|
}), n;
|
|
27
161
|
} catch {
|
|
28
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
162
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(St), {
|
|
29
163
|
type: "module",
|
|
30
164
|
name: e?.name
|
|
31
165
|
});
|
|
@@ -33,46 +167,97 @@ function at(e) {
|
|
|
33
167
|
}
|
|
34
168
|
//#endregion
|
|
35
169
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
36
|
-
var
|
|
170
|
+
var Tt = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
37
171
|
//#endregion
|
|
38
172
|
//#region packages/docx/src/bookmark-nav.ts
|
|
39
|
-
function
|
|
173
|
+
function Et(e) {
|
|
40
174
|
let t = /* @__PURE__ */ new Map();
|
|
41
175
|
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
176
|
return t;
|
|
43
177
|
}
|
|
44
178
|
//#endregion
|
|
45
179
|
//#region packages/docx/src/embedded-fonts.ts
|
|
46
|
-
async function
|
|
180
|
+
async function Dt(e, t) {
|
|
47
181
|
let n = e.embeddedFonts;
|
|
48
|
-
if (!n || n.length === 0) return
|
|
49
|
-
|
|
182
|
+
if (!n || n.length === 0) return {
|
|
183
|
+
faces: [],
|
|
184
|
+
metrics: {}
|
|
185
|
+
};
|
|
186
|
+
let r = [], i = /* @__PURE__ */ new Set();
|
|
187
|
+
for (let e of n) {
|
|
188
|
+
let t = Ot(e.style) === "bold" ? 700 : 400, n = kt(e.style), a = `${Ae(e.fontName)}:${t}:${n}`;
|
|
189
|
+
i.has(a) || (i.add(a), r.push(e));
|
|
190
|
+
}
|
|
191
|
+
let a = (await Promise.all(r.map(async (e) => {
|
|
50
192
|
try {
|
|
51
|
-
let n = await t(e.partPath)
|
|
52
|
-
return {
|
|
193
|
+
let n = await t(e.partPath), r = e.partPath.toLowerCase().endsWith(".odttf"), i = {
|
|
53
194
|
family: e.fontName,
|
|
54
195
|
bytes: n,
|
|
55
|
-
odttf:
|
|
196
|
+
odttf: r,
|
|
56
197
|
fontKey: e.fontKey,
|
|
57
|
-
weight:
|
|
58
|
-
style:
|
|
198
|
+
weight: Ot(e.style),
|
|
199
|
+
style: kt(e.style)
|
|
200
|
+
};
|
|
201
|
+
if (!Ee(n)) return {
|
|
202
|
+
face: i,
|
|
203
|
+
metric: null
|
|
204
|
+
};
|
|
205
|
+
let a = i, o = null;
|
|
206
|
+
try {
|
|
207
|
+
let t = r ? xe(n, e.fontKey ?? "") : n;
|
|
208
|
+
a = {
|
|
209
|
+
...i,
|
|
210
|
+
bytes: t,
|
|
211
|
+
odttf: !1,
|
|
212
|
+
fontKey: ""
|
|
213
|
+
};
|
|
214
|
+
let s = xt(t), c = s?.hasEastAsianCmap ? Me(s) : 0;
|
|
215
|
+
c > 0 && (o = Object.freeze({
|
|
216
|
+
family: e.fontName,
|
|
217
|
+
requestedFamily: e.fontName,
|
|
218
|
+
weight: a.weight === "bold" ? 700 : 400,
|
|
219
|
+
style: a.style,
|
|
220
|
+
sourceIdentity: `embedded:${e.partPath}`,
|
|
221
|
+
synthesized: !1,
|
|
222
|
+
eastAsianLineHeightRatio: c
|
|
223
|
+
}));
|
|
224
|
+
} catch {}
|
|
225
|
+
return {
|
|
226
|
+
face: a,
|
|
227
|
+
metric: o
|
|
59
228
|
};
|
|
60
229
|
} catch {
|
|
61
230
|
return null;
|
|
62
231
|
}
|
|
63
232
|
}))).filter((e) => e !== null);
|
|
64
|
-
|
|
233
|
+
if (a.length === 0) return {
|
|
234
|
+
faces: [],
|
|
235
|
+
metrics: {}
|
|
236
|
+
};
|
|
237
|
+
let o = await ve(a.map((e) => e.face)), s = new Set(o.map((e) => {
|
|
238
|
+
let t = e.family.trim().replace(/^(['"])(.*)\1$/, "$2"), n = e.weight === "bold" ? 700 : Number(e.weight) || 400, r = e.style === "italic" ? "italic" : "normal";
|
|
239
|
+
return `${Ae(t)}:${n}:${r}`;
|
|
240
|
+
})), c = {};
|
|
241
|
+
for (let e of a) {
|
|
242
|
+
if (!e.metric) continue;
|
|
243
|
+
let t = Ae(e.face.family), n = e.face.weight === "bold" ? 700 : 400, r = e.face.style, i = `${t}:${n}:${r}`;
|
|
244
|
+
s.has(i) && (c[n === 400 && r === "normal" ? t : i] = e.metric);
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
faces: o,
|
|
248
|
+
metrics: Object.freeze(c)
|
|
249
|
+
};
|
|
65
250
|
}
|
|
66
|
-
function
|
|
251
|
+
function Ot(e) {
|
|
67
252
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
68
253
|
}
|
|
69
|
-
function
|
|
254
|
+
function kt(e) {
|
|
70
255
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
71
256
|
}
|
|
72
257
|
//#endregion
|
|
73
258
|
//#region packages/docx/src/element-context.ts
|
|
74
|
-
var
|
|
75
|
-
function
|
|
259
|
+
var I = fe, At = 16384;
|
|
260
|
+
function jt(e, t) {
|
|
76
261
|
let n = Math.min(e.length, t);
|
|
77
262
|
if (n > 0 && n < e.length) {
|
|
78
263
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -80,7 +265,7 @@ function ft(e, t) {
|
|
|
80
265
|
}
|
|
81
266
|
return e.slice(0, n);
|
|
82
267
|
}
|
|
83
|
-
function
|
|
268
|
+
function Mt(e, t) {
|
|
84
269
|
let n = [], r = 0, i = !1;
|
|
85
270
|
for (let a of e) {
|
|
86
271
|
if (a.length === 0) continue;
|
|
@@ -91,7 +276,7 @@ function pt(e, t) {
|
|
|
91
276
|
}
|
|
92
277
|
n.push("\n"), r++;
|
|
93
278
|
}
|
|
94
|
-
let e =
|
|
279
|
+
let e = jt(a, Math.max(0, t - r));
|
|
95
280
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
96
281
|
i = !0;
|
|
97
282
|
break;
|
|
@@ -103,7 +288,7 @@ function pt(e, t) {
|
|
|
103
288
|
truncated: i
|
|
104
289
|
};
|
|
105
290
|
}
|
|
106
|
-
function*
|
|
291
|
+
function* L(e) {
|
|
107
292
|
if (e.kind === "paragraph") {
|
|
108
293
|
for (let t of e.lines) {
|
|
109
294
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -112,42 +297,42 @@ function* I(e) {
|
|
|
112
297
|
return;
|
|
113
298
|
}
|
|
114
299
|
if (e.kind === "table") {
|
|
115
|
-
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield*
|
|
300
|
+
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* L(t.layout);
|
|
116
301
|
return;
|
|
117
302
|
}
|
|
118
|
-
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield*
|
|
303
|
+
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* L(t);
|
|
119
304
|
}
|
|
120
|
-
function*
|
|
305
|
+
function* Nt(e) {
|
|
121
306
|
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*
|
|
307
|
+
for (let t of e.textBoxes) yield* L(t);
|
|
123
308
|
}
|
|
124
|
-
function
|
|
125
|
-
let t = e ??
|
|
309
|
+
function Pt(e) {
|
|
310
|
+
let t = e ?? At;
|
|
126
311
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
127
|
-
return Math.min(
|
|
312
|
+
return Math.min(I, Math.floor(t));
|
|
128
313
|
}
|
|
129
|
-
function
|
|
314
|
+
function Ft(e) {
|
|
130
315
|
return {
|
|
131
316
|
story: e.story,
|
|
132
317
|
storyInstance: e.storyInstance,
|
|
133
318
|
path: [...e.path]
|
|
134
319
|
};
|
|
135
320
|
}
|
|
136
|
-
function
|
|
321
|
+
function It(e) {
|
|
137
322
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
138
323
|
}
|
|
139
|
-
function
|
|
140
|
-
let t =
|
|
141
|
-
|
|
142
|
-
|
|
324
|
+
function Lt(e) {
|
|
325
|
+
let t = It(e), n = [
|
|
326
|
+
E(e.pointToPage, t),
|
|
327
|
+
E(e.pointToPage, {
|
|
143
328
|
xPt: t.xPt + t.widthPt,
|
|
144
329
|
yPt: t.yPt
|
|
145
330
|
}),
|
|
146
|
-
|
|
331
|
+
E(e.pointToPage, {
|
|
147
332
|
xPt: t.xPt,
|
|
148
333
|
yPt: t.yPt + t.heightPt
|
|
149
334
|
}),
|
|
150
|
-
|
|
335
|
+
E(e.pointToPage, {
|
|
151
336
|
xPt: t.xPt + t.widthPt,
|
|
152
337
|
yPt: t.yPt + t.heightPt
|
|
153
338
|
})
|
|
@@ -159,10 +344,10 @@ function vt(e) {
|
|
|
159
344
|
heightPt: o - i
|
|
160
345
|
};
|
|
161
346
|
}
|
|
162
|
-
function
|
|
347
|
+
function R(e, t) {
|
|
163
348
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
164
349
|
}
|
|
165
|
-
function
|
|
350
|
+
function Rt(e, t) {
|
|
166
351
|
let n = !1;
|
|
167
352
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
168
353
|
let a = t[r], o = t[i];
|
|
@@ -170,35 +355,35 @@ function yt(e, t) {
|
|
|
170
355
|
}
|
|
171
356
|
return n;
|
|
172
357
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
358
|
+
function zt(e, t) {
|
|
359
|
+
return R(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? R(e.clip.rect, t) : Rt(t, e.clip.points) : !0 : !1;
|
|
175
360
|
}
|
|
176
|
-
function
|
|
361
|
+
function Bt(e, t, n) {
|
|
177
362
|
for (let n of e.clips) {
|
|
178
|
-
let e =
|
|
179
|
-
if (!e || !
|
|
363
|
+
let e = je(n.pointToPage, t);
|
|
364
|
+
if (!e || !R(n.bounds, e)) return !1;
|
|
180
365
|
}
|
|
181
|
-
return "drawing" in e ?
|
|
366
|
+
return "drawing" in e ? zt(e.drawing, n) : R(e.placement.bounds, n);
|
|
182
367
|
}
|
|
183
|
-
function
|
|
368
|
+
function z(e, t) {
|
|
184
369
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
185
370
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
371
|
+
function Vt(e) {
|
|
372
|
+
return z(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" : z(e, "image") ? "image" : null;
|
|
188
373
|
}
|
|
189
|
-
function
|
|
190
|
-
let o = "drawing" in e ?
|
|
374
|
+
function Ht(e, t, n, r, i, a) {
|
|
375
|
+
let o = "drawing" in e ? Vt(e.drawing) : e.placement.resourceKind;
|
|
191
376
|
if (!o) return null;
|
|
192
377
|
let s, c = !1, l, u;
|
|
193
378
|
if (o === "chart") {
|
|
194
|
-
let t = "drawing" in e ?
|
|
379
|
+
let t = "drawing" in e ? z(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = te(n.model, a);
|
|
195
380
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
196
381
|
} else if (o === "image") {
|
|
197
|
-
let t = "drawing" in e ?
|
|
382
|
+
let t = "drawing" in e ? z(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
|
|
198
383
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
199
384
|
l = n.mimeType;
|
|
200
385
|
} else {
|
|
201
|
-
let t =
|
|
386
|
+
let t = Mt(Nt(e), a);
|
|
202
387
|
s = t.text, c = t.truncated;
|
|
203
388
|
}
|
|
204
389
|
return {
|
|
@@ -208,8 +393,8 @@ function Ct(e, t, n, r, i, a) {
|
|
|
208
393
|
elementIndex: n,
|
|
209
394
|
elementType: o,
|
|
210
395
|
point: { ...r },
|
|
211
|
-
bounds:
|
|
212
|
-
source:
|
|
396
|
+
bounds: Lt(e),
|
|
397
|
+
source: Ft("drawing" in e ? e.drawing.source : e.source),
|
|
213
398
|
...s === void 0 ? {} : { text: s },
|
|
214
399
|
...l === void 0 ? {} : { mimeType: l },
|
|
215
400
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -219,26 +404,26 @@ function Ct(e, t, n, r, i, a) {
|
|
|
219
404
|
maxTextCharacters: a
|
|
220
405
|
};
|
|
221
406
|
}
|
|
222
|
-
function
|
|
407
|
+
function Ut(e, t, n, r, i = {}) {
|
|
223
408
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
224
|
-
let a =
|
|
409
|
+
let a = Pt(i.maxTextCharacters), o = Fe(e, t);
|
|
225
410
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
226
|
-
let i = o[e], s =
|
|
227
|
-
if (!s || !
|
|
228
|
-
let c =
|
|
411
|
+
let i = o[e], s = je(i.pointToPage, n);
|
|
412
|
+
if (!s || !Bt(i, n, s)) continue;
|
|
413
|
+
let c = Ht(i, t, e, n, r, a);
|
|
229
414
|
if (c) return c;
|
|
230
415
|
}
|
|
231
416
|
return null;
|
|
232
417
|
}
|
|
233
|
-
function
|
|
234
|
-
return
|
|
418
|
+
function Wt(e, t, n, r) {
|
|
419
|
+
return Ut(Xe(e, {
|
|
235
420
|
currentDate: r.currentDate,
|
|
236
421
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
237
422
|
showTrackedChanges: r.showTrackedChanges
|
|
238
|
-
}, t).layout, t, n,
|
|
423
|
+
}, t).layout, t, n, De(e), r);
|
|
239
424
|
}
|
|
240
|
-
function
|
|
241
|
-
let n =
|
|
425
|
+
function Gt(e, t) {
|
|
426
|
+
let n = Pt(t), r = e.text === void 0 ? void 0 : jt(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
|
|
242
427
|
return {
|
|
243
428
|
...structuredClone(e),
|
|
244
429
|
...r === void 0 ? {} : { text: r },
|
|
@@ -250,20 +435,20 @@ function Et(e, t) {
|
|
|
250
435
|
}
|
|
251
436
|
//#endregion
|
|
252
437
|
//#region packages/docx/src/revisions.ts
|
|
253
|
-
function
|
|
254
|
-
let t =
|
|
438
|
+
function B(e) {
|
|
439
|
+
let t = st(e.id);
|
|
255
440
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
256
441
|
}
|
|
257
|
-
function
|
|
442
|
+
function V(e) {
|
|
258
443
|
return Object.freeze({
|
|
259
444
|
...e,
|
|
260
445
|
path: Object.freeze([...e.path])
|
|
261
446
|
});
|
|
262
447
|
}
|
|
263
|
-
function
|
|
448
|
+
function Kt(e, t) {
|
|
264
449
|
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
450
|
}
|
|
266
|
-
function
|
|
451
|
+
function qt(e, t) {
|
|
267
452
|
let n = 0, r = e.length;
|
|
268
453
|
for (; n < r;) {
|
|
269
454
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -271,22 +456,22 @@ function V(e, t) {
|
|
|
271
456
|
}
|
|
272
457
|
return n;
|
|
273
458
|
}
|
|
274
|
-
function
|
|
459
|
+
function Jt(e, t) {
|
|
275
460
|
let n = Array(e.length), r;
|
|
276
461
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
277
462
|
n[i] = r;
|
|
278
|
-
let a = e[i], o = t.get(
|
|
463
|
+
let a = e[i], o = t.get(j(a.source))?.[0];
|
|
279
464
|
o !== void 0 && (r = Object.freeze({
|
|
280
|
-
source:
|
|
465
|
+
source: V(a.source),
|
|
281
466
|
sourceRunIndex: o
|
|
282
467
|
}));
|
|
283
468
|
}
|
|
284
469
|
let i = Array(e.length), a;
|
|
285
470
|
for (let n = 0; n < e.length; n += 1) {
|
|
286
471
|
i[n] = a;
|
|
287
|
-
let r = e[n], o = t.get(
|
|
472
|
+
let r = e[n], o = t.get(j(r.source))?.at(-1);
|
|
288
473
|
o !== void 0 && (a = Object.freeze({
|
|
289
|
-
source:
|
|
474
|
+
source: V(r.source),
|
|
290
475
|
sourceRunIndex: o
|
|
291
476
|
}));
|
|
292
477
|
}
|
|
@@ -295,17 +480,17 @@ function Ot(e, t) {
|
|
|
295
480
|
preceding: i
|
|
296
481
|
};
|
|
297
482
|
}
|
|
298
|
-
function
|
|
299
|
-
let o = r[e], s = i.get(
|
|
483
|
+
function Yt(e, t, n, r, i, a) {
|
|
484
|
+
let o = r[e], s = i.get(j(o.source)) ?? [], c = s[qt(s, n)], l = s[qt(s, t) - 1], u = c ?? l;
|
|
300
485
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
301
|
-
source:
|
|
486
|
+
source: V(o.source),
|
|
302
487
|
sourceRunIndex: u
|
|
303
488
|
});
|
|
304
489
|
}
|
|
305
|
-
function
|
|
490
|
+
function Xt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
306
491
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
307
492
|
e.forEach((e, t) => {
|
|
308
|
-
let n =
|
|
493
|
+
let n = B(e);
|
|
309
494
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
310
495
|
});
|
|
311
496
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -315,11 +500,11 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
315
500
|
source: e,
|
|
316
501
|
runs: n.runs
|
|
317
502
|
}] : [];
|
|
318
|
-
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s =
|
|
503
|
+
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Jt(a, o), c = [];
|
|
319
504
|
for (let [e, t] of a.entries()) {
|
|
320
505
|
let n = 0;
|
|
321
506
|
for (; n < t.runs.length;) {
|
|
322
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
507
|
+
let i = t.runs[n], l = i.revision?.kind ? B({
|
|
323
508
|
kind: i.revision.kind,
|
|
324
509
|
id: i.revision.id
|
|
325
510
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -330,16 +515,16 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
330
515
|
let d = n;
|
|
331
516
|
for (n += 1; n < t.runs.length;) {
|
|
332
517
|
let e = t.runs[n].revision;
|
|
333
|
-
if (!e?.kind ||
|
|
518
|
+
if (!e?.kind || B({
|
|
334
519
|
kind: e.kind,
|
|
335
520
|
id: e.id
|
|
336
521
|
}) !== l) break;
|
|
337
522
|
n += 1;
|
|
338
523
|
}
|
|
339
|
-
let f = n, p = o.get(
|
|
524
|
+
let f = n, p = o.get(j(t.source)) ?? [], m = (p[qt(p, d)] ?? f) < f ? void 0 : Yt(e, d, f, a, o, s);
|
|
340
525
|
c.push(Object.freeze({
|
|
341
526
|
revisionIndex: u,
|
|
342
|
-
source:
|
|
527
|
+
source: V(t.source),
|
|
343
528
|
startRunIndex: d,
|
|
344
529
|
endRunIndex: f,
|
|
345
530
|
...m === void 0 ? {} : { geometryFallback: m }
|
|
@@ -348,26 +533,26 @@ function At(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
348
533
|
}
|
|
349
534
|
return c;
|
|
350
535
|
}
|
|
351
|
-
function
|
|
536
|
+
function Zt(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
352
537
|
if ((e?.length ?? 0) === 0) return [];
|
|
353
|
-
let i =
|
|
538
|
+
let i = Xt(e ?? [], t, n), a = r.completedSourceKeys;
|
|
354
539
|
return a === void 0 ? i : i.filter((e) => {
|
|
355
|
-
let t = n.get(
|
|
356
|
-
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(
|
|
540
|
+
let t = n.get(j(e.source));
|
|
541
|
+
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(j(e.source));
|
|
357
542
|
});
|
|
358
543
|
}
|
|
359
|
-
function
|
|
360
|
-
let n = t.filter((t) => t.sourceRunIndex !== void 0 &&
|
|
544
|
+
function Qt(e, t) {
|
|
545
|
+
let n = t.filter((t) => t.sourceRunIndex !== void 0 && Kt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
|
|
361
546
|
if (n.length > 0) return n;
|
|
362
547
|
let r = e.geometryFallback;
|
|
363
|
-
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex &&
|
|
548
|
+
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && Kt(e.source, r.source));
|
|
364
549
|
}
|
|
365
550
|
//#endregion
|
|
366
551
|
//#region packages/docx/src/layout/progressive.ts
|
|
367
|
-
var
|
|
368
|
-
async function
|
|
552
|
+
var $t = 12;
|
|
553
|
+
async function en(e, t, n, r = {}) {
|
|
369
554
|
let { onPreview: i, scheduler: a } = r;
|
|
370
|
-
return
|
|
555
|
+
return ze(Ne(e, t, n, i && e.sequence.length > $t ? { onPages: (e, t) => {
|
|
371
556
|
i(Object.freeze({
|
|
372
557
|
layout: e,
|
|
373
558
|
exact: !1,
|
|
@@ -388,7 +573,7 @@ function U(e, t) {
|
|
|
388
573
|
} catch {}
|
|
389
574
|
}
|
|
390
575
|
}
|
|
391
|
-
function
|
|
576
|
+
function tn(e, t, n, r) {
|
|
392
577
|
let i = H.get(e);
|
|
393
578
|
i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
|
|
394
579
|
let a = Object.freeze({
|
|
@@ -409,30 +594,30 @@ function Ft(e, t, n, r) {
|
|
|
409
594
|
}
|
|
410
595
|
//#endregion
|
|
411
596
|
//#region packages/docx/src/document-layout-view.ts
|
|
412
|
-
var W = /* @__PURE__ */ new WeakMap(),
|
|
597
|
+
var W = /* @__PURE__ */ new WeakMap(), nn = /* @__PURE__ */ new WeakMap(), rn = Symbol("docxLayoutViewRequester");
|
|
413
598
|
function G(e) {
|
|
414
|
-
let t =
|
|
599
|
+
let t = D(e), n = t.activeLayoutOptions;
|
|
415
600
|
return {
|
|
416
601
|
showTrackedChanges: n?.showTrackedChanges === !0,
|
|
417
602
|
currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
|
|
418
603
|
};
|
|
419
604
|
}
|
|
420
605
|
async function K(e, t, n) {
|
|
421
|
-
let r =
|
|
606
|
+
let r = D(e), i = ke(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
422
607
|
showTrackedChanges: i.showTrackedChanges === !0,
|
|
423
608
|
currentDate: i.currentDateMs
|
|
424
609
|
}), o = {
|
|
425
610
|
showTrackedChanges: a.showTrackedChanges,
|
|
426
611
|
currentDate: a.currentDate,
|
|
427
|
-
[
|
|
612
|
+
[rn]: n
|
|
428
613
|
};
|
|
429
614
|
await e.setLayoutView(o);
|
|
430
615
|
let s = G(e);
|
|
431
616
|
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
432
617
|
}
|
|
433
|
-
function
|
|
434
|
-
let n = Object.freeze({ ...G(e) }), r = (
|
|
435
|
-
|
|
618
|
+
function an(e, t) {
|
|
619
|
+
let n = Object.freeze({ ...G(e) }), r = (nn.get(e) ?? 0) + 1;
|
|
620
|
+
nn.set(e, r);
|
|
436
621
|
let i = Object.freeze({
|
|
437
622
|
view: n,
|
|
438
623
|
generation: r,
|
|
@@ -446,7 +631,7 @@ function Rt(e, t) {
|
|
|
446
631
|
} catch {}
|
|
447
632
|
}
|
|
448
633
|
}
|
|
449
|
-
function
|
|
634
|
+
function on(e, t, n) {
|
|
450
635
|
let r = W.get(e);
|
|
451
636
|
r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
|
|
452
637
|
let i = Object.freeze({
|
|
@@ -459,10 +644,10 @@ function zt(e, t, n) {
|
|
|
459
644
|
}
|
|
460
645
|
//#endregion
|
|
461
646
|
//#region packages/docx/src/document.ts
|
|
462
|
-
function
|
|
647
|
+
function sn(e, t) {
|
|
463
648
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
464
649
|
}
|
|
465
|
-
function
|
|
650
|
+
function cn() {
|
|
466
651
|
let e, t;
|
|
467
652
|
return {
|
|
468
653
|
promise: new Promise((n, r) => {
|
|
@@ -472,22 +657,23 @@ function Vt() {
|
|
|
472
657
|
reject: t
|
|
473
658
|
};
|
|
474
659
|
}
|
|
475
|
-
var
|
|
660
|
+
var ln = Object.freeze([]), un = Object.freeze([]), dn = Object.freeze({
|
|
476
661
|
comments: Object.freeze([]),
|
|
477
662
|
revisions: Object.freeze([])
|
|
478
663
|
});
|
|
479
664
|
function q(e, t) {
|
|
480
|
-
return
|
|
665
|
+
return Ve({
|
|
481
666
|
comments: e,
|
|
482
667
|
revisions: t
|
|
483
668
|
}, "DOCX review metadata");
|
|
484
669
|
}
|
|
485
670
|
var J = class e {
|
|
486
671
|
_metrics = null;
|
|
672
|
+
_cjkFallback = "jp";
|
|
487
673
|
_document = null;
|
|
488
674
|
_source = null;
|
|
489
675
|
_meta = null;
|
|
490
|
-
_review =
|
|
676
|
+
_review = dn;
|
|
491
677
|
_layoutLifecycle = new be();
|
|
492
678
|
_layoutObservers = new Ce();
|
|
493
679
|
_layoutCompletion = null;
|
|
@@ -508,20 +694,19 @@ var J = class e {
|
|
|
508
694
|
_tiff;
|
|
509
695
|
_worker;
|
|
510
696
|
_bridge;
|
|
511
|
-
_rawParts = new
|
|
697
|
+
_rawParts = new ot({
|
|
512
698
|
maxEntries: 64,
|
|
513
|
-
maxBytes:
|
|
699
|
+
maxBytes: n
|
|
514
700
|
});
|
|
515
701
|
_embeddedFontFaces = [];
|
|
516
702
|
_googleFontFaces = [];
|
|
517
|
-
_localMetricFontFaces = [];
|
|
518
703
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
519
|
-
constructor(e, n, r
|
|
520
|
-
this._worker = e, this._mode =
|
|
704
|
+
constructor(e, t, n, r) {
|
|
705
|
+
this._worker = e, this._mode = t, Oe(this, n), this._bridge = new me(this._worker, {
|
|
521
706
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
522
707
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
523
708
|
toError: (e) => {
|
|
524
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
709
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(a(e), {
|
|
525
710
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
526
711
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
527
712
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -529,128 +714,131 @@ var J = class e {
|
|
|
529
714
|
});
|
|
530
715
|
}
|
|
531
716
|
});
|
|
532
|
-
let
|
|
717
|
+
let i = new URL(r ?? Tt, location.href).href;
|
|
533
718
|
this._bridge.post({
|
|
534
719
|
type: "init",
|
|
535
|
-
wasmUrl:
|
|
720
|
+
wasmUrl: i
|
|
536
721
|
});
|
|
537
722
|
}
|
|
538
|
-
static async load(t,
|
|
539
|
-
let i = a(
|
|
723
|
+
static async load(t, n = {}) {
|
|
724
|
+
let i = $e(n.cjkFallback), a = f(n), o = Date.now(), s = n.mode ?? "main", c = new r({
|
|
540
725
|
enabled: !0,
|
|
541
726
|
format: "docx",
|
|
542
727
|
mode: s,
|
|
543
|
-
policy:
|
|
544
|
-
onMetrics:
|
|
545
|
-
emitToConsole:
|
|
728
|
+
policy: a.policy,
|
|
729
|
+
onMetrics: a.onResourceMetrics,
|
|
730
|
+
emitToConsole: a.debug
|
|
546
731
|
});
|
|
547
732
|
try {
|
|
548
733
|
if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
549
|
-
let
|
|
734
|
+
let r;
|
|
550
735
|
if (typeof t == "string") {
|
|
551
736
|
let e = await fetch(t);
|
|
552
737
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
553
|
-
|
|
554
|
-
} else
|
|
555
|
-
|
|
556
|
-
let
|
|
738
|
+
r = await e.arrayBuffer();
|
|
739
|
+
} else r = t;
|
|
740
|
+
r = g(await h(r, n.password)), c.setSourceBytes(r.byteLength), c.checkpoint("container ready");
|
|
741
|
+
let l = s === "worker" ? (await import("./render-worker-host-IkHrYOci.js")).createRenderWorker() : new wt(), u = s === "worker" ? it(n) : void 0, d = s === "worker" && !!n.progressiveLayout, f;
|
|
557
742
|
try {
|
|
558
|
-
|
|
559
|
-
let t =
|
|
560
|
-
|
|
561
|
-
onPartial:
|
|
562
|
-
onComplete:
|
|
563
|
-
onProgress:
|
|
564
|
-
layoutOptions:
|
|
743
|
+
f = new e(l, s, o, n.wasmUrl), f._metrics = c, f._cjkFallback = i;
|
|
744
|
+
let t = D(f), p = ke(n.currentDate, t.defaultCurrentDateMs, n.showTrackedChanges === !0);
|
|
745
|
+
t.activeLayoutOptions = p, await f._parse(r, a.policy, s === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => c.observeUsage(e), u, d ? {
|
|
746
|
+
onPartial: n.onLayoutPartial,
|
|
747
|
+
onComplete: n.onLayoutComplete,
|
|
748
|
+
onProgress: n.onLayoutProgress,
|
|
749
|
+
layoutOptions: p,
|
|
565
750
|
abort: new AbortController(),
|
|
566
|
-
firstPublication:
|
|
751
|
+
firstPublication: cn(),
|
|
567
752
|
published: !1,
|
|
568
753
|
settled: !1
|
|
569
|
-
} : void 0), s === "worker" &&
|
|
570
|
-
|
|
571
|
-
|
|
754
|
+
} : void 0), s === "worker" && f._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.")), n.math && f._mode === "worker" && !u?.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."), n.threeD && f._mode === "worker" && !u?.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."), f._threeD = f._mode === "worker" ? void 0 : n.threeD, n.regionMap && f._mode === "worker" && !u?.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."), f._regionMap = f._mode === "worker" ? void 0 : n.regionMap, n.chartEx && f._mode === "worker" && !u?.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."), f._chartEx = f._mode === "worker" ? void 0 : n.chartEx, n.tiff && f._mode === "worker" && !u?.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."), f._tiff = f._mode === "worker" ? void 0 : n.tiff, f._mode === "main" && n.useGoogleFonts && f._document && (f._googleFontFaces = await m(Re(f._document, i), Le));
|
|
755
|
+
let h;
|
|
756
|
+
if (f._mode === "main" && f._document?.embeddedFonts?.length) {
|
|
757
|
+
let e = f, t = await Dt(f._document, (t) => e.getFontBytes(t));
|
|
758
|
+
f._embeddedFontFaces = t.faces, h = t.metrics;
|
|
572
759
|
}
|
|
573
|
-
let
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
useGoogleFonts: !!
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
760
|
+
let g;
|
|
761
|
+
if (f._mode === "main" && n.math && f._document && Ke(f._document) && (g = await Je(f._document, n.math)), f._mode === "main" && f._document && f._source) {
|
|
762
|
+
let e = f, t = D(f);
|
|
763
|
+
t.services = Ue(f._source, {
|
|
764
|
+
fontMetrics: h,
|
|
765
|
+
measureResolvedFontMetrics: !0,
|
|
766
|
+
resolvedFontMetricCandidates: qe(f._document, f._source.fontFamilyCharsets),
|
|
767
|
+
useGoogleFonts: !!n.useGoogleFonts,
|
|
768
|
+
cjkFallback: i,
|
|
769
|
+
embeddedFaces: f._embeddedFontFaces,
|
|
770
|
+
googleFaces: f._googleFontFaces,
|
|
771
|
+
mathResources: g?.records,
|
|
772
|
+
mathDrawables: g?.drawables
|
|
585
773
|
});
|
|
586
|
-
let
|
|
587
|
-
if (!
|
|
588
|
-
let
|
|
589
|
-
if (
|
|
590
|
-
let e =
|
|
591
|
-
t._layoutAbort =
|
|
592
|
-
let
|
|
593
|
-
t._layoutCompletion =
|
|
774
|
+
let r = t.services, a = Pe(f._source, r, t.defaultCurrentDateMs), o = f._source.fatalParse === null, s = t.activeLayoutOptions;
|
|
775
|
+
if (!s) throw Error("Active layout view was not recorded at load");
|
|
776
|
+
let c = { onProgress: n.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", n.onLayoutProgress, { committedUnits: t }) : void 0 };
|
|
777
|
+
if (o && n.progressiveLayout) {
|
|
778
|
+
let e = a.layoutVariants, t = f, i = new AbortController();
|
|
779
|
+
t._layoutAbort = i;
|
|
780
|
+
let o = cn(), l = null, u = !0;
|
|
781
|
+
t._layoutCompletion = en(f._source.bodyLayoutInput, r, s, {
|
|
594
782
|
scheduler: {
|
|
595
|
-
...
|
|
596
|
-
signal:
|
|
783
|
+
...c,
|
|
784
|
+
signal: i.signal
|
|
597
785
|
},
|
|
598
|
-
onPreview: (
|
|
786
|
+
onPreview: (r) => {
|
|
599
787
|
if (!u) return;
|
|
600
|
-
let i = l === null, a = t._replaceMainLayoutPublication(e,
|
|
788
|
+
let i = l === null, a = t._replaceMainLayoutPublication(e, s, l, r.layout);
|
|
601
789
|
if (a === null) {
|
|
602
790
|
u = !1;
|
|
603
791
|
return;
|
|
604
792
|
}
|
|
605
793
|
if (l = a, i) t._layoutLifecycle.begin(), U(t, {
|
|
606
|
-
pageCount:
|
|
607
|
-
exact:
|
|
794
|
+
pageCount: r.layout.pages.length,
|
|
795
|
+
exact: r.exact,
|
|
608
796
|
complete: !1
|
|
609
|
-
}),
|
|
797
|
+
}), o.resolve();
|
|
610
798
|
else {
|
|
611
|
-
if (!t._isLayoutViewActive(
|
|
799
|
+
if (!t._isLayoutViewActive(s)) return;
|
|
612
800
|
U(t, {
|
|
613
|
-
pageCount:
|
|
614
|
-
exact:
|
|
801
|
+
pageCount: r.layout.pages.length,
|
|
802
|
+
exact: r.exact,
|
|
615
803
|
complete: !1
|
|
616
|
-
}), t._layoutObservers.notify("onLayoutPartial",
|
|
617
|
-
availableUnits:
|
|
618
|
-
exact:
|
|
804
|
+
}), t._layoutObservers.notify("onLayoutPartial", n.onLayoutPartial, {
|
|
805
|
+
availableUnits: r.layout.pages.length,
|
|
806
|
+
exact: r.exact
|
|
619
807
|
});
|
|
620
808
|
}
|
|
621
809
|
}
|
|
622
|
-
}).then((
|
|
623
|
-
u && t._replaceMainLayoutPublication(e,
|
|
810
|
+
}).then((r) => {
|
|
811
|
+
u && t._replaceMainLayoutPublication(e, s, l, r) === null && (u = !1), t._layoutLifecycle.succeed(), U(t, {
|
|
624
812
|
pageCount: t.pageCount,
|
|
625
813
|
exact: !0,
|
|
626
814
|
complete: !0
|
|
627
|
-
}),
|
|
815
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete), o.resolve();
|
|
628
816
|
}).catch((e) => {
|
|
629
817
|
if (l === null) {
|
|
630
|
-
|
|
818
|
+
o.reject(e);
|
|
631
819
|
return;
|
|
632
820
|
}
|
|
633
|
-
if (e instanceof
|
|
821
|
+
if (e instanceof Be) {
|
|
634
822
|
t._layoutLifecycle.succeed();
|
|
635
823
|
return;
|
|
636
824
|
}
|
|
637
|
-
let
|
|
825
|
+
let r = t._layoutLifecycle.fail(e);
|
|
638
826
|
U(t, {
|
|
639
827
|
pageCount: t.pageCount,
|
|
640
828
|
exact: !1,
|
|
641
829
|
complete: !1,
|
|
642
|
-
error:
|
|
643
|
-
}), t._layoutObservers.notify("onLayoutComplete",
|
|
644
|
-
}), await
|
|
645
|
-
} else if (
|
|
646
|
-
let e = await
|
|
647
|
-
|
|
648
|
-
} else
|
|
830
|
+
error: r
|
|
831
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete, r);
|
|
832
|
+
}), await o.promise;
|
|
833
|
+
} else if (o && (n.sliceLayout || n.onLayoutProgress)) {
|
|
834
|
+
let e = await We(f._source.bodyLayoutInput, r, s, c);
|
|
835
|
+
a.layoutVariants.prime(s, e);
|
|
836
|
+
} else a.layoutVariants.layoutFor(s);
|
|
649
837
|
}
|
|
650
|
-
return await
|
|
838
|
+
return await f._resourceUsage(n.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: f.pageCount }), f;
|
|
651
839
|
} catch (e) {
|
|
652
|
-
let t =
|
|
653
|
-
throw p(
|
|
840
|
+
let t = f;
|
|
841
|
+
throw p(l, t ? () => t.destroy() : void 0), e;
|
|
654
842
|
}
|
|
655
843
|
} catch (e) {
|
|
656
844
|
throw c.fail(e), e;
|
|
@@ -667,7 +855,8 @@ var J = class e {
|
|
|
667
855
|
data: e,
|
|
668
856
|
resourcePolicy: t,
|
|
669
857
|
useGoogleFonts: n,
|
|
670
|
-
|
|
858
|
+
cjkFallback: this._cjkFallback,
|
|
859
|
+
defaultCurrentDateMs: D(this).defaultCurrentDateMs,
|
|
671
860
|
...this._parseViewFields(),
|
|
672
861
|
renderers: a
|
|
673
862
|
} : {
|
|
@@ -678,14 +867,14 @@ var J = class e {
|
|
|
678
867
|
}, [e], { timeoutMs: r });
|
|
679
868
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
680
869
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
681
|
-
let e = await
|
|
870
|
+
let e = await Ge(this._bridge.transport(O), s, {
|
|
682
871
|
timeoutMs: r,
|
|
683
872
|
onUsage: i
|
|
684
873
|
});
|
|
685
874
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
686
875
|
} else this._meta = s.meta;
|
|
687
876
|
else {
|
|
688
|
-
let e = s, t = await
|
|
877
|
+
let e = s, t = await Ge(this._bridge.transport(O), e, {
|
|
689
878
|
timeoutMs: r,
|
|
690
879
|
onUsage: i
|
|
691
880
|
});
|
|
@@ -694,7 +883,7 @@ var J = class e {
|
|
|
694
883
|
this._review = q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []);
|
|
695
884
|
}
|
|
696
885
|
_onWorkerLayoutPush(e) {
|
|
697
|
-
if (
|
|
886
|
+
if (v((e, t) => this._worker.postMessage(e, t), e) || !("forId" in e) || e.forId !== this._parseRequestId) return;
|
|
698
887
|
this._rearmParseWatchdog();
|
|
699
888
|
let t = this._progressive;
|
|
700
889
|
if (t?.settled) return;
|
|
@@ -756,7 +945,7 @@ var J = class e {
|
|
|
756
945
|
pageCount: this.pageCount,
|
|
757
946
|
exact: !0,
|
|
758
947
|
complete: !0
|
|
759
|
-
}), t.firstPublication.resolve(),
|
|
948
|
+
}), t.firstPublication.resolve(), this._layoutObservers.notify("onLayoutComplete", t.onComplete));
|
|
760
949
|
}
|
|
761
950
|
}
|
|
762
951
|
_invalidateLayoutDerivedCaches() {
|
|
@@ -767,7 +956,7 @@ var J = class e {
|
|
|
767
956
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
768
957
|
}
|
|
769
958
|
_isLayoutViewActive(e) {
|
|
770
|
-
return
|
|
959
|
+
return sn(D(this).activeLayoutOptions, e);
|
|
771
960
|
}
|
|
772
961
|
_rearmParseWatchdog() {
|
|
773
962
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -796,7 +985,7 @@ var J = class e {
|
|
|
796
985
|
}), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
|
|
797
986
|
}
|
|
798
987
|
_parseViewFields() {
|
|
799
|
-
let e =
|
|
988
|
+
let e = D(this), t = e.activeLayoutOptions;
|
|
800
989
|
return t ? {
|
|
801
990
|
...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
|
|
802
991
|
...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
|
|
@@ -809,7 +998,8 @@ var J = class e {
|
|
|
809
998
|
data: e,
|
|
810
999
|
resourcePolicy: t,
|
|
811
1000
|
useGoogleFonts: n,
|
|
812
|
-
|
|
1001
|
+
cjkFallback: this._cjkFallback,
|
|
1002
|
+
defaultCurrentDateMs: D(this).defaultCurrentDateMs,
|
|
813
1003
|
...this._parseViewFields(),
|
|
814
1004
|
renderers: a,
|
|
815
1005
|
progressiveLayout: !0
|
|
@@ -817,7 +1007,7 @@ var J = class e {
|
|
|
817
1007
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
818
1008
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
819
1009
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
820
|
-
let t = await
|
|
1010
|
+
let t = await Ge(this._bridge.transport(O), e, {
|
|
821
1011
|
timeoutMs: r,
|
|
822
1012
|
onUsage: i
|
|
823
1013
|
});
|
|
@@ -836,7 +1026,7 @@ var J = class e {
|
|
|
836
1026
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
837
1027
|
}
|
|
838
1028
|
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 =
|
|
1029
|
+
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 = dn, D(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (ye(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (_(this._googleFontFaces), this._googleFontFaces = []), s(this._fetchImage), l(this._fetchImage);
|
|
840
1030
|
}
|
|
841
1031
|
async getImage(e, t) {
|
|
842
1032
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -865,7 +1055,7 @@ var J = class e {
|
|
|
865
1055
|
async getResourceMetrics() {
|
|
866
1056
|
let e = this._metrics;
|
|
867
1057
|
if (!e) throw Error("Document not loaded");
|
|
868
|
-
return
|
|
1058
|
+
return i(e, (e) => this._resourceUsage(e));
|
|
869
1059
|
}
|
|
870
1060
|
async toMarkdown() {
|
|
871
1061
|
return (await this._bridge.request((e) => ({
|
|
@@ -897,32 +1087,32 @@ var J = class e {
|
|
|
897
1087
|
return this._reviewSnapshot().revisions;
|
|
898
1088
|
}
|
|
899
1089
|
commentAnchorRanges() {
|
|
900
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
1090
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? ln;
|
|
901
1091
|
if (!this._document || !this._source) return [];
|
|
902
1092
|
let e = this._reviewSnapshot().comments;
|
|
903
|
-
if (e.length === 0) return
|
|
904
|
-
let t =
|
|
1093
|
+
if (e.length === 0) return ln;
|
|
1094
|
+
let t = D(this), n = t.services;
|
|
905
1095
|
if (!n) throw Error("Document layout services are not initialized");
|
|
906
|
-
let r =
|
|
1096
|
+
let r = He(n);
|
|
907
1097
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
908
1098
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
909
|
-
this._reviewProjectionIndex ??=
|
|
1099
|
+
this._reviewProjectionIndex ??= Ze(a);
|
|
910
1100
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
911
|
-
return this._commentAnchorRanges ??=
|
|
1101
|
+
return this._commentAnchorRanges ??= lt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
912
1102
|
}
|
|
913
1103
|
revisionAnchorRanges() {
|
|
914
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
1104
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? un;
|
|
915
1105
|
if (!this._document || !this._source) return [];
|
|
916
1106
|
let e = this._reviewSnapshot().revisions;
|
|
917
|
-
if (e.length === 0) return
|
|
918
|
-
let t =
|
|
1107
|
+
if (e.length === 0) return un;
|
|
1108
|
+
let t = D(this), n = t.services;
|
|
919
1109
|
if (!n) throw Error("Document layout services are not initialized");
|
|
920
|
-
let r =
|
|
1110
|
+
let r = He(n);
|
|
921
1111
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
922
1112
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
923
|
-
this._reviewProjectionIndex ??=
|
|
1113
|
+
this._reviewProjectionIndex ??= Ze(a);
|
|
924
1114
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
925
|
-
return this._revisionAnchorRanges ??=
|
|
1115
|
+
return this._revisionAnchorRanges ??= Zt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
926
1116
|
}
|
|
927
1117
|
_reviewSnapshot() {
|
|
928
1118
|
return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
@@ -935,16 +1125,16 @@ var J = class e {
|
|
|
935
1125
|
}
|
|
936
1126
|
_getLayout() {
|
|
937
1127
|
if (!this._document) return null;
|
|
938
|
-
let e =
|
|
1128
|
+
let e = D(this), t = e.services;
|
|
939
1129
|
if (!t) throw Error("Document layout services are not initialized");
|
|
940
|
-
let n =
|
|
1130
|
+
let n = He(t);
|
|
941
1131
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
942
1132
|
let r = e.activeLayoutOptions;
|
|
943
1133
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
944
1134
|
}
|
|
945
1135
|
async setLayoutView(e = {}) {
|
|
946
|
-
let t = e[
|
|
947
|
-
if (!
|
|
1136
|
+
let t = e[rn], n = D(this), r = ke(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
|
|
1137
|
+
if (!sn(a, r)) {
|
|
948
1138
|
if (this._mode === "worker" && this._meta) {
|
|
949
1139
|
let e = await this._bridge.request((e) => ({
|
|
950
1140
|
type: "selectLayoutView",
|
|
@@ -957,17 +1147,17 @@ var J = class e {
|
|
|
957
1147
|
n.activeLayoutOptions = r, this._meta = {
|
|
958
1148
|
...this._meta,
|
|
959
1149
|
...a.meta
|
|
960
|
-
}, this._invalidateLayoutDerivedCaches(),
|
|
1150
|
+
}, this._invalidateLayoutDerivedCaches(), an(this, t);
|
|
961
1151
|
return;
|
|
962
1152
|
}
|
|
963
|
-
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(),
|
|
1153
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), an(this, t);
|
|
964
1154
|
}
|
|
965
1155
|
}
|
|
966
1156
|
_getBookmarkPages() {
|
|
967
1157
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
968
1158
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
969
1159
|
let e = this._getLayout();
|
|
970
|
-
return e ? (this._bookmarkPages =
|
|
1160
|
+
return e ? (this._bookmarkPages = Et(e), this._bookmarkPages) : null;
|
|
971
1161
|
}
|
|
972
1162
|
getBookmarkPage(e) {
|
|
973
1163
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -999,7 +1189,7 @@ var J = class e {
|
|
|
999
1189
|
};
|
|
1000
1190
|
}
|
|
1001
1191
|
_withActiveView(e) {
|
|
1002
|
-
let t =
|
|
1192
|
+
let t = D(this).activeLayoutOptions;
|
|
1003
1193
|
if (!t) return e;
|
|
1004
1194
|
let n = { ...e };
|
|
1005
1195
|
return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
|
|
@@ -1007,21 +1197,21 @@ var J = class e {
|
|
|
1007
1197
|
renderPage(e, t, n = {}) {
|
|
1008
1198
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1009
1199
|
if (!this._source) throw Error("Document not loaded");
|
|
1010
|
-
return
|
|
1200
|
+
return Ie(this._source, e, t, {
|
|
1011
1201
|
...this._withActiveView(n),
|
|
1012
1202
|
fetchImage: this._fetchImage,
|
|
1013
|
-
layoutServices:
|
|
1014
|
-
defaultCurrentDateMs:
|
|
1203
|
+
layoutServices: D(this).services ?? void 0,
|
|
1204
|
+
defaultCurrentDateMs: D(this).defaultCurrentDateMs,
|
|
1015
1205
|
threeD: this._threeD,
|
|
1016
1206
|
regionMap: this._regionMap,
|
|
1017
1207
|
chartEx: this._chartEx,
|
|
1018
1208
|
tiff: this._tiff
|
|
1019
1209
|
});
|
|
1020
1210
|
}
|
|
1021
|
-
async renderPageToBitmap(e,
|
|
1022
|
-
let { onTextRun:
|
|
1023
|
-
...this._withActiveView(
|
|
1024
|
-
dpr:
|
|
1211
|
+
async renderPageToBitmap(e, n = {}) {
|
|
1212
|
+
let { onTextRun: r, ...i } = n, a = {
|
|
1213
|
+
...this._withActiveView(i),
|
|
1214
|
+
dpr: i.dpr ?? t()
|
|
1025
1215
|
};
|
|
1026
1216
|
if (this._mode === "worker") {
|
|
1027
1217
|
let t = await this._bridge.request((t) => ({
|
|
@@ -1031,17 +1221,17 @@ var J = class e {
|
|
|
1031
1221
|
opts: a
|
|
1032
1222
|
}));
|
|
1033
1223
|
try {
|
|
1034
|
-
if (
|
|
1224
|
+
if (r) for (let e of t.runs) r(e);
|
|
1035
1225
|
} catch (e) {
|
|
1036
|
-
throw
|
|
1226
|
+
throw o(t.bitmap), e;
|
|
1037
1227
|
}
|
|
1038
1228
|
return t.bitmap;
|
|
1039
1229
|
}
|
|
1040
|
-
let
|
|
1041
|
-
return await this.renderPage(
|
|
1230
|
+
let s = new OffscreenCanvas(1, 1);
|
|
1231
|
+
return await this.renderPage(s, e, {
|
|
1042
1232
|
...a,
|
|
1043
|
-
onTextRun:
|
|
1044
|
-
}),
|
|
1233
|
+
onTextRun: r
|
|
1234
|
+
}), s.transferToImageBitmap();
|
|
1045
1235
|
}
|
|
1046
1236
|
async collectPageRuns(e, t = {}) {
|
|
1047
1237
|
let n = { ...this._withActiveView(t) };
|
|
@@ -1051,9 +1241,9 @@ var J = class e {
|
|
|
1051
1241
|
pageIndex: e,
|
|
1052
1242
|
opts: n
|
|
1053
1243
|
}))).runs;
|
|
1054
|
-
let r =
|
|
1244
|
+
let r = D(this), i = r.services;
|
|
1055
1245
|
if (!i) throw Error("Document layout services are not initialized");
|
|
1056
|
-
return
|
|
1246
|
+
return Qe(i, e, {
|
|
1057
1247
|
currentDate: n.currentDate,
|
|
1058
1248
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
1059
1249
|
width: n.width,
|
|
@@ -1062,7 +1252,7 @@ var J = class e {
|
|
|
1062
1252
|
}
|
|
1063
1253
|
async getCommentThreads(e, t = {}) {
|
|
1064
1254
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1065
|
-
return
|
|
1255
|
+
return ct(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1066
1256
|
}
|
|
1067
1257
|
async getElementContextAt(e, t, n = {}) {
|
|
1068
1258
|
let r = this._withActiveView(n);
|
|
@@ -1073,9 +1263,9 @@ var J = class e {
|
|
|
1073
1263
|
point: t,
|
|
1074
1264
|
opts: r
|
|
1075
1265
|
}))).context;
|
|
1076
|
-
let i =
|
|
1266
|
+
let i = D(this), a = i.services;
|
|
1077
1267
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1078
|
-
return
|
|
1268
|
+
return Wt(a, e, t, {
|
|
1079
1269
|
...r,
|
|
1080
1270
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1081
1271
|
});
|
|
@@ -1083,7 +1273,7 @@ var J = class e {
|
|
|
1083
1273
|
};
|
|
1084
1274
|
//#endregion
|
|
1085
1275
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1086
|
-
function
|
|
1276
|
+
function fn(e, t) {
|
|
1087
1277
|
if (!e.eastAsianVert) return 1;
|
|
1088
1278
|
let n = t(e.text);
|
|
1089
1279
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
@@ -1101,11 +1291,11 @@ function X(e, t, n, r, i, a, o) {
|
|
|
1101
1291
|
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
1292
|
let l = c.transform ?? "";
|
|
1103
1293
|
if (a && c.eastAsianVert) {
|
|
1104
|
-
let e =
|
|
1294
|
+
let e = fn(c, a(c.font));
|
|
1105
1295
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1106
1296
|
}
|
|
1107
1297
|
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:${
|
|
1298
|
+
t.style.cssText = `position:absolute;left:${A(c.x, n)};top:${A(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
1299
|
e.preventDefault(), i(d);
|
|
1110
1300
|
})), e.appendChild(t);
|
|
1111
1301
|
}
|
|
@@ -1118,16 +1308,16 @@ function Z(e, t, n, r, i, a, o = {}) {
|
|
|
1118
1308
|
for (let s of o.slices) {
|
|
1119
1309
|
let o = t[s.runIndex];
|
|
1120
1310
|
if (!o) continue;
|
|
1121
|
-
let c = a(o.font), l =
|
|
1311
|
+
let c = a(o.font), l = at(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, _ = fn(o, c), v = h * _, y = g * _;
|
|
1122
1312
|
if (y <= 0) continue;
|
|
1123
1313
|
let b = document.createElement("div"), x = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
1124
|
-
b.style.cssText = `position:absolute;left:${
|
|
1314
|
+
b.style.cssText = `position:absolute;left:${A(o.x + v, r)};top:${A(o.y, i)};width:${A(y, r)};height:${A(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
|
|
1125
1315
|
}
|
|
1126
1316
|
}
|
|
1127
1317
|
}
|
|
1128
1318
|
//#endregion
|
|
1129
1319
|
//#region packages/docx/src/find.ts
|
|
1130
|
-
var
|
|
1320
|
+
var pn = class {
|
|
1131
1321
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1132
1322
|
_matches = [];
|
|
1133
1323
|
_active = -1;
|
|
@@ -1190,8 +1380,8 @@ var Kt = class {
|
|
|
1190
1380
|
if (n !== this._generation) return [];
|
|
1191
1381
|
let o = r === this._runsRevision ? i : new Map([...i, ...this._pageRuns]), s = [];
|
|
1192
1382
|
for (let n = 0; n < a; n++) {
|
|
1193
|
-
let r = o.get(n) ?? [], i =
|
|
1194
|
-
for (let a of
|
|
1383
|
+
let r = o.get(n) ?? [], i = ae(r);
|
|
1384
|
+
for (let a of ie(i, e, t)) {
|
|
1195
1385
|
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
1196
1386
|
s.push({
|
|
1197
1387
|
page: n,
|
|
@@ -1203,10 +1393,10 @@ var Kt = class {
|
|
|
1203
1393
|
return this._runsRevision++, this._pageRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
1204
1394
|
}
|
|
1205
1395
|
next() {
|
|
1206
|
-
return this._active =
|
|
1396
|
+
return this._active = ne(this._active, this._matches.length), this._activePublic();
|
|
1207
1397
|
}
|
|
1208
1398
|
prev() {
|
|
1209
|
-
return this._active =
|
|
1399
|
+
return this._active = ce(this._active, this._matches.length), this._activePublic();
|
|
1210
1400
|
}
|
|
1211
1401
|
_activePublic() {
|
|
1212
1402
|
let e = this._matchAt(this._active);
|
|
@@ -1219,7 +1409,7 @@ var Kt = class {
|
|
|
1219
1409
|
};
|
|
1220
1410
|
//#endregion
|
|
1221
1411
|
//#region packages/docx/src/selection-context.ts
|
|
1222
|
-
function
|
|
1412
|
+
function mn(e, t, n, r, i = {}) {
|
|
1223
1413
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1224
1414
|
if (!a) return null;
|
|
1225
1415
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1262,19 +1452,19 @@ function qt(e, t, n, r, i = {}) {
|
|
|
1262
1452
|
maxTextCharacters: c.maxTextCharacters
|
|
1263
1453
|
});
|
|
1264
1454
|
}
|
|
1265
|
-
function
|
|
1455
|
+
function hn(e) {
|
|
1266
1456
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1267
1457
|
let t = Number(e);
|
|
1268
1458
|
return Number.isSafeInteger(t) ? t : null;
|
|
1269
1459
|
}
|
|
1270
|
-
function
|
|
1460
|
+
function gn(e) {
|
|
1271
1461
|
for (let t = e; t; t = t.parentElement) {
|
|
1272
|
-
let e =
|
|
1462
|
+
let e = hn(t.dataset.pageIndex);
|
|
1273
1463
|
if (e !== null) return e;
|
|
1274
1464
|
}
|
|
1275
1465
|
return null;
|
|
1276
1466
|
}
|
|
1277
|
-
var
|
|
1467
|
+
var _n = new Set([
|
|
1278
1468
|
"body",
|
|
1279
1469
|
"header",
|
|
1280
1470
|
"footer",
|
|
@@ -1282,9 +1472,9 @@ var Xt = new Set([
|
|
|
1282
1472
|
"endnote",
|
|
1283
1473
|
"textbox"
|
|
1284
1474
|
]);
|
|
1285
|
-
function
|
|
1475
|
+
function vn(e) {
|
|
1286
1476
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1287
|
-
if (!t || !
|
|
1477
|
+
if (!t || !_n.has(t) || !n || !r) return null;
|
|
1288
1478
|
try {
|
|
1289
1479
|
let e = JSON.parse(r);
|
|
1290
1480
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1297,13 +1487,13 @@ function Zt(e) {
|
|
|
1297
1487
|
}
|
|
1298
1488
|
}
|
|
1299
1489
|
function Q(e, t, n = {}) {
|
|
1300
|
-
let r =
|
|
1301
|
-
let t =
|
|
1490
|
+
let r = ue(e, t, (e) => {
|
|
1491
|
+
let t = gn(e), n = hn(e.dataset.runIndex);
|
|
1302
1492
|
return t === null || n === null ? null : {
|
|
1303
1493
|
pageIndex: t,
|
|
1304
1494
|
runIndex: n,
|
|
1305
1495
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1306
|
-
...
|
|
1496
|
+
...vn(e) === null ? {} : { source: vn(e) }
|
|
1307
1497
|
};
|
|
1308
1498
|
}, {
|
|
1309
1499
|
maxChars: n.maxTextCharacters,
|
|
@@ -1332,7 +1522,7 @@ function $(e, t, n, r, i) {
|
|
|
1332
1522
|
}
|
|
1333
1523
|
//#endregion
|
|
1334
1524
|
//#region packages/docx/src/viewer.ts
|
|
1335
|
-
var
|
|
1525
|
+
var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
1336
1526
|
_documentOwner;
|
|
1337
1527
|
get _doc() {
|
|
1338
1528
|
return this._documentOwner.current;
|
|
@@ -1375,20 +1565,20 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1375
1565
|
...r,
|
|
1376
1566
|
currentDate: i.currentDate,
|
|
1377
1567
|
showTrackedChanges: i.showTrackedChanges,
|
|
1378
|
-
[
|
|
1568
|
+
[yn]: n
|
|
1379
1569
|
});
|
|
1380
1570
|
}
|
|
1381
1571
|
constructor(e, t = {}) {
|
|
1382
1572
|
this._canvas = e, this._opts = t;
|
|
1383
|
-
let n = t[
|
|
1384
|
-
this._borrowed = n !== void 0, this._mode =
|
|
1573
|
+
let n = t[yn];
|
|
1574
|
+
this._borrowed = n !== void 0, this._mode = w("DocxViewer", t.mode, n), this._documentOwner = new x("DocxViewer", n ?? null, !1);
|
|
1385
1575
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1386
1576
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
1387
|
-
this._hostWindow = r, this._canvasMount = new
|
|
1577
|
+
this._hostWindow = r, this._canvasMount = new de(e, {
|
|
1388
1578
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1389
1579
|
forceDisplayBlock: !0
|
|
1390
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new
|
|
1391
|
-
let i = new
|
|
1580
|
+
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new C(e, this._mode === "worker"), this._errorRouter = new le("DocxViewer", t.onError);
|
|
1581
|
+
let i = new oe(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1392
1582
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
|
|
1393
1583
|
"position:absolute",
|
|
1394
1584
|
"inset:0",
|
|
@@ -1402,7 +1592,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1402
1592
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1403
1593
|
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
1594
|
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
|
|
1595
|
+
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new pn(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
|
|
1406
1596
|
}
|
|
1407
1597
|
async load(e) {
|
|
1408
1598
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
@@ -1412,6 +1602,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1412
1602
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1413
1603
|
password: this._opts.password,
|
|
1414
1604
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1605
|
+
cjkFallback: this._opts.cjkFallback,
|
|
1415
1606
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1416
1607
|
resourceLimits: this._opts.resourceLimits,
|
|
1417
1608
|
debug: this._opts.debug,
|
|
@@ -1482,7 +1673,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1482
1673
|
await this.goToPage(this._currentPage - 1);
|
|
1483
1674
|
}
|
|
1484
1675
|
_naturalWidthPx() {
|
|
1485
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
1676
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * k;
|
|
1486
1677
|
}
|
|
1487
1678
|
_renderWidth() {
|
|
1488
1679
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1501,14 +1692,14 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1501
1692
|
return this._opts.zoomMax ?? 4;
|
|
1502
1693
|
}
|
|
1503
1694
|
async setScale(e) {
|
|
1504
|
-
let t =
|
|
1695
|
+
let t = re(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1505
1696
|
this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
|
|
1506
1697
|
}
|
|
1507
1698
|
async zoomIn() {
|
|
1508
|
-
await this.setScale(
|
|
1699
|
+
await this.setScale(pe(this.getScale()));
|
|
1509
1700
|
}
|
|
1510
1701
|
async zoomOut() {
|
|
1511
|
-
await this.setScale(
|
|
1702
|
+
await this.setScale(ge(this.getScale()));
|
|
1512
1703
|
}
|
|
1513
1704
|
async fitWidth() {
|
|
1514
1705
|
await this._fit("width");
|
|
@@ -1520,9 +1711,9 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1520
1711
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
1521
1712
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1522
1713
|
if (!n) return;
|
|
1523
|
-
let r =
|
|
1524
|
-
contentWidth: t.widthPt *
|
|
1525
|
-
contentHeight: t.heightPt *
|
|
1714
|
+
let r = b({
|
|
1715
|
+
contentWidth: t.widthPt * k,
|
|
1716
|
+
contentHeight: t.heightPt * k,
|
|
1526
1717
|
containerWidth: n.clientWidth,
|
|
1527
1718
|
containerHeight: n.clientHeight
|
|
1528
1719
|
}, e);
|
|
@@ -1561,7 +1752,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1561
1752
|
}
|
|
1562
1753
|
getSelectionContext(e = {}) {
|
|
1563
1754
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1564
|
-
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ?
|
|
1755
|
+
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Gt(this._elementContext, e.maxTextCharacters) : null);
|
|
1565
1756
|
}
|
|
1566
1757
|
_emitSelectionContextChange() {
|
|
1567
1758
|
let e = this.getSelectionContext();
|
|
@@ -1578,11 +1769,11 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1578
1769
|
_redrawElementOutline() {
|
|
1579
1770
|
let e = this._elementContext, t = this._doc;
|
|
1580
1771
|
if (!e || !t || e.pageIndex !== this._currentPage) {
|
|
1581
|
-
|
|
1772
|
+
S(this._elementLayer, null);
|
|
1582
1773
|
return;
|
|
1583
1774
|
}
|
|
1584
1775
|
let n = t.pageSize(e.pageIndex);
|
|
1585
|
-
|
|
1776
|
+
S(this._elementLayer, {
|
|
1586
1777
|
x: e.bounds.xPt / n.widthPt,
|
|
1587
1778
|
y: e.bounds.yPt / n.heightPt,
|
|
1588
1779
|
width: e.bounds.widthPt / n.widthPt,
|
|
@@ -1616,7 +1807,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1616
1807
|
}, {
|
|
1617
1808
|
currentDate: this._opts.currentDate,
|
|
1618
1809
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1619
|
-
maxTextCharacters:
|
|
1810
|
+
maxTextCharacters: I
|
|
1620
1811
|
});
|
|
1621
1812
|
} catch (e) {
|
|
1622
1813
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1625,7 +1816,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1625
1816
|
return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
|
|
1626
1817
|
}
|
|
1627
1818
|
destroy() {
|
|
1628
|
-
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(),
|
|
1819
|
+
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), Ye(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
1820
|
}
|
|
1630
1821
|
async _render() {
|
|
1631
1822
|
let e = this._renderDispatcher.begin();
|
|
@@ -1661,7 +1852,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1661
1852
|
}
|
|
1662
1853
|
_bindLayoutDocument(e) {
|
|
1663
1854
|
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1664
|
-
let t =
|
|
1855
|
+
let t = on(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = tn(e, () => ({
|
|
1665
1856
|
pageCount: e.pageCount,
|
|
1666
1857
|
exact: e.layoutComplete,
|
|
1667
1858
|
complete: e.layoutComplete
|
|
@@ -1763,7 +1954,7 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1763
1954
|
_hyperlinkHandler() {
|
|
1764
1955
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
1765
1956
|
if (e.kind === "external") {
|
|
1766
|
-
|
|
1957
|
+
u(e.url, void 0, this._hostWindow);
|
|
1767
1958
|
return;
|
|
1768
1959
|
}
|
|
1769
1960
|
let t = this._doc;
|
|
@@ -1777,11 +1968,11 @@ var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
|
1777
1968
|
let r = e.getBookmarkPage(t);
|
|
1778
1969
|
r !== void 0 && await this.goToPage(r);
|
|
1779
1970
|
}
|
|
1780
|
-
},
|
|
1781
|
-
function
|
|
1782
|
-
return
|
|
1971
|
+
}, xn = 150, Sn = "0 1px 3px rgba(0,0,0,0.2)", Cn = 12, wn = 13, Tn = Symbol("DocxScrollViewer.borrowedDocument"), En;
|
|
1972
|
+
function Dn() {
|
|
1973
|
+
return En ??= import("./comment-ui-runtime-DcJOYlw-.js");
|
|
1783
1974
|
}
|
|
1784
|
-
var
|
|
1975
|
+
var On = class e {
|
|
1785
1976
|
_documentOwner;
|
|
1786
1977
|
get _doc() {
|
|
1787
1978
|
return this._documentOwner.current;
|
|
@@ -1844,7 +2035,7 @@ var cn = class e {
|
|
|
1844
2035
|
_prevBase = 0;
|
|
1845
2036
|
_lastFitWidth = 0;
|
|
1846
2037
|
_pageShadow;
|
|
1847
|
-
_find = new
|
|
2038
|
+
_find = new pn(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
1848
2039
|
_findActive = !1;
|
|
1849
2040
|
_findRequestGeneration = 0;
|
|
1850
2041
|
_showTrackedChanges;
|
|
@@ -1857,14 +2048,14 @@ var cn = class e {
|
|
|
1857
2048
|
...r,
|
|
1858
2049
|
currentDate: i.currentDate,
|
|
1859
2050
|
showTrackedChanges: i.showTrackedChanges,
|
|
1860
|
-
[
|
|
2051
|
+
[Tn]: n
|
|
1861
2052
|
});
|
|
1862
2053
|
}
|
|
1863
2054
|
constructor(e, t = {}) {
|
|
1864
2055
|
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
|
|
1866
|
-
let n = t[
|
|
1867
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new
|
|
2056
|
+
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 ?? Sn;
|
|
2057
|
+
let n = t[Tn];
|
|
2058
|
+
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() && Dn().then((e) => {
|
|
1868
2059
|
if (!this._destroyed) {
|
|
1869
2060
|
this._commentUi = e;
|
|
1870
2061
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -1883,7 +2074,7 @@ var cn = class e {
|
|
|
1883
2074
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
1884
2075
|
x: n,
|
|
1885
2076
|
y: r
|
|
1886
|
-
} : null, this.setScale(
|
|
2077
|
+
} : null, this.setScale(he(this._scale, e.deltaY, e.deltaMode));
|
|
1887
2078
|
}, 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
2079
|
}
|
|
1889
2080
|
async load(e) {
|
|
@@ -1894,6 +2085,7 @@ var cn = class e {
|
|
|
1894
2085
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1895
2086
|
password: this._opts.password,
|
|
1896
2087
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
2088
|
+
cjkFallback: this._opts.cjkFallback,
|
|
1897
2089
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1898
2090
|
resourceLimits: this._opts.resourceLimits,
|
|
1899
2091
|
debug: this._opts.debug,
|
|
@@ -1942,7 +2134,7 @@ var cn = class e {
|
|
|
1942
2134
|
}
|
|
1943
2135
|
_bindLayoutDocument(e) {
|
|
1944
2136
|
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount;
|
|
1945
|
-
let t =
|
|
2137
|
+
let t = on(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = tn(e, () => ({
|
|
1946
2138
|
pageCount: e.pageCount,
|
|
1947
2139
|
exact: e.layoutComplete,
|
|
1948
2140
|
complete: e.layoutComplete
|
|
@@ -1988,10 +2180,10 @@ var cn = class e {
|
|
|
1988
2180
|
for (let [e, n] of t) e >= this._presentedPageCount || this._slots.get(e) !== n || this._refreshSlotAtomically(e, n);
|
|
1989
2181
|
}
|
|
1990
2182
|
_pageWidthPx(e) {
|
|
1991
|
-
return this._doc.pageSize(e).widthPt *
|
|
2183
|
+
return this._doc.pageSize(e).widthPt * k * this._scale;
|
|
1992
2184
|
}
|
|
1993
2185
|
_pageHeightPx(e) {
|
|
1994
|
-
return this._doc.pageSize(e).heightPt *
|
|
2186
|
+
return this._doc.pageSize(e).heightPt * k * this._scale;
|
|
1995
2187
|
}
|
|
1996
2188
|
_fitWidthPx() {
|
|
1997
2189
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -2013,7 +2205,7 @@ var cn = class e {
|
|
|
2013
2205
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
2014
2206
|
}
|
|
2015
2207
|
_commentMarginExtent() {
|
|
2016
|
-
return this._hasCommentMargin() ? (
|
|
2208
|
+
return this._hasCommentMargin() ? (Cn + 280) * this._commentZoom() : 0;
|
|
2017
2209
|
}
|
|
2018
2210
|
_commentZoom() {
|
|
2019
2211
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -2031,8 +2223,8 @@ var cn = class e {
|
|
|
2031
2223
|
_syncCommentMarginGeometry(e) {
|
|
2032
2224
|
if (!e) return;
|
|
2033
2225
|
e.style.display = this._hasCommentMargin() ? "" : "none";
|
|
2034
|
-
let t = this._commentZoom(), n = `calc(100% + ${
|
|
2035
|
-
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${
|
|
2226
|
+
let t = this._commentZoom(), n = `calc(100% + ${Cn * t}px)`;
|
|
2227
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${wn}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
2036
2228
|
}
|
|
2037
2229
|
_widestPageWidthPt() {
|
|
2038
2230
|
if (!this._doc) return 0;
|
|
@@ -2048,7 +2240,7 @@ var cn = class e {
|
|
|
2048
2240
|
let e = this._fitWidthPx();
|
|
2049
2241
|
if (e <= 0) return 0;
|
|
2050
2242
|
let t = this._widestPageWidthPt();
|
|
2051
|
-
return t <= 0 ? 0 : e / (t *
|
|
2243
|
+
return t <= 0 ? 0 : e / (t * k);
|
|
2052
2244
|
}
|
|
2053
2245
|
relayout() {
|
|
2054
2246
|
this._relayout();
|
|
@@ -2108,7 +2300,7 @@ var cn = class e {
|
|
|
2108
2300
|
return a;
|
|
2109
2301
|
}
|
|
2110
2302
|
_range() {
|
|
2111
|
-
return
|
|
2303
|
+
return T(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
|
|
2112
2304
|
}
|
|
2113
2305
|
_syncSpacer() {
|
|
2114
2306
|
let e = this._range();
|
|
@@ -2165,7 +2357,7 @@ var cn = class e {
|
|
|
2165
2357
|
i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
|
|
2166
2358
|
let a = null, o = null, s = null;
|
|
2167
2359
|
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 =
|
|
2360
|
+
let c = se(t, this._opts.enableElementSelection === !0);
|
|
2169
2361
|
return this._scrollHost.appendChild(t), {
|
|
2170
2362
|
wrapper: t,
|
|
2171
2363
|
canvas: n,
|
|
@@ -2179,11 +2371,11 @@ var cn = class e {
|
|
|
2179
2371
|
commentGeometry: null,
|
|
2180
2372
|
renderedPage: -1,
|
|
2181
2373
|
renderedScale: -1,
|
|
2182
|
-
dispatcher: new
|
|
2374
|
+
dispatcher: new C(n, this._mode === "worker")
|
|
2183
2375
|
};
|
|
2184
2376
|
}
|
|
2185
2377
|
_recycleSlot(e, t) {
|
|
2186
|
-
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
2378
|
+
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
2379
|
}
|
|
2188
2380
|
_positionSlot(e, t, n) {
|
|
2189
2381
|
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
@@ -2234,7 +2426,7 @@ var cn = class e {
|
|
|
2234
2426
|
_hyperlinkHandler() {
|
|
2235
2427
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
2236
2428
|
if (e.kind === "external") {
|
|
2237
|
-
|
|
2429
|
+
u(e.url);
|
|
2238
2430
|
return;
|
|
2239
2431
|
}
|
|
2240
2432
|
let t = this._doc;
|
|
@@ -2313,12 +2505,12 @@ var cn = class e {
|
|
|
2313
2505
|
f = Math.min(1, Math.max(0, f));
|
|
2314
2506
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
2315
2507
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2316
|
-
let h =
|
|
2508
|
+
let h = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
|
|
2317
2509
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
2318
2510
|
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
2511
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
2320
2512
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2321
|
-
this._scrollHost.scrollLeft =
|
|
2513
|
+
this._scrollHost.scrollLeft = ee(m, i.x - p, a, r, { maxScroll: e });
|
|
2322
2514
|
}
|
|
2323
2515
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2324
2516
|
}
|
|
@@ -2326,10 +2518,10 @@ var cn = class e {
|
|
|
2326
2518
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2327
2519
|
}
|
|
2328
2520
|
zoomIn() {
|
|
2329
|
-
this.setScale(
|
|
2521
|
+
this.setScale(pe(this.getScale()));
|
|
2330
2522
|
}
|
|
2331
2523
|
zoomOut() {
|
|
2332
|
-
this.setScale(
|
|
2524
|
+
this.setScale(ge(this.getScale(), this._effectiveZoomMin()));
|
|
2333
2525
|
}
|
|
2334
2526
|
_effectiveZoomMin() {
|
|
2335
2527
|
let e = this._opts.zoomMin ?? .1;
|
|
@@ -2343,9 +2535,9 @@ var cn = class e {
|
|
|
2343
2535
|
}
|
|
2344
2536
|
_fit(e) {
|
|
2345
2537
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2346
|
-
let t = this._doc.pageSize(0), n =
|
|
2347
|
-
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) *
|
|
2348
|
-
contentHeight: t.heightPt *
|
|
2538
|
+
let t = this._doc.pageSize(0), n = b({
|
|
2539
|
+
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) * k,
|
|
2540
|
+
contentHeight: t.heightPt * k,
|
|
2349
2541
|
containerWidth: this._fitWidthPx(),
|
|
2350
2542
|
containerHeight: this._scrollHost.clientHeight
|
|
2351
2543
|
}, e);
|
|
@@ -2382,7 +2574,7 @@ var cn = class e {
|
|
|
2382
2574
|
_scheduleSettle() {
|
|
2383
2575
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2384
2576
|
this._settleTimer = null, this._settleRender();
|
|
2385
|
-
},
|
|
2577
|
+
}, xn);
|
|
2386
2578
|
}
|
|
2387
2579
|
_settleRender() {
|
|
2388
2580
|
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 +2588,7 @@ var cn = class e {
|
|
|
2396
2588
|
}
|
|
2397
2589
|
let o = document.createElement("canvas");
|
|
2398
2590
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2399
|
-
let s = new
|
|
2591
|
+
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
2592
|
$(this._doc, o, e, "main", {
|
|
2401
2593
|
width: r,
|
|
2402
2594
|
dpr: n,
|
|
@@ -2440,14 +2632,14 @@ var cn = class e {
|
|
|
2440
2632
|
}
|
|
2441
2633
|
scrollToPage(e, t) {
|
|
2442
2634
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2443
|
-
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r =
|
|
2444
|
-
typeof
|
|
2445
|
-
top:
|
|
2635
|
+
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = _e(r.offsets[n] ?? 0, Math.max(0, r.totalHeight - this._scrollHost.clientHeight)), a = this._scrollHost;
|
|
2636
|
+
typeof a.scrollTo == "function" ? a.scrollTo({
|
|
2637
|
+
top: i,
|
|
2446
2638
|
behavior: t?.behavior ?? "auto"
|
|
2447
|
-
}) : this._scrollHost.scrollTop =
|
|
2639
|
+
}) : this._scrollHost.scrollTop = i, this._mountVisible();
|
|
2448
2640
|
}
|
|
2449
2641
|
_scrollToPageTarget(e, t, n) {
|
|
2450
|
-
let r =
|
|
2642
|
+
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
2643
|
typeof f.scrollTo == "function" ? f.scrollTo({
|
|
2452
2644
|
top: u,
|
|
2453
2645
|
left: d,
|
|
@@ -2462,7 +2654,7 @@ var cn = class e {
|
|
|
2462
2654
|
}
|
|
2463
2655
|
_indexCommentPages(e, t, n) {
|
|
2464
2656
|
if (!this._commentIndexedPages.has(e)) {
|
|
2465
|
-
for (let r of n) this._commentPageById.has(r.commentId) ||
|
|
2657
|
+
for (let r of n) this._commentPageById.has(r.commentId) || M(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
|
|
2466
2658
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2467
2659
|
}
|
|
2468
2660
|
}
|
|
@@ -2512,7 +2704,7 @@ var cn = class e {
|
|
|
2512
2704
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2513
2705
|
let u = await this._commentRunsForPage(s, n);
|
|
2514
2706
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2515
|
-
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) =>
|
|
2707
|
+
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => M(e, u))[0], !c)) return !1;
|
|
2516
2708
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2517
2709
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2518
2710
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2689,7 +2881,7 @@ var cn = class e {
|
|
|
2689
2881
|
}
|
|
2690
2882
|
getSelectionContext(e = {}) {
|
|
2691
2883
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2692
|
-
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ?
|
|
2884
|
+
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? mn(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 ? Gt(this._elementContext, e.maxTextCharacters) : null));
|
|
2693
2885
|
}
|
|
2694
2886
|
_emitSelectionContextChange() {
|
|
2695
2887
|
let e = this.getSelectionContext();
|
|
@@ -2709,11 +2901,11 @@ var cn = class e {
|
|
|
2709
2901
|
_redrawElementOutlineForSlot(e, t) {
|
|
2710
2902
|
let n = this._elementContext, r = this._doc;
|
|
2711
2903
|
if (!n || !r || n.pageIndex !== e) {
|
|
2712
|
-
|
|
2904
|
+
S(t.elementLayer, null);
|
|
2713
2905
|
return;
|
|
2714
2906
|
}
|
|
2715
2907
|
let i = r.pageSize(e);
|
|
2716
|
-
|
|
2908
|
+
S(t.elementLayer, {
|
|
2717
2909
|
x: n.bounds.xPt / i.widthPt,
|
|
2718
2910
|
y: n.bounds.yPt / i.heightPt,
|
|
2719
2911
|
width: n.bounds.widthPt / i.widthPt,
|
|
@@ -2749,7 +2941,7 @@ var cn = class e {
|
|
|
2749
2941
|
}, {
|
|
2750
2942
|
currentDate: this._currentDate,
|
|
2751
2943
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2752
|
-
maxTextCharacters:
|
|
2944
|
+
maxTextCharacters: I
|
|
2753
2945
|
});
|
|
2754
2946
|
} catch (e) {
|
|
2755
2947
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2767,7 +2959,7 @@ var cn = class e {
|
|
|
2767
2959
|
};
|
|
2768
2960
|
//#endregion
|
|
2769
2961
|
//#region packages/docx/src/types.ts
|
|
2770
|
-
function
|
|
2962
|
+
function kn(e) {
|
|
2771
2963
|
let t = [];
|
|
2772
2964
|
for (let n of e.content) {
|
|
2773
2965
|
if (n.type !== "paragraph") continue;
|
|
@@ -2779,25 +2971,25 @@ function ln(e) {
|
|
|
2779
2971
|
}
|
|
2780
2972
|
//#endregion
|
|
2781
2973
|
//#region src/docx.ts
|
|
2782
|
-
var
|
|
2974
|
+
var An = /* @__PURE__ */ e({
|
|
2783
2975
|
DocxDocument: () => J,
|
|
2784
|
-
DocxScrollViewer: () =>
|
|
2785
|
-
DocxViewer: () =>
|
|
2786
|
-
OoxmlDecodedImageLimitError: () =>
|
|
2787
|
-
OoxmlError: () =>
|
|
2788
|
-
OoxmlResourceLimitError: () =>
|
|
2789
|
-
TiffDecodeError: () =>
|
|
2790
|
-
autoResize: () =>
|
|
2976
|
+
DocxScrollViewer: () => On,
|
|
2977
|
+
DocxViewer: () => bn,
|
|
2978
|
+
OoxmlDecodedImageLimitError: () => tt,
|
|
2979
|
+
OoxmlError: () => c,
|
|
2980
|
+
OoxmlResourceLimitError: () => d,
|
|
2981
|
+
TiffDecodeError: () => nt,
|
|
2982
|
+
autoResize: () => y,
|
|
2791
2983
|
buildDocxHighlightLayer: () => Z,
|
|
2792
2984
|
buildDocxTextLayer: () => X,
|
|
2793
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
2794
|
-
isTiffDecodeError: () =>
|
|
2795
|
-
noteText: () =>
|
|
2796
|
-
openExternalHyperlink: () =>
|
|
2985
|
+
isOoxmlDecodedImageLimitError: () => et,
|
|
2986
|
+
isTiffDecodeError: () => rt,
|
|
2987
|
+
noteText: () => kn,
|
|
2988
|
+
openExternalHyperlink: () => u,
|
|
2797
2989
|
readDocxTextSelectionContext: () => Q,
|
|
2798
|
-
resolveCommentAnchorRuns: () =>
|
|
2799
|
-
resolveDocxCommentThreads: () =>
|
|
2800
|
-
resolveRevisionAnchorRuns: () =>
|
|
2990
|
+
resolveCommentAnchorRuns: () => M,
|
|
2991
|
+
resolveDocxCommentThreads: () => ct,
|
|
2992
|
+
resolveRevisionAnchorRuns: () => Qt
|
|
2801
2993
|
});
|
|
2802
2994
|
//#endregion
|
|
2803
|
-
export { Q as a, J as c,
|
|
2995
|
+
export { Q as a, J as c, bn as i, Qt as l, kn as n, Z as o, On as r, X as s, An as t };
|