@silurus/ooxml 0.84.0 → 0.85.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 +36 -13
- package/dist/assets/render-worker-BRKOyWVH.js +24 -0
- package/dist/assets/render-worker-DnU-PxZ1.js +10 -0
- package/dist/assets/render-worker-NZPOUOTU.js +11 -0
- package/dist/{canvas-viewer-mechanics-CIfhCgYA.js → canvas-viewer-mechanics-C-yTGbFC.js} +308 -234
- package/dist/chart-ex.mjs +270 -270
- package/dist/{comment-ui-runtime-CdMMApEN.js → comment-ui-runtime-CAbpuWi_.js} +4 -4
- package/dist/{comment-ui-runtime-C5qimVMD.js → comment-ui-runtime-DAKBCpsM.js} +5 -5
- package/dist/comment-ui-runtime-DTaaZdXC.js +2 -0
- package/dist/{comments-BAlAyIhb.js → comments-Brfxa3hQ.js} +1 -1
- package/dist/{document-pull-client-DeHUdQhH.js → document-pull-client-BdYrjAep.js} +4679 -4359
- package/dist/{docx-CbU51aPR.js → docx-qK0Qmyey.js} +315 -300
- package/dist/docx.mjs +7 -6
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-DS6BVyHA.js → dom-interaction-boundary-CMDDgICk.js} +1 -1
- package/dist/index.mjs +3 -3
- package/dist/line-distribute-CiKeWjBF.js +1023 -0
- package/dist/{line-metrics-CXyjyYd5.js → line-metrics-u87yCAfV.js} +2182 -705
- package/dist/math.mjs +2 -2
- package/dist/node.mjs +404 -394
- package/dist/pixel-budget-Dgjw269h.js +37 -0
- package/dist/{plot-area-frame-DuXZzovH.js → plot-area-frame-D5hEOgkJ.js} +691 -1418
- package/dist/{pptx-C17oBD8Z.js → pptx-DxZwhOWr.js} +250 -221
- package/dist/pptx.mjs +7 -6
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/raster-target-whZhvVMt.js +87 -0
- package/dist/region-map.mjs +5 -5
- package/dist/{render-CVeGktZG.js → render-DrAAZWwH.js} +9 -6
- package/dist/{render-worker-host-BWdhjVH_.js → render-worker-host-CHlwYJdK.js} +1 -1
- package/dist/{render-worker-host-CZi7Mn5v.js → render-worker-host-GZ7ez-l3.js} +1 -1
- package/dist/{render-worker-host-CbaQivE7.js → render-worker-host-XDMsyVsv.js} +1 -1
- package/dist/{renderer-Bmky2yBc.js → renderer-XFSCOT6m.js} +1937 -1936
- package/dist/resource-measurement-6uR3Huao.js +150 -0
- package/dist/{session-Cl0RVnMs.js → session-DoPwA4gv.js} +79 -79
- package/dist/{slide-pull-client-BS0EeZo2.js → slide-pull-client-8i8C4VyD.js} +1054 -824
- package/dist/{three-d-B7LsKeOS.js → three-d-YYghQndN.js} +109 -110
- package/dist/three-d.mjs +726 -726
- package/dist/tiff.mjs +664 -78
- package/dist/types/chart-ex.d.ts +2 -2
- package/dist/types/docx.d.ts +29 -13
- package/dist/types/index.d.ts +43 -21
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +11 -7
- package/dist/types/pptx.d.ts +34 -15
- package/dist/types/region-map.d.ts +2 -2
- package/dist/types/three-d.d.ts +2 -2
- package/dist/types/tiff.d.ts +13 -3
- package/dist/types/xlsx.d.ts +30 -13
- package/dist/{worksheet-pull-client-B0zfEVau.js → worksheet-pull-client-Btydoxto.js} +47 -47
- package/dist/{xlsx-FyKAiNo-.js → xlsx-57OZsbD9.js} +1395 -1196
- package/dist/xlsx.mjs +7 -6
- package/package.json +2 -2
- package/dist/assets/render-worker-BZd4-U4w.js +0 -10
- package/dist/assets/render-worker-CiEWCh_T.js +0 -11
- package/dist/assets/render-worker-Cpmy3GDF.js +0 -24
- package/dist/comment-ui-runtime-aPzHfV_A.js +0 -2
- package/dist/line-distribute-MqInuujx.js +0 -1003
- package/dist/resource-measurement-esyGbzAF.js +0 -120
- package/dist/tiff-contract-Xjn3qXqK.js +0 -69
- /package/dist/{comment-occurrence-C34fWs_F.js → comment-occurrence-tj54AXXB.js} +0 -0
- /package/dist/{highlight-rect-MaCt0om0.js → highlight-rect-DBcYVJDv.js} +0 -0
- /package/dist/{mathjax-DPEX346v.js → mathjax-DS69BmJd.js} +0 -0
- /package/dist/{read-only-comment-decoration-BYCXoSdC.js → read-only-comment-decoration-Mv_SAiHy.js} +0 -0
- /package/dist/{read-only-comment-margin-C7b3l0ro.js → read-only-comment-margin-Cqu-Ir0C.js} +0 -0
- /package/dist/{renderer-module-contract-C6sYZvTV.js → renderer-module-contract-Cu-GKuPd.js} +0 -0
- /package/dist/{source-key-DORuuFb-.js → source-key-BkBB3X82.js} +0 -0
- /package/dist/{transfer-vNOFQuvv.js → transfer-mIj7E7NB.js} +0 -0
- /package/dist/{visible-index-DwJzuGmJ.js → visible-index-DPoQYSDt.js} +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { B as t,
|
|
3
|
-
import { C as
|
|
2
|
+
import { B as t, R as n, W as r, Xt as i, a, et as o, on as s, pt as c, sn as l, ut as u, vt as d, z as f } from "./line-metrics-u87yCAfV.js";
|
|
3
|
+
import { C as p, D as m, E as h, S as g, T as _, _ as v, a as y, b, c as x, d as ee, f as te, g as ne, h as re, i as S, l as C, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as fe, w as pe, x as me, y as he } from "./canvas-viewer-mechanics-C-yTGbFC.js";
|
|
4
4
|
import { a as ge, i as _e, t as ve } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
5
|
-
import { c as ye, i as be, l as xe, n as Se, o as
|
|
6
|
-
import { A as Ee, C, D as
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
5
|
+
import { c as ye, i as be, l as xe, n as Se, o as w, r as Ce, s as we, t as Te } from "./dom-interaction-boundary-CMDDgICk.js";
|
|
6
|
+
import { A as Ee, C as T, D as E, E as De, O as D, S as Oe, T as O, _ as ke, a as Ae, b as je, c as Me, d as Ne, f as Pe, g as Fe, h as Ie, j as Le, k as Re, l as ze, m as Be, n as k, o as Ve, p as He, s as Ue, t as A, v as We, w as Ge, x as Ke, y as qe } from "./document-pull-client-BdYrjAep.js";
|
|
7
|
+
import { l as Je, s as Ye } from "./pixel-budget-Dgjw269h.js";
|
|
8
|
+
import { a as j } from "./units-EJdC96r6.js";
|
|
9
|
+
import { i as Xe, s as Ze } from "./raster-target-whZhvVMt.js";
|
|
10
|
+
import { n as Qe } from "./renderer-module-contract-Cu-GKuPd.js";
|
|
11
|
+
import { n as $e, t as M } from "./highlight-rect-DBcYVJDv.js";
|
|
12
|
+
import { o as N } from "./source-key-BkBB3X82.js";
|
|
13
|
+
import { i as et, n as P, r as tt, t as nt } from "./comments-Brfxa3hQ.js";
|
|
13
14
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
14
|
-
var tt = "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();_.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=_.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw f(r[0])}assert_healthy(){let e=_.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw f(e[0])}cancel_document_cursor(){_.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){_.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=_.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw f(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=_.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=i(e[0],e[1]).slice();return _.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=d(e,_.__wbindgen_malloc,_.__wbindgen_realloc),n=g,r=_.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw f(r[2]);var a=i(r[0],r[1]).slice();return _.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=ee(e,_.__wbindgen_malloc),o=g,s=_.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 f(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=_.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw f(n[0])}parse(){let e=_.docxarchive_parse(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=i(e[0],e[1]).slice();return _.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=_.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw f(a[2]);var o=i(a[0],a[1]).slice();return _.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=_.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=i(e[0],e[1]).slice();return _.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=_.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,f(i[2]);return e=n,t=r,s(n,r)}finally{_.__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{_.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=d(n,_.__wbindgen_malloc,_.__wbindgen_realloc),i=g;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=_.__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=>_.__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!==_.memory.buffer)&&(a=new DataView(_.memory.buffer)),a}function s(e,t){return e>>>=0,te(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(_.memory.buffer)),c}function u(e){return e==null}function ee(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),g=e.length,n}function d(e,t,n){if(n===void 0){let n=h.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),g=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=h.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return g=o,i}function f(e){let t=_.__wbindgen_externrefs.get(e);return _.__externref_table_dealloc(e),t}let p=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});p.decode();let m=0;function te(e,t){return m+=t,m>=2146435072&&(p=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),p.decode(),m=t),p.decode(l().subarray(e,e+t))}const h=new TextEncoder;`encodeInto`in h||(h.encodeInto=function(e,t){let n=h.encode(e);return t.set(n),{read:e.length,written:n.length}});let g=0,_;function v(e,t){return _=e.exports,a=null,c=null,_.__wbindgen_start(),_}async function y(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 b(e){if(_!==void 0)return _;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 y(await e,t);return v(r,i)}async function ne(e){return _=void 0,a=null,c=null,b(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)}},C,w,re=e((()=>{C=1<<25,C*4,w=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 ie(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 ae=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`)}},T=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function E(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 oe(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 se(e,t){return e({module_or_path:t})}var ce=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new ae(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),le),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 T(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):se(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,oe(e)}};function le(e){return E(e)?new T(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function D(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function O(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return D(t.requiredBytes)&&D(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var k=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 A(e){if(e instanceof k)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`||!O(r)))return new k(r)}function ue(e,t,n){let r=A(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}re();const j=`OOXML_RESOURCE_LIMIT:`;function M(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function N(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return M(t.archiveEntryCount)&&M(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||M(t.largestInflatedEntryBytes))&&M(t.distinctInflatedBytes)&&M(t.operationInflatedBytes)}function P(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!N(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function F(e){return e===`docx`||e===`xlsx`||e===`pptx`}function I(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function L(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function R(e){return L(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function z(e){return!L(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 B=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}]]),V=new Set([...B.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),H=new Set([...B.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function de(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!F(t.format)||!L(t.operation,256)||!R(t.resource)||!R(t.metric)||!M(t.limit)||!M(t.observed)||typeof t.configurable!=`boolean`||!N(t.usage)?!1:!(`part`in t)||z(t.part)}function U(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!I(t.stage)||!de(t.violation))return!1;let n=t.violation,r=B.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:!(V.has(n.resource)&&H.has(n.metric))}function fe(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function pe(e){if(!U(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:fe(t.usage)}};return U(n)?n:void 0}function W(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function me(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(j))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`||!U(r.details)))return new S(W(r.details),r.details)}function he(e){if(e instanceof w)return{message:e.message,errorName:e.name,code:e.code,decodedImage:{metric:e.metric,limit:e.limit,observed:e.observed}};let t=A(e);if(t)return{message:t.message,errorName:t.name,code:t.code,insufficientCredit:{requiredBytes:t.requiredBytes,offeredBytes:t.offeredBytes}};let n=e instanceof x||e instanceof S?e:me(e);if(n instanceof S){let e=pe(n.details);return e?{message:typeof n.message==`string`?n.message:W(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(n instanceof x)return{message:typeof n.message==`string`?n.message:String(n.message),errorName:L(n.name,128)?n.name:`OoxmlError`,...R(n.code)?{code:n.code}:{}};let r=e instanceof Error?e.message:String(e);if(typeof r==`string`&&r.startsWith(j))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let i=e instanceof Error?e:Error(r),a=i;return{message:typeof i.message==`string`?i.message:String(i.message),errorName:L(i.name,128)?i.name:`Error`,...typeof a.code==`string`?{code:a.code}:{}}}function G(e){try{return he(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function ge(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 _e(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const K=`ooxml-pull-v1`;function q(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function ve(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 J=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,q(this.maxRetainedBytes,`max retained lease bytes`),q(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}},ye=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){ve(e.sessionId),q(e.operationId,`operation id`),q(e.generation,`generation`),q(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&q(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=G(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(q(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:K,...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){q(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(q(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:K,...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:K,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 Y=67108864;var be=class{coordinator=new J;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 ye({...e,maxByteCredit:Y,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 ue(e,n,Y)||e}let i=ge(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?P(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:K,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:G(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 J}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function xe(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new ce(b,{freeArchive:e=>e.free(),reinit:ne}),Z=new be(()=>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(xe(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:K,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:G(e)})}return}if(n.type===`init`){X.setWasmInput(ie(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]=_e(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:P(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,...G(e)})}};", nt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", tt], { type: "text/javascript;charset=utf-8" });
|
|
15
|
-
function
|
|
15
|
+
var rt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};const J=67108864;var De=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>{let e=this.executeArchive(e=>e.document_cursor_resource_usage?.());return e?I(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Y(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new De(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Y(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", it = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", rt], { type: "text/javascript;charset=utf-8" });
|
|
16
|
+
function at(e) {
|
|
16
17
|
let t;
|
|
17
18
|
try {
|
|
18
|
-
if (t =
|
|
19
|
+
if (t = it && (self.URL || self.webkitURL).createObjectURL(it), !t) throw "";
|
|
19
20
|
let n = new Worker(t, {
|
|
20
21
|
type: "module",
|
|
21
22
|
name: e?.name
|
|
@@ -24,7 +25,7 @@ function rt(e) {
|
|
|
24
25
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
25
26
|
}), n;
|
|
26
27
|
} catch {
|
|
27
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
28
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(rt), {
|
|
28
29
|
type: "module",
|
|
29
30
|
name: e?.name
|
|
30
31
|
});
|
|
@@ -32,17 +33,17 @@ function rt(e) {
|
|
|
32
33
|
}
|
|
33
34
|
//#endregion
|
|
34
35
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
35
|
-
var
|
|
36
|
+
var ot = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region packages/docx/src/bookmark-nav.ts
|
|
38
|
-
function
|
|
39
|
+
function st(e) {
|
|
39
40
|
let t = /* @__PURE__ */ new Map();
|
|
40
41
|
for (let n of e.pages) for (let e of n.bookmarkStarts) e.name !== "" && !t.has(e.name) && t.set(e.name, n.pageIndex);
|
|
41
42
|
return t;
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
45
|
//#region packages/docx/src/embedded-fonts.ts
|
|
45
|
-
async function
|
|
46
|
+
async function ct(e, t) {
|
|
46
47
|
let n = e.embeddedFonts;
|
|
47
48
|
if (!n || n.length === 0) return [];
|
|
48
49
|
let r = (await Promise.all(n.map(async (e) => {
|
|
@@ -53,8 +54,8 @@ async function ot(e, t) {
|
|
|
53
54
|
bytes: n,
|
|
54
55
|
odttf: e.partPath.toLowerCase().endsWith(".odttf"),
|
|
55
56
|
fontKey: e.fontKey,
|
|
56
|
-
weight:
|
|
57
|
-
style:
|
|
57
|
+
weight: lt(e.style),
|
|
58
|
+
style: ut(e.style)
|
|
58
59
|
};
|
|
59
60
|
} catch {
|
|
60
61
|
return null;
|
|
@@ -62,16 +63,16 @@ async function ot(e, t) {
|
|
|
62
63
|
}))).filter((e) => e !== null);
|
|
63
64
|
return r.length === 0 ? [] : ye(r);
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function lt(e) {
|
|
66
67
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function ut(e) {
|
|
69
70
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
70
71
|
}
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region packages/docx/src/element-context.ts
|
|
73
|
-
var
|
|
74
|
-
function
|
|
74
|
+
var F = de, dt = 16384;
|
|
75
|
+
function ft(e, t) {
|
|
75
76
|
let n = Math.min(e.length, t);
|
|
76
77
|
if (n > 0 && n < e.length) {
|
|
77
78
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -79,7 +80,7 @@ function ut(e, t) {
|
|
|
79
80
|
}
|
|
80
81
|
return e.slice(0, n);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function pt(e, t) {
|
|
83
84
|
let n = [], r = 0, i = !1;
|
|
84
85
|
for (let a of e) {
|
|
85
86
|
if (a.length === 0) continue;
|
|
@@ -90,7 +91,7 @@ function dt(e, t) {
|
|
|
90
91
|
}
|
|
91
92
|
n.push("\n"), r++;
|
|
92
93
|
}
|
|
93
|
-
let e =
|
|
94
|
+
let e = ft(a, Math.max(0, t - r));
|
|
94
95
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
95
96
|
i = !0;
|
|
96
97
|
break;
|
|
@@ -102,7 +103,7 @@ function dt(e, t) {
|
|
|
102
103
|
truncated: i
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
|
-
function*
|
|
106
|
+
function* I(e) {
|
|
106
107
|
if (e.kind === "paragraph") {
|
|
107
108
|
for (let t of e.lines) {
|
|
108
109
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -111,42 +112,42 @@ function* P(e) {
|
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
114
|
if (e.kind === "table") {
|
|
114
|
-
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield*
|
|
115
|
+
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* I(t.layout);
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
|
-
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield*
|
|
118
|
+
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* I(t);
|
|
118
119
|
}
|
|
119
|
-
function*
|
|
120
|
+
function* mt(e) {
|
|
120
121
|
for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
|
|
121
|
-
for (let t of e.textBoxes) yield*
|
|
122
|
+
for (let t of e.textBoxes) yield* I(t);
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
-
let t = e ??
|
|
124
|
+
function ht(e) {
|
|
125
|
+
let t = e ?? dt;
|
|
125
126
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
126
|
-
return Math.min(
|
|
127
|
+
return Math.min(F, Math.floor(t));
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function gt(e) {
|
|
129
130
|
return {
|
|
130
131
|
story: e.story,
|
|
131
132
|
storyInstance: e.storyInstance,
|
|
132
133
|
path: [...e.path]
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
+
function _t(e) {
|
|
136
137
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
let t =
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
function vt(e) {
|
|
140
|
+
let t = _t(e), n = [
|
|
141
|
+
T(e.pointToPage, t),
|
|
142
|
+
T(e.pointToPage, {
|
|
142
143
|
xPt: t.xPt + t.widthPt,
|
|
143
144
|
yPt: t.yPt
|
|
144
145
|
}),
|
|
145
|
-
|
|
146
|
+
T(e.pointToPage, {
|
|
146
147
|
xPt: t.xPt,
|
|
147
148
|
yPt: t.yPt + t.heightPt
|
|
148
149
|
}),
|
|
149
|
-
|
|
150
|
+
T(e.pointToPage, {
|
|
150
151
|
xPt: t.xPt + t.widthPt,
|
|
151
152
|
yPt: t.yPt + t.heightPt
|
|
152
153
|
})
|
|
@@ -158,10 +159,10 @@ function gt(e) {
|
|
|
158
159
|
heightPt: o - i
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
|
-
function
|
|
162
|
+
function L(e, t) {
|
|
162
163
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
+
function yt(e, t) {
|
|
165
166
|
let n = !1;
|
|
166
167
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
167
168
|
let a = t[r], o = t[i];
|
|
@@ -169,35 +170,35 @@ function _t(e, t) {
|
|
|
169
170
|
}
|
|
170
171
|
return n;
|
|
171
172
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
173
|
+
function bt(e, t) {
|
|
174
|
+
return L(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? L(e.clip.rect, t) : yt(t, e.clip.points) : !0 : !1;
|
|
174
175
|
}
|
|
175
|
-
function
|
|
176
|
+
function xt(e, t, n) {
|
|
176
177
|
for (let n of e.clips) {
|
|
177
178
|
let e = Oe(n.pointToPage, t);
|
|
178
|
-
if (!e || !
|
|
179
|
+
if (!e || !L(n.bounds, e)) return !1;
|
|
179
180
|
}
|
|
180
|
-
return "drawing" in e ?
|
|
181
|
+
return "drawing" in e ? bt(e.drawing, n) : L(e.placement.bounds, n);
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
+
function R(e, t) {
|
|
183
184
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
186
|
+
function St(e) {
|
|
187
|
+
return R(e, "chart") ? "chart" : e.commands.some((e) => e.kind === "drawingml-shape" || e.kind === "drawingml-image-fill" || e.kind === "fill-rect" || e.kind === "stroke-rect" || e.kind === "text" || e.kind === "watermark-text") ? "shape" : R(e, "image") ? "image" : null;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
let o = "drawing" in e ?
|
|
189
|
+
function Ct(e, t, n, r, i, a) {
|
|
190
|
+
let o = "drawing" in e ? St(e.drawing) : e.placement.resourceKind;
|
|
190
191
|
if (!o) return null;
|
|
191
192
|
let s, c = !1, l, u;
|
|
192
193
|
if (o === "chart") {
|
|
193
|
-
let t = "drawing" in e ?
|
|
194
|
+
let t = "drawing" in e ? R(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = ee(n.model, a);
|
|
194
195
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
195
196
|
} else if (o === "image") {
|
|
196
|
-
let t = "drawing" in e ?
|
|
197
|
+
let t = "drawing" in e ? R(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
|
|
197
198
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
198
199
|
l = n.mimeType;
|
|
199
200
|
} else {
|
|
200
|
-
let t =
|
|
201
|
+
let t = pt(mt(e), a);
|
|
201
202
|
s = t.text, c = t.truncated;
|
|
202
203
|
}
|
|
203
204
|
return {
|
|
@@ -207,8 +208,8 @@ function xt(e, t, n, r, i, a) {
|
|
|
207
208
|
elementIndex: n,
|
|
208
209
|
elementType: o,
|
|
209
210
|
point: { ...r },
|
|
210
|
-
bounds:
|
|
211
|
-
source:
|
|
211
|
+
bounds: vt(e),
|
|
212
|
+
source: gt("drawing" in e ? e.drawing.source : e.source),
|
|
212
213
|
...s === void 0 ? {} : { text: s },
|
|
213
214
|
...l === void 0 ? {} : { mimeType: l },
|
|
214
215
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -218,26 +219,26 @@ function xt(e, t, n, r, i, a) {
|
|
|
218
219
|
maxTextCharacters: a
|
|
219
220
|
};
|
|
220
221
|
}
|
|
221
|
-
function
|
|
222
|
+
function wt(e, t, n, r, i = {}) {
|
|
222
223
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
223
|
-
let a =
|
|
224
|
+
let a = ht(i.maxTextCharacters), o = je(e, t);
|
|
224
225
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
225
226
|
let i = o[e], s = Oe(i.pointToPage, n);
|
|
226
|
-
if (!s || !
|
|
227
|
-
let c =
|
|
227
|
+
if (!s || !xt(i, n, s)) continue;
|
|
228
|
+
let c = Ct(i, t, e, n, r, a);
|
|
228
229
|
if (c) return c;
|
|
229
230
|
}
|
|
230
231
|
return null;
|
|
231
232
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
233
|
+
function Tt(e, t, n, r) {
|
|
234
|
+
return wt(Ge(e, {
|
|
234
235
|
currentDate: r.currentDate,
|
|
235
236
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
236
237
|
showTrackedChanges: r.showTrackedChanges
|
|
237
238
|
}, t).layout, t, n, Re(e), r);
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
-
let n =
|
|
240
|
+
function Et(e, t) {
|
|
241
|
+
let n = ht(t), r = e.text === void 0 ? void 0 : ft(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
|
|
241
242
|
return {
|
|
242
243
|
...structuredClone(e),
|
|
243
244
|
...r === void 0 ? {} : { text: r },
|
|
@@ -249,20 +250,20 @@ function L(e, t) {
|
|
|
249
250
|
}
|
|
250
251
|
//#endregion
|
|
251
252
|
//#region packages/docx/src/revisions.ts
|
|
252
|
-
function
|
|
253
|
-
let t =
|
|
253
|
+
function z(e) {
|
|
254
|
+
let t = et(e.id);
|
|
254
255
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
255
256
|
}
|
|
256
|
-
function
|
|
257
|
+
function B(e) {
|
|
257
258
|
return Object.freeze({
|
|
258
259
|
...e,
|
|
259
260
|
path: Object.freeze([...e.path])
|
|
260
261
|
});
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
+
function Dt(e, t) {
|
|
263
264
|
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]);
|
|
264
265
|
}
|
|
265
|
-
function
|
|
266
|
+
function V(e, t) {
|
|
266
267
|
let n = 0, r = e.length;
|
|
267
268
|
for (; n < r;) {
|
|
268
269
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -270,22 +271,22 @@ function B(e, t) {
|
|
|
270
271
|
}
|
|
271
272
|
return n;
|
|
272
273
|
}
|
|
273
|
-
function
|
|
274
|
+
function Ot(e, t) {
|
|
274
275
|
let n = Array(e.length), r;
|
|
275
276
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
276
277
|
n[i] = r;
|
|
277
|
-
let a = e[i], o = t.get(
|
|
278
|
+
let a = e[i], o = t.get(N(a.source))?.[0];
|
|
278
279
|
o !== void 0 && (r = Object.freeze({
|
|
279
|
-
source:
|
|
280
|
+
source: B(a.source),
|
|
280
281
|
sourceRunIndex: o
|
|
281
282
|
}));
|
|
282
283
|
}
|
|
283
284
|
let i = Array(e.length), a;
|
|
284
285
|
for (let n = 0; n < e.length; n += 1) {
|
|
285
286
|
i[n] = a;
|
|
286
|
-
let r = e[n], o = t.get(
|
|
287
|
+
let r = e[n], o = t.get(N(r.source))?.at(-1);
|
|
287
288
|
o !== void 0 && (a = Object.freeze({
|
|
288
|
-
source:
|
|
289
|
+
source: B(r.source),
|
|
289
290
|
sourceRunIndex: o
|
|
290
291
|
}));
|
|
291
292
|
}
|
|
@@ -294,17 +295,17 @@ function Tt(e, t) {
|
|
|
294
295
|
preceding: i
|
|
295
296
|
};
|
|
296
297
|
}
|
|
297
|
-
function
|
|
298
|
-
let o = r[e], s = i.get(
|
|
298
|
+
function kt(e, t, n, r, i, a) {
|
|
299
|
+
let o = r[e], s = i.get(N(o.source)) ?? [], c = s[V(s, n)], l = s[V(s, t) - 1], u = c ?? l;
|
|
299
300
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
300
|
-
source:
|
|
301
|
+
source: B(o.source),
|
|
301
302
|
sourceRunIndex: u
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
|
-
function
|
|
305
|
+
function At(e, t, n = /* @__PURE__ */ new Map()) {
|
|
305
306
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
306
307
|
e.forEach((e, t) => {
|
|
307
|
-
let n =
|
|
308
|
+
let n = z(e);
|
|
308
309
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
309
310
|
});
|
|
310
311
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -314,11 +315,11 @@ function Dt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
314
315
|
source: e,
|
|
315
316
|
runs: n.runs
|
|
316
317
|
}] : [];
|
|
317
|
-
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s =
|
|
318
|
+
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Ot(a, o), c = [];
|
|
318
319
|
for (let [e, t] of a.entries()) {
|
|
319
320
|
let n = 0;
|
|
320
321
|
for (; n < t.runs.length;) {
|
|
321
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
322
|
+
let i = t.runs[n], l = i.revision?.kind ? z({
|
|
322
323
|
kind: i.revision.kind,
|
|
323
324
|
id: i.revision.id
|
|
324
325
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -329,16 +330,16 @@ function Dt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
329
330
|
let d = n;
|
|
330
331
|
for (n += 1; n < t.runs.length;) {
|
|
331
332
|
let e = t.runs[n].revision;
|
|
332
|
-
if (!e?.kind ||
|
|
333
|
+
if (!e?.kind || z({
|
|
333
334
|
kind: e.kind,
|
|
334
335
|
id: e.id
|
|
335
336
|
}) !== l) break;
|
|
336
337
|
n += 1;
|
|
337
338
|
}
|
|
338
|
-
let f = n, p = o.get(
|
|
339
|
+
let f = n, p = o.get(N(t.source)) ?? [], m = (p[V(p, d)] ?? f) < f ? void 0 : kt(e, d, f, a, o, s);
|
|
339
340
|
c.push(Object.freeze({
|
|
340
341
|
revisionIndex: u,
|
|
341
|
-
source:
|
|
342
|
+
source: B(t.source),
|
|
342
343
|
startRunIndex: d,
|
|
343
344
|
endRunIndex: f,
|
|
344
345
|
...m === void 0 ? {} : { geometryFallback: m }
|
|
@@ -347,26 +348,26 @@ function Dt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
347
348
|
}
|
|
348
349
|
return c;
|
|
349
350
|
}
|
|
350
|
-
function
|
|
351
|
+
function jt(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
351
352
|
if ((e?.length ?? 0) === 0) return [];
|
|
352
|
-
let i =
|
|
353
|
+
let i = At(e ?? [], t, n), a = r.completedSourceKeys;
|
|
353
354
|
return a === void 0 ? i : i.filter((e) => {
|
|
354
|
-
let t = n.get(
|
|
355
|
-
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(
|
|
355
|
+
let t = n.get(N(e.source));
|
|
356
|
+
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(N(e.source));
|
|
356
357
|
});
|
|
357
358
|
}
|
|
358
|
-
function
|
|
359
|
-
let n = t.filter((t) => t.sourceRunIndex !== void 0 &&
|
|
359
|
+
function Mt(e, t) {
|
|
360
|
+
let n = t.filter((t) => t.sourceRunIndex !== void 0 && Dt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
|
|
360
361
|
if (n.length > 0) return n;
|
|
361
362
|
let r = e.geometryFallback;
|
|
362
|
-
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex &&
|
|
363
|
+
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && Dt(e.source, r.source));
|
|
363
364
|
}
|
|
364
365
|
//#endregion
|
|
365
366
|
//#region packages/docx/src/layout/progressive.ts
|
|
366
|
-
var
|
|
367
|
-
async function
|
|
367
|
+
var Nt = 12;
|
|
368
|
+
async function Pt(e, t, n, r = {}) {
|
|
368
369
|
let { onPreview: i, scheduler: a } = r;
|
|
369
|
-
return Fe(ke(e, t, n, i && e.sequence.length >
|
|
370
|
+
return Fe(ke(e, t, n, i && e.sequence.length > Nt ? { onPages: (e, t) => {
|
|
370
371
|
i(Object.freeze({
|
|
371
372
|
layout: e,
|
|
372
373
|
exact: !1,
|
|
@@ -376,10 +377,10 @@ async function jt(e, t, n, r = {}) {
|
|
|
376
377
|
}
|
|
377
378
|
//#endregion
|
|
378
379
|
//#region packages/docx/src/document-layout-events.ts
|
|
379
|
-
var
|
|
380
|
-
function
|
|
380
|
+
var H = /* @__PURE__ */ new WeakMap();
|
|
381
|
+
function U(e, t) {
|
|
381
382
|
let n = Object.freeze({ ...t });
|
|
382
|
-
for (let t of [...
|
|
383
|
+
for (let t of [...H.get(e) ?? []]) try {
|
|
383
384
|
t.notify(n);
|
|
384
385
|
} catch (e) {
|
|
385
386
|
try {
|
|
@@ -387,9 +388,9 @@ function H(e, t) {
|
|
|
387
388
|
} catch {}
|
|
388
389
|
}
|
|
389
390
|
}
|
|
390
|
-
function
|
|
391
|
-
let i =
|
|
392
|
-
i || (i = /* @__PURE__ */ new Set(),
|
|
391
|
+
function Ft(e, t, n, r) {
|
|
392
|
+
let i = H.get(e);
|
|
393
|
+
i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
|
|
393
394
|
let a = Object.freeze({
|
|
394
395
|
notify: n,
|
|
395
396
|
report: r
|
|
@@ -403,41 +404,41 @@ function Mt(e, t, n, r) {
|
|
|
403
404
|
} catch {}
|
|
404
405
|
}
|
|
405
406
|
return () => {
|
|
406
|
-
i?.delete(a), i?.size === 0 &&
|
|
407
|
+
i?.delete(a), i?.size === 0 && H.delete(e);
|
|
407
408
|
};
|
|
408
409
|
}
|
|
409
410
|
//#endregion
|
|
410
411
|
//#region packages/docx/src/document-layout-view.ts
|
|
411
|
-
var
|
|
412
|
-
function
|
|
413
|
-
let t =
|
|
412
|
+
var W = /* @__PURE__ */ new WeakMap(), It = /* @__PURE__ */ new WeakMap(), Lt = Symbol("docxLayoutViewRequester");
|
|
413
|
+
function G(e) {
|
|
414
|
+
let t = E(e), n = t.activeLayoutOptions;
|
|
414
415
|
return {
|
|
415
416
|
showTrackedChanges: n?.showTrackedChanges === !0,
|
|
416
417
|
currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
|
|
417
418
|
};
|
|
418
419
|
}
|
|
419
|
-
async function
|
|
420
|
-
let r =
|
|
420
|
+
async function K(e, t, n) {
|
|
421
|
+
let r = E(e), i = O(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
421
422
|
showTrackedChanges: i.showTrackedChanges === !0,
|
|
422
423
|
currentDate: i.currentDateMs
|
|
423
424
|
}), o = {
|
|
424
425
|
showTrackedChanges: a.showTrackedChanges,
|
|
425
426
|
currentDate: a.currentDate,
|
|
426
|
-
[
|
|
427
|
+
[Lt]: n
|
|
427
428
|
};
|
|
428
429
|
await e.setLayoutView(o);
|
|
429
|
-
let s =
|
|
430
|
+
let s = G(e);
|
|
430
431
|
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
431
432
|
}
|
|
432
|
-
function
|
|
433
|
-
let n = Object.freeze({ ...
|
|
434
|
-
|
|
433
|
+
function Rt(e, t) {
|
|
434
|
+
let n = Object.freeze({ ...G(e) }), r = (It.get(e) ?? 0) + 1;
|
|
435
|
+
It.set(e, r);
|
|
435
436
|
let i = Object.freeze({
|
|
436
437
|
view: n,
|
|
437
438
|
generation: r,
|
|
438
439
|
requester: t
|
|
439
440
|
});
|
|
440
|
-
for (let t of [...
|
|
441
|
+
for (let t of [...W.get(e) ?? []]) try {
|
|
441
442
|
t.notify(i);
|
|
442
443
|
} catch (e) {
|
|
443
444
|
try {
|
|
@@ -445,23 +446,23 @@ function Ft(e, t) {
|
|
|
445
446
|
} catch {}
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
|
-
function
|
|
449
|
-
let r =
|
|
450
|
-
r || (r = /* @__PURE__ */ new Set(),
|
|
449
|
+
function zt(e, t, n) {
|
|
450
|
+
let r = W.get(e);
|
|
451
|
+
r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
|
|
451
452
|
let i = Object.freeze({
|
|
452
453
|
notify: t,
|
|
453
454
|
report: n
|
|
454
455
|
});
|
|
455
456
|
return r.add(i), () => {
|
|
456
|
-
r?.delete(i), r?.size === 0 &&
|
|
457
|
+
r?.delete(i), r?.size === 0 && W.delete(e);
|
|
457
458
|
};
|
|
458
459
|
}
|
|
459
460
|
//#endregion
|
|
460
461
|
//#region packages/docx/src/document.ts
|
|
461
|
-
function
|
|
462
|
+
function Bt(e, t) {
|
|
462
463
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
463
464
|
}
|
|
464
|
-
function
|
|
465
|
+
function Vt() {
|
|
465
466
|
let e, t;
|
|
466
467
|
return {
|
|
467
468
|
promise: new Promise((n, r) => {
|
|
@@ -471,22 +472,22 @@ function Rt() {
|
|
|
471
472
|
reject: t
|
|
472
473
|
};
|
|
473
474
|
}
|
|
474
|
-
var
|
|
475
|
+
var Ht = Object.freeze([]), Ut = Object.freeze([]), Wt = Object.freeze({
|
|
475
476
|
comments: Object.freeze([]),
|
|
476
477
|
revisions: Object.freeze([])
|
|
477
478
|
});
|
|
478
|
-
function
|
|
479
|
+
function q(e, t) {
|
|
479
480
|
return Ee({
|
|
480
481
|
comments: e,
|
|
481
482
|
revisions: t
|
|
482
483
|
}, "DOCX review metadata");
|
|
483
484
|
}
|
|
484
|
-
var
|
|
485
|
+
var J = class e {
|
|
485
486
|
_metrics = null;
|
|
486
487
|
_document = null;
|
|
487
488
|
_source = null;
|
|
488
489
|
_meta = null;
|
|
489
|
-
_review =
|
|
490
|
+
_review = Wt;
|
|
490
491
|
_layoutLifecycle = new be();
|
|
491
492
|
_layoutObservers = new Ce();
|
|
492
493
|
_layoutCompletion = null;
|
|
@@ -515,12 +516,12 @@ var q = class e {
|
|
|
515
516
|
_googleFontFaces = [];
|
|
516
517
|
_localMetricFontFaces = [];
|
|
517
518
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
518
|
-
constructor(e, t, n,
|
|
519
|
-
this._worker = e, this._mode = t, De(this, n), this._bridge = new
|
|
519
|
+
constructor(e, t, n, i) {
|
|
520
|
+
this._worker = e, this._mode = t, De(this, n), this._bridge = new pe(this._worker, {
|
|
520
521
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
521
522
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
522
523
|
toError: (e) => {
|
|
523
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
524
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(r(e), {
|
|
524
525
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
525
526
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
526
527
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -528,14 +529,14 @@ var q = class e {
|
|
|
528
529
|
});
|
|
529
530
|
}
|
|
530
531
|
});
|
|
531
|
-
let
|
|
532
|
+
let a = new URL(i ?? ot, location.href).href;
|
|
532
533
|
this._bridge.post({
|
|
533
534
|
type: "init",
|
|
534
|
-
wasmUrl:
|
|
535
|
+
wasmUrl: a
|
|
535
536
|
});
|
|
536
537
|
}
|
|
537
|
-
static async load(
|
|
538
|
-
let a = t(i), o = Date.now(), s = i.mode ?? "main", c = new
|
|
538
|
+
static async load(r, i = {}) {
|
|
539
|
+
let a = t(i), o = Date.now(), s = i.mode ?? "main", c = new n({
|
|
539
540
|
enabled: !0,
|
|
540
541
|
format: "docx",
|
|
541
542
|
mode: s,
|
|
@@ -546,34 +547,34 @@ var q = class e {
|
|
|
546
547
|
try {
|
|
547
548
|
if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
548
549
|
let t;
|
|
549
|
-
if (typeof
|
|
550
|
-
let e = await fetch(
|
|
550
|
+
if (typeof r == "string") {
|
|
551
|
+
let e = await fetch(r);
|
|
551
552
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
552
553
|
t = await e.arrayBuffer();
|
|
553
|
-
} else t =
|
|
554
|
-
t =
|
|
555
|
-
let
|
|
554
|
+
} else t = r;
|
|
555
|
+
t = m(await h(t, i.password)), c.setSourceBytes(t.byteLength), c.checkpoint("container ready");
|
|
556
|
+
let n = s === "worker" ? (await import("./render-worker-host-GZ7ez-l3.js")).createRenderWorker() : new at(), l = s === "worker" ? Qe(i) : void 0, u = s === "worker" && !!i.progressiveLayout, d;
|
|
556
557
|
try {
|
|
557
|
-
d = new e(
|
|
558
|
-
let
|
|
559
|
-
if (
|
|
558
|
+
d = new e(n, s, o, i.wasmUrl), d._metrics = c;
|
|
559
|
+
let r = E(d), f = O(i.currentDate, r.defaultCurrentDateMs, i.showTrackedChanges === !0);
|
|
560
|
+
if (r.activeLayoutOptions = f, await d._parse(t, a.policy, s === "worker" ? !!i.useGoogleFonts : !1, i.workerTimeoutMs, (e) => c.observeUsage(e), l, u ? {
|
|
560
561
|
onPartial: i.onLayoutPartial,
|
|
561
562
|
onComplete: i.onLayoutComplete,
|
|
562
563
|
onProgress: i.onLayoutProgress,
|
|
563
564
|
layoutOptions: f,
|
|
564
565
|
abort: new AbortController(),
|
|
565
|
-
firstPublication:
|
|
566
|
+
firstPublication: Vt(),
|
|
566
567
|
published: !1,
|
|
567
568
|
settled: !1
|
|
568
|
-
} : void 0), s === "worker" && d._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), i.math && d._mode === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), i.threeD && d._mode === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), d._threeD = d._mode === "worker" ? void 0 : i.threeD, i.regionMap && d._mode === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), d._regionMap = d._mode === "worker" ? void 0 : i.regionMap, i.chartEx && d._mode === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), d._chartEx = d._mode === "worker" ? void 0 : i.chartEx, i.tiff && d._mode === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; TIFF images will
|
|
569
|
+
} : void 0), s === "worker" && d._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), i.math && d._mode === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), i.threeD && d._mode === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), d._threeD = d._mode === "worker" ? void 0 : i.threeD, i.regionMap && d._mode === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), d._regionMap = d._mode === "worker" ? void 0 : i.regionMap, i.chartEx && d._mode === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), d._chartEx = d._mode === "worker" ? void 0 : i.chartEx, i.tiff && d._mode === "worker" && !l?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), d._tiff = d._mode === "worker" ? void 0 : i.tiff, d._mode === "main" && i.useGoogleFonts && d._document && (d._googleFontFaces = await _e(He(d._document), Pe)), d._mode === "main" && d._document?.embeddedFonts?.length) {
|
|
569
570
|
let e = d;
|
|
570
|
-
d._embeddedFontFaces = await
|
|
571
|
+
d._embeddedFontFaces = await ct(d._document, (t) => e.getFontBytes(t));
|
|
571
572
|
}
|
|
572
573
|
let p;
|
|
573
574
|
d._mode === "main" && d._document && (p = await Ne(d._document), d._localMetricFontFaces = p.faces);
|
|
574
575
|
let m;
|
|
575
576
|
if (d._mode === "main" && i.math && d._document && Ve(d._document) && (m = await Ue(d._document, i.math)), d._mode === "main" && d._document && d._source) {
|
|
576
|
-
let e = d, t =
|
|
577
|
+
let e = d, t = E(d);
|
|
577
578
|
t.services = ze(d._source, {
|
|
578
579
|
localMetrics: p?.metrics,
|
|
579
580
|
useGoogleFonts: !!i.useGoogleFonts,
|
|
@@ -588,8 +589,8 @@ var q = class e {
|
|
|
588
589
|
if (a && i.progressiveLayout) {
|
|
589
590
|
let e = r.layoutVariants, t = d, a = new AbortController();
|
|
590
591
|
t._layoutAbort = a;
|
|
591
|
-
let c =
|
|
592
|
-
t._layoutCompletion =
|
|
592
|
+
let c = Vt(), l = null, u = !0;
|
|
593
|
+
t._layoutCompletion = Pt(d._source.bodyLayoutInput, n, o, {
|
|
593
594
|
scheduler: {
|
|
594
595
|
...s,
|
|
595
596
|
signal: a.signal
|
|
@@ -601,14 +602,14 @@ var q = class e {
|
|
|
601
602
|
u = !1;
|
|
602
603
|
return;
|
|
603
604
|
}
|
|
604
|
-
if (l = a, r) t._layoutLifecycle.begin(),
|
|
605
|
+
if (l = a, r) t._layoutLifecycle.begin(), U(t, {
|
|
605
606
|
pageCount: n.layout.pages.length,
|
|
606
607
|
exact: n.exact,
|
|
607
608
|
complete: !1
|
|
608
609
|
}), c.resolve();
|
|
609
610
|
else {
|
|
610
611
|
if (!t._isLayoutViewActive(o)) return;
|
|
611
|
-
|
|
612
|
+
U(t, {
|
|
612
613
|
pageCount: n.layout.pages.length,
|
|
613
614
|
exact: n.exact,
|
|
614
615
|
complete: !1
|
|
@@ -619,7 +620,7 @@ var q = class e {
|
|
|
619
620
|
}
|
|
620
621
|
}
|
|
621
622
|
}).then((n) => {
|
|
622
|
-
u && t._replaceMainLayoutPublication(e, o, l, n) === null && (u = !1), t._layoutLifecycle.succeed(),
|
|
623
|
+
u && t._replaceMainLayoutPublication(e, o, l, n) === null && (u = !1), t._layoutLifecycle.succeed(), U(t, {
|
|
623
624
|
pageCount: t.pageCount,
|
|
624
625
|
exact: !0,
|
|
625
626
|
complete: !0
|
|
@@ -634,7 +635,7 @@ var q = class e {
|
|
|
634
635
|
return;
|
|
635
636
|
}
|
|
636
637
|
let n = t._layoutLifecycle.fail(e);
|
|
637
|
-
|
|
638
|
+
U(t, {
|
|
638
639
|
pageCount: t.pageCount,
|
|
639
640
|
exact: !1,
|
|
640
641
|
complete: !1,
|
|
@@ -649,7 +650,7 @@ var q = class e {
|
|
|
649
650
|
return await d._resourceUsage(i.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: d.pageCount }), d;
|
|
650
651
|
} catch (e) {
|
|
651
652
|
let t = d;
|
|
652
|
-
throw
|
|
653
|
+
throw p(n, t ? () => t.destroy() : void 0), e;
|
|
653
654
|
}
|
|
654
655
|
} catch (e) {
|
|
655
656
|
throw c.fail(e), e;
|
|
@@ -666,7 +667,7 @@ var q = class e {
|
|
|
666
667
|
data: e,
|
|
667
668
|
resourcePolicy: t,
|
|
668
669
|
useGoogleFonts: n,
|
|
669
|
-
defaultCurrentDateMs:
|
|
670
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
670
671
|
...this._parseViewFields(),
|
|
671
672
|
renderers: a
|
|
672
673
|
} : {
|
|
@@ -677,23 +678,23 @@ var q = class e {
|
|
|
677
678
|
}, [e], { timeoutMs: r });
|
|
678
679
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
679
680
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
680
|
-
let e = await
|
|
681
|
+
let e = await k(this._bridge.transport(A), s, {
|
|
681
682
|
timeoutMs: r,
|
|
682
683
|
onUsage: i
|
|
683
684
|
});
|
|
684
685
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
685
686
|
} else this._meta = s.meta;
|
|
686
687
|
else {
|
|
687
|
-
let e = s, t = await
|
|
688
|
+
let e = s, t = await k(this._bridge.transport(A), e, {
|
|
688
689
|
timeoutMs: r,
|
|
689
690
|
onUsage: i
|
|
690
691
|
});
|
|
691
692
|
this._source = t.source, this._document = t.document;
|
|
692
693
|
}
|
|
693
|
-
this._review =
|
|
694
|
+
this._review = q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []);
|
|
694
695
|
}
|
|
695
696
|
_onWorkerLayoutPush(e) {
|
|
696
|
-
if (!("forId" in e) || e.forId !== this._parseRequestId) return;
|
|
697
|
+
if (g((e, t) => this._worker.postMessage(e, t), e) || !("forId" in e) || e.forId !== this._parseRequestId) return;
|
|
697
698
|
this._rearmParseWatchdog();
|
|
698
699
|
let t = this._progressive;
|
|
699
700
|
if (t?.settled) return;
|
|
@@ -705,7 +706,7 @@ var q = class e {
|
|
|
705
706
|
let n = !t.published || this._isLayoutViewActive(t.layoutOptions);
|
|
706
707
|
if (n && this._applyLayoutPartial(e.partial), t.published) {
|
|
707
708
|
if (!n) return;
|
|
708
|
-
|
|
709
|
+
U(this, {
|
|
709
710
|
pageCount: e.partial.pageCount,
|
|
710
711
|
exact: e.partial.exact,
|
|
711
712
|
complete: !1
|
|
@@ -715,7 +716,7 @@ var q = class e {
|
|
|
715
716
|
});
|
|
716
717
|
return;
|
|
717
718
|
}
|
|
718
|
-
t.published = !0, this._layoutLifecycle.begin(),
|
|
719
|
+
t.published = !0, this._layoutLifecycle.begin(), U(this, {
|
|
719
720
|
pageCount: e.partial.pageCount,
|
|
720
721
|
exact: e.partial.exact,
|
|
721
722
|
complete: !1
|
|
@@ -733,7 +734,7 @@ var q = class e {
|
|
|
733
734
|
endnotes: t?.endnotes ?? [],
|
|
734
735
|
commentAnchorRanges: e.commentAnchorRanges,
|
|
735
736
|
revisionAnchorRanges: e.revisionAnchorRanges
|
|
736
|
-
}, e.review && (this._review =
|
|
737
|
+
}, e.review && (this._review = q(e.review.comments, e.review.revisions)), this._invalidateLayoutDerivedCaches();
|
|
737
738
|
}
|
|
738
739
|
_onAuthoritativeMeta(e) {
|
|
739
740
|
this._clearParseWatchdog();
|
|
@@ -751,7 +752,7 @@ var q = class e {
|
|
|
751
752
|
revisionAnchorRanges: t.revisionAnchorRanges
|
|
752
753
|
};
|
|
753
754
|
}
|
|
754
|
-
this._invalidateLayoutDerivedCaches(), this._review =
|
|
755
|
+
this._invalidateLayoutDerivedCaches(), this._review = q(e.comments, e.revisions), t && (t.settled = !0, this._layoutLifecycle.succeed(), U(this, {
|
|
755
756
|
pageCount: this.pageCount,
|
|
756
757
|
exact: !0,
|
|
757
758
|
complete: !0
|
|
@@ -766,7 +767,7 @@ var q = class e {
|
|
|
766
767
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
767
768
|
}
|
|
768
769
|
_isLayoutViewActive(e) {
|
|
769
|
-
return
|
|
770
|
+
return Bt(E(this).activeLayoutOptions, e);
|
|
770
771
|
}
|
|
771
772
|
_rearmParseWatchdog() {
|
|
772
773
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -787,7 +788,7 @@ var q = class e {
|
|
|
787
788
|
return;
|
|
788
789
|
}
|
|
789
790
|
let n = this._layoutLifecycle.fail(t);
|
|
790
|
-
|
|
791
|
+
U(this, {
|
|
791
792
|
pageCount: this.pageCount,
|
|
792
793
|
exact: !1,
|
|
793
794
|
complete: !1,
|
|
@@ -795,7 +796,7 @@ var q = class e {
|
|
|
795
796
|
}), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
|
|
796
797
|
}
|
|
797
798
|
_parseViewFields() {
|
|
798
|
-
let e =
|
|
799
|
+
let e = E(this), t = e.activeLayoutOptions;
|
|
799
800
|
return t ? {
|
|
800
801
|
...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
|
|
801
802
|
...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
|
|
@@ -808,7 +809,7 @@ var q = class e {
|
|
|
808
809
|
data: e,
|
|
809
810
|
resourcePolicy: t,
|
|
810
811
|
useGoogleFonts: n,
|
|
811
|
-
defaultCurrentDateMs:
|
|
812
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
812
813
|
...this._parseViewFields(),
|
|
813
814
|
renderers: a,
|
|
814
815
|
progressiveLayout: !0
|
|
@@ -816,11 +817,11 @@ var q = class e {
|
|
|
816
817
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
817
818
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
818
819
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
819
|
-
let t = await
|
|
820
|
+
let t = await k(this._bridge.transport(A), e, {
|
|
820
821
|
timeoutMs: r,
|
|
821
822
|
onUsage: i
|
|
822
823
|
});
|
|
823
|
-
this._source = t.source, this._document = t.document, this._meta = null, this._mode = "main", this._review =
|
|
824
|
+
this._source = t.source, this._document = t.document, this._meta = null, this._mode = "main", this._review = q(t.document.comments ?? [], t.document.revisions ?? []), o.firstPublication.resolve();
|
|
824
825
|
return;
|
|
825
826
|
}
|
|
826
827
|
this._onAuthoritativeMeta(e.meta);
|
|
@@ -835,7 +836,7 @@ var q = class e {
|
|
|
835
836
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
836
837
|
}
|
|
837
838
|
destroy() {
|
|
838
|
-
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 =
|
|
839
|
+
this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review = Wt, E(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (xe(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (ge(this._googleFontFaces), this._googleFontFaces = []), this._localMetricFontFaces.length > 0 && (Le(this._localMetricFontFaces), this._localMetricFontFaces = []), c(this._fetchImage), u(this._fetchImage);
|
|
839
840
|
}
|
|
840
841
|
async getImage(e, t) {
|
|
841
842
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -864,7 +865,7 @@ var q = class e {
|
|
|
864
865
|
async getResourceMetrics() {
|
|
865
866
|
let e = this._metrics;
|
|
866
867
|
if (!e) throw Error("Document not loaded");
|
|
867
|
-
return
|
|
868
|
+
return f(e, (e) => this._resourceUsage(e));
|
|
868
869
|
}
|
|
869
870
|
async toMarkdown() {
|
|
870
871
|
return (await this._bridge.request((e) => ({
|
|
@@ -896,35 +897,35 @@ var q = class e {
|
|
|
896
897
|
return this._reviewSnapshot().revisions;
|
|
897
898
|
}
|
|
898
899
|
commentAnchorRanges() {
|
|
899
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
900
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? Ht;
|
|
900
901
|
if (!this._document || !this._source) return [];
|
|
901
902
|
let e = this._reviewSnapshot().comments;
|
|
902
|
-
if (e.length === 0) return
|
|
903
|
-
let t =
|
|
903
|
+
if (e.length === 0) return Ht;
|
|
904
|
+
let t = E(this), n = t.services;
|
|
904
905
|
if (!n) throw Error("Document layout services are not initialized");
|
|
905
|
-
let r =
|
|
906
|
+
let r = D(n);
|
|
906
907
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
907
908
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
908
909
|
this._reviewProjectionIndex ??= Ke(a);
|
|
909
910
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
910
|
-
return this._commentAnchorRanges ??=
|
|
911
|
+
return this._commentAnchorRanges ??= nt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
911
912
|
}
|
|
912
913
|
revisionAnchorRanges() {
|
|
913
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
914
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? Ut;
|
|
914
915
|
if (!this._document || !this._source) return [];
|
|
915
916
|
let e = this._reviewSnapshot().revisions;
|
|
916
|
-
if (e.length === 0) return
|
|
917
|
-
let t =
|
|
917
|
+
if (e.length === 0) return Ut;
|
|
918
|
+
let t = E(this), n = t.services;
|
|
918
919
|
if (!n) throw Error("Document layout services are not initialized");
|
|
919
|
-
let r =
|
|
920
|
+
let r = D(n);
|
|
920
921
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
921
922
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
922
923
|
this._reviewProjectionIndex ??= Ke(a);
|
|
923
924
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
924
|
-
return this._revisionAnchorRanges ??=
|
|
925
|
+
return this._revisionAnchorRanges ??= jt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
925
926
|
}
|
|
926
927
|
_reviewSnapshot() {
|
|
927
|
-
return this._review ||=
|
|
928
|
+
return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
928
929
|
}
|
|
929
930
|
get footnotes() {
|
|
930
931
|
return this._meta?.footnotes ?? this._document?.footnotes ?? [];
|
|
@@ -934,16 +935,16 @@ var q = class e {
|
|
|
934
935
|
}
|
|
935
936
|
_getLayout() {
|
|
936
937
|
if (!this._document) return null;
|
|
937
|
-
let e =
|
|
938
|
+
let e = E(this), t = e.services;
|
|
938
939
|
if (!t) throw Error("Document layout services are not initialized");
|
|
939
|
-
let n =
|
|
940
|
+
let n = D(t);
|
|
940
941
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
941
942
|
let r = e.activeLayoutOptions;
|
|
942
943
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
943
944
|
}
|
|
944
945
|
async setLayoutView(e = {}) {
|
|
945
|
-
let t = e[
|
|
946
|
-
if (!
|
|
946
|
+
let t = e[Lt], n = E(this), r = O(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
|
|
947
|
+
if (!Bt(a, r)) {
|
|
947
948
|
if (this._mode === "worker" && this._meta) {
|
|
948
949
|
let e = await this._bridge.request((e) => ({
|
|
949
950
|
type: "selectLayoutView",
|
|
@@ -956,17 +957,17 @@ var q = class e {
|
|
|
956
957
|
n.activeLayoutOptions = r, this._meta = {
|
|
957
958
|
...this._meta,
|
|
958
959
|
...a.meta
|
|
959
|
-
}, this._invalidateLayoutDerivedCaches(),
|
|
960
|
+
}, this._invalidateLayoutDerivedCaches(), Rt(this, t);
|
|
960
961
|
return;
|
|
961
962
|
}
|
|
962
|
-
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(),
|
|
963
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), Rt(this, t);
|
|
963
964
|
}
|
|
964
965
|
}
|
|
965
966
|
_getBookmarkPages() {
|
|
966
967
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
967
968
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
968
969
|
let e = this._getLayout();
|
|
969
|
-
return e ? (this._bookmarkPages =
|
|
970
|
+
return e ? (this._bookmarkPages = st(e), this._bookmarkPages) : null;
|
|
970
971
|
}
|
|
971
972
|
getBookmarkPage(e) {
|
|
972
973
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -998,7 +999,7 @@ var q = class e {
|
|
|
998
999
|
};
|
|
999
1000
|
}
|
|
1000
1001
|
_withActiveView(e) {
|
|
1001
|
-
let t =
|
|
1002
|
+
let t = E(this).activeLayoutOptions;
|
|
1002
1003
|
if (!t) return e;
|
|
1003
1004
|
let n = { ...e };
|
|
1004
1005
|
return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
|
|
@@ -1009,8 +1010,8 @@ var q = class e {
|
|
|
1009
1010
|
return Me(this._source, e, t, {
|
|
1010
1011
|
...this._withActiveView(n),
|
|
1011
1012
|
fetchImage: this._fetchImage,
|
|
1012
|
-
layoutServices:
|
|
1013
|
-
defaultCurrentDateMs:
|
|
1013
|
+
layoutServices: E(this).services ?? void 0,
|
|
1014
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
1014
1015
|
threeD: this._threeD,
|
|
1015
1016
|
regionMap: this._regionMap,
|
|
1016
1017
|
chartEx: this._chartEx,
|
|
@@ -1020,7 +1021,7 @@ var q = class e {
|
|
|
1020
1021
|
async renderPageToBitmap(e, t = {}) {
|
|
1021
1022
|
let { onTextRun: n, ...r } = t, i = {
|
|
1022
1023
|
...this._withActiveView(r),
|
|
1023
|
-
dpr: r.dpr ??
|
|
1024
|
+
dpr: r.dpr ?? o()
|
|
1024
1025
|
};
|
|
1025
1026
|
if (this._mode === "worker") {
|
|
1026
1027
|
let t = await this._bridge.request((t) => ({
|
|
@@ -1029,7 +1030,11 @@ var q = class e {
|
|
|
1029
1030
|
pageIndex: e,
|
|
1030
1031
|
opts: i
|
|
1031
1032
|
}));
|
|
1032
|
-
|
|
1033
|
+
try {
|
|
1034
|
+
if (n) for (let e of t.runs) n(e);
|
|
1035
|
+
} catch (e) {
|
|
1036
|
+
throw d(t.bitmap), e;
|
|
1037
|
+
}
|
|
1033
1038
|
return t.bitmap;
|
|
1034
1039
|
}
|
|
1035
1040
|
let a = new OffscreenCanvas(1, 1);
|
|
@@ -1046,7 +1051,7 @@ var q = class e {
|
|
|
1046
1051
|
pageIndex: e,
|
|
1047
1052
|
opts: n
|
|
1048
1053
|
}))).runs;
|
|
1049
|
-
let r =
|
|
1054
|
+
let r = E(this), i = r.services;
|
|
1050
1055
|
if (!i) throw Error("Document layout services are not initialized");
|
|
1051
1056
|
return qe(i, e, {
|
|
1052
1057
|
currentDate: n.currentDate,
|
|
@@ -1057,7 +1062,7 @@ var q = class e {
|
|
|
1057
1062
|
}
|
|
1058
1063
|
async getCommentThreads(e, t = {}) {
|
|
1059
1064
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1060
|
-
return
|
|
1065
|
+
return tt(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1061
1066
|
}
|
|
1062
1067
|
async getElementContextAt(e, t, n = {}) {
|
|
1063
1068
|
let r = this._withActiveView(n);
|
|
@@ -1068,9 +1073,9 @@ var q = class e {
|
|
|
1068
1073
|
point: t,
|
|
1069
1074
|
opts: r
|
|
1070
1075
|
}))).context;
|
|
1071
|
-
let i =
|
|
1076
|
+
let i = E(this), a = i.services;
|
|
1072
1077
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1073
|
-
return
|
|
1078
|
+
return Tt(a, e, t, {
|
|
1074
1079
|
...r,
|
|
1075
1080
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1076
1081
|
});
|
|
@@ -1078,34 +1083,34 @@ var q = class e {
|
|
|
1078
1083
|
};
|
|
1079
1084
|
//#endregion
|
|
1080
1085
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1081
|
-
function
|
|
1086
|
+
function Gt(e, t) {
|
|
1082
1087
|
if (!e.eastAsianVert) return 1;
|
|
1083
1088
|
let n = t(e.text);
|
|
1084
1089
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
1085
1090
|
}
|
|
1086
1091
|
//#endregion
|
|
1087
1092
|
//#region packages/docx/src/text-layer.ts
|
|
1088
|
-
function
|
|
1093
|
+
function Y(e, t, n) {
|
|
1089
1094
|
e.dataset ? n === void 0 ? delete e.dataset[t] : e.dataset[t] = n : n !== void 0 && e.setAttribute?.(`data-${t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}`, n);
|
|
1090
1095
|
}
|
|
1091
|
-
function
|
|
1092
|
-
e.innerHTML = "",
|
|
1096
|
+
function X(e, t, n, r, i, a, o) {
|
|
1097
|
+
e.innerHTML = "", Y(e, "ooxmlSelectionSurface", "docx"), Y(e, "pageIndex", o === void 0 ? void 0 : String(o));
|
|
1093
1098
|
let s = e.ownerDocument ?? document;
|
|
1094
1099
|
for (let [o, c] of t.entries()) {
|
|
1095
1100
|
let t = s.createElement("span");
|
|
1096
|
-
|
|
1101
|
+
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;
|
|
1097
1102
|
let l = c.transform ?? "";
|
|
1098
1103
|
if (a && c.eastAsianVert) {
|
|
1099
|
-
let e =
|
|
1104
|
+
let e = Gt(c, a(c.font));
|
|
1100
1105
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1101
1106
|
}
|
|
1102
1107
|
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`;
|
|
1103
|
-
t.style.cssText = `position:absolute;left:${
|
|
1108
|
+
t.style.cssText = `position:absolute;left:${M(c.x, n)};top:${M(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
|
|
1104
1109
|
e.preventDefault(), i(d);
|
|
1105
1110
|
})), e.appendChild(t);
|
|
1106
1111
|
}
|
|
1107
1112
|
}
|
|
1108
|
-
function
|
|
1113
|
+
function Z(e, t, n, r, i, a, o = {}) {
|
|
1109
1114
|
e.innerHTML = "";
|
|
1110
1115
|
let s = o.match ?? "rgba(255, 214, 0, 0.42)", c = o.active ?? "rgba(255, 140, 0, 0.55)";
|
|
1111
1116
|
for (let o of n) {
|
|
@@ -1113,16 +1118,16 @@ function X(e, t, n, r, i, a, o = {}) {
|
|
|
1113
1118
|
for (let s of o.slices) {
|
|
1114
1119
|
let o = t[s.runIndex];
|
|
1115
1120
|
if (!o) continue;
|
|
1116
|
-
let c = a(o.font), l =
|
|
1117
|
-
if (
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1121
|
+
let c = a(o.font), l = $e(o.text, s.start, s.end, c), u = o.letterSpacingPx ?? 0, d = Math.max(0, Math.min(s.start, o.text.length)), f = Math.max(d, Math.min(s.end, o.text.length)), p = [...o.text.slice(0, d)].length, m = [...o.text.slice(d, f)].length, h = l.x + p * u, g = l.width + Math.max(0, m - 1) * u, _ = Gt(o, c), v = h * _, y = g * _;
|
|
1122
|
+
if (y <= 0) continue;
|
|
1123
|
+
let b = document.createElement("div"), x = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
1124
|
+
b.style.cssText = `position:absolute;left:${M(o.x + v, r)};top:${M(o.y, i)};width:${M(y, r)};height:${M(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
|
|
1120
1125
|
}
|
|
1121
1126
|
}
|
|
1122
1127
|
}
|
|
1123
1128
|
//#endregion
|
|
1124
1129
|
//#region packages/docx/src/find.ts
|
|
1125
|
-
var
|
|
1130
|
+
var Kt = class {
|
|
1126
1131
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1127
1132
|
_matches = [];
|
|
1128
1133
|
_active = -1;
|
|
@@ -1214,7 +1219,7 @@ var Ut = class {
|
|
|
1214
1219
|
};
|
|
1215
1220
|
//#endregion
|
|
1216
1221
|
//#region packages/docx/src/selection-context.ts
|
|
1217
|
-
function
|
|
1222
|
+
function qt(e, t, n, r, i = {}) {
|
|
1218
1223
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1219
1224
|
if (!a) return null;
|
|
1220
1225
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1257,19 +1262,19 @@ function Wt(e, t, n, r, i = {}) {
|
|
|
1257
1262
|
maxTextCharacters: c.maxTextCharacters
|
|
1258
1263
|
});
|
|
1259
1264
|
}
|
|
1260
|
-
function
|
|
1265
|
+
function Jt(e) {
|
|
1261
1266
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1262
1267
|
let t = Number(e);
|
|
1263
1268
|
return Number.isSafeInteger(t) ? t : null;
|
|
1264
1269
|
}
|
|
1265
|
-
function
|
|
1270
|
+
function Yt(e) {
|
|
1266
1271
|
for (let t = e; t; t = t.parentElement) {
|
|
1267
|
-
let e =
|
|
1272
|
+
let e = Jt(t.dataset.pageIndex);
|
|
1268
1273
|
if (e !== null) return e;
|
|
1269
1274
|
}
|
|
1270
1275
|
return null;
|
|
1271
1276
|
}
|
|
1272
|
-
var
|
|
1277
|
+
var Xt = new Set([
|
|
1273
1278
|
"body",
|
|
1274
1279
|
"header",
|
|
1275
1280
|
"footer",
|
|
@@ -1277,9 +1282,9 @@ var Kt = new Set([
|
|
|
1277
1282
|
"endnote",
|
|
1278
1283
|
"textbox"
|
|
1279
1284
|
]);
|
|
1280
|
-
function
|
|
1285
|
+
function Zt(e) {
|
|
1281
1286
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1282
|
-
if (!t || !
|
|
1287
|
+
if (!t || !Xt.has(t) || !n || !r) return null;
|
|
1283
1288
|
try {
|
|
1284
1289
|
let e = JSON.parse(r);
|
|
1285
1290
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1293,12 +1298,12 @@ function qt(e) {
|
|
|
1293
1298
|
}
|
|
1294
1299
|
function Q(e, t, n = {}) {
|
|
1295
1300
|
let r = le(e, t, (e) => {
|
|
1296
|
-
let t =
|
|
1301
|
+
let t = Yt(e), n = Jt(e.dataset.runIndex);
|
|
1297
1302
|
return t === null || n === null ? null : {
|
|
1298
1303
|
pageIndex: t,
|
|
1299
1304
|
runIndex: n,
|
|
1300
1305
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1301
|
-
...
|
|
1306
|
+
...Zt(e) === null ? {} : { source: Zt(e) }
|
|
1302
1307
|
};
|
|
1303
1308
|
}, {
|
|
1304
1309
|
maxChars: n.maxTextCharacters,
|
|
@@ -1327,7 +1332,7 @@ function $(e, t, n, r, i) {
|
|
|
1327
1332
|
}
|
|
1328
1333
|
//#endregion
|
|
1329
1334
|
//#region packages/docx/src/viewer.ts
|
|
1330
|
-
var
|
|
1335
|
+
var Qt = Symbol("DocxViewer.borrowedDocument"), $t = class e {
|
|
1331
1336
|
_documentOwner;
|
|
1332
1337
|
get _doc() {
|
|
1333
1338
|
return this._documentOwner.current;
|
|
@@ -1365,24 +1370,24 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1365
1370
|
_elementClickListener = null;
|
|
1366
1371
|
_contextMenuListener = null;
|
|
1367
1372
|
static fromDocument(t, n, r = {}) {
|
|
1368
|
-
let i =
|
|
1373
|
+
let i = G(n);
|
|
1369
1374
|
return new e(t, {
|
|
1370
1375
|
...r,
|
|
1371
1376
|
currentDate: i.currentDate,
|
|
1372
1377
|
showTrackedChanges: i.showTrackedChanges,
|
|
1373
|
-
[
|
|
1378
|
+
[Qt]: n
|
|
1374
1379
|
});
|
|
1375
1380
|
}
|
|
1376
1381
|
constructor(e, t = {}) {
|
|
1377
1382
|
this._canvas = e, this._opts = t;
|
|
1378
|
-
let n = t[
|
|
1379
|
-
this._borrowed = n !== void 0, this._mode =
|
|
1383
|
+
let n = t[Qt];
|
|
1384
|
+
this._borrowed = n !== void 0, this._mode = C("DocxViewer", t.mode, n), this._documentOwner = new y("DocxViewer", n ?? null, !1);
|
|
1380
1385
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1381
1386
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
1382
1387
|
this._hostWindow = r, this._canvasMount = new ue(e, {
|
|
1383
1388
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1384
1389
|
forceDisplayBlock: !0
|
|
1385
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new
|
|
1390
|
+
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new S(e, this._mode === "worker"), this._errorRouter = new ce("DocxViewer", t.onError);
|
|
1386
1391
|
let i = new ae(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1387
1392
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
|
|
1388
1393
|
"position:absolute",
|
|
@@ -1397,14 +1402,14 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1397
1402
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1398
1403
|
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) => {
|
|
1399
1404
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1400
|
-
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new
|
|
1405
|
+
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new Kt(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
|
|
1401
1406
|
}
|
|
1402
1407
|
async load(e) {
|
|
1403
1408
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1404
1409
|
if (this._borrowed) throw Error("DocxViewer.load() is unsupported on a Viewer created by fromDocument(); the borrowed document is already loaded.");
|
|
1405
1410
|
let t = !1;
|
|
1406
1411
|
try {
|
|
1407
|
-
let n = await this._documentOwner.replace(() =>
|
|
1412
|
+
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1408
1413
|
password: this._opts.password,
|
|
1409
1414
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1410
1415
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
@@ -1417,6 +1422,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1417
1422
|
threeD: this._opts.threeD,
|
|
1418
1423
|
regionMap: this._opts.regionMap,
|
|
1419
1424
|
chartEx: this._opts.chartEx,
|
|
1425
|
+
tiff: this._opts.tiff,
|
|
1420
1426
|
mode: this._mode,
|
|
1421
1427
|
...this._opts.progressiveLayout ? { progressiveLayout: !0 } : {},
|
|
1422
1428
|
...this._opts.sliceLayout ? { sliceLayout: !0 } : {},
|
|
@@ -1476,7 +1482,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1476
1482
|
await this.goToPage(this._currentPage - 1);
|
|
1477
1483
|
}
|
|
1478
1484
|
_naturalWidthPx() {
|
|
1479
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
1485
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * j;
|
|
1480
1486
|
}
|
|
1481
1487
|
_renderWidth() {
|
|
1482
1488
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1514,9 +1520,9 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1514
1520
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
1515
1521
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1516
1522
|
if (!n) return;
|
|
1517
|
-
let r =
|
|
1518
|
-
contentWidth: t.widthPt *
|
|
1519
|
-
contentHeight: t.heightPt *
|
|
1523
|
+
let r = v({
|
|
1524
|
+
contentWidth: t.widthPt * j,
|
|
1525
|
+
contentHeight: t.heightPt * j,
|
|
1520
1526
|
containerWidth: n.clientWidth,
|
|
1521
1527
|
containerHeight: n.clientHeight
|
|
1522
1528
|
}, e);
|
|
@@ -1555,7 +1561,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1555
1561
|
}
|
|
1556
1562
|
getSelectionContext(e = {}) {
|
|
1557
1563
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1558
|
-
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ?
|
|
1564
|
+
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Et(this._elementContext, e.maxTextCharacters) : null);
|
|
1559
1565
|
}
|
|
1560
1566
|
_emitSelectionContextChange() {
|
|
1561
1567
|
let e = this.getSelectionContext();
|
|
@@ -1572,11 +1578,11 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1572
1578
|
_redrawElementOutline() {
|
|
1573
1579
|
let e = this._elementContext, t = this._doc;
|
|
1574
1580
|
if (!e || !t || e.pageIndex !== this._currentPage) {
|
|
1575
|
-
|
|
1581
|
+
x(this._elementLayer, null);
|
|
1576
1582
|
return;
|
|
1577
1583
|
}
|
|
1578
1584
|
let n = t.pageSize(e.pageIndex);
|
|
1579
|
-
|
|
1585
|
+
x(this._elementLayer, {
|
|
1580
1586
|
x: e.bounds.xPt / n.widthPt,
|
|
1581
1587
|
y: e.bounds.yPt / n.heightPt,
|
|
1582
1588
|
width: e.bounds.widthPt / n.widthPt,
|
|
@@ -1610,7 +1616,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1610
1616
|
}, {
|
|
1611
1617
|
currentDate: this._opts.currentDate,
|
|
1612
1618
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1613
|
-
maxTextCharacters:
|
|
1619
|
+
maxTextCharacters: F
|
|
1614
1620
|
});
|
|
1615
1621
|
} catch (e) {
|
|
1616
1622
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1638,6 +1644,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1638
1644
|
let t = this._mode === "worker", n = this._renderWidth(), r = this._doc.pageSize(this._currentPage), i = n ?? r.widthPt * 1.3333333333333333, a = r.widthPt > 0 ? i * r.heightPt / r.widthPt : 0, o = [], s = (e) => o.push(e), c = this._opts.dpr ?? (typeof window < "u" && window.devicePixelRatio || 1), l = {
|
|
1639
1645
|
width: n,
|
|
1640
1646
|
dpr: this._opts.dpr,
|
|
1647
|
+
imageResources: this._opts.imageResources,
|
|
1641
1648
|
defaultTextColor: this._opts.defaultTextColor,
|
|
1642
1649
|
currentDate: this._opts.currentDate,
|
|
1643
1650
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
@@ -1654,7 +1661,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1654
1661
|
}
|
|
1655
1662
|
_bindLayoutDocument(e) {
|
|
1656
1663
|
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1657
|
-
let t =
|
|
1664
|
+
let t = zt(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Ft(e, () => ({
|
|
1658
1665
|
pageCount: e.pageCount,
|
|
1659
1666
|
exact: e.layoutComplete,
|
|
1660
1667
|
complete: e.layoutComplete
|
|
@@ -1710,7 +1717,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1710
1717
|
async setShowTrackedChanges(e) {
|
|
1711
1718
|
let t = ++this._layoutViewGeneration, n = this._doc;
|
|
1712
1719
|
if (this._opts.showTrackedChanges === !0 === e) {
|
|
1713
|
-
n && await
|
|
1720
|
+
n && await K(n, {
|
|
1714
1721
|
showTrackedChanges: e,
|
|
1715
1722
|
currentDate: this._opts.currentDate
|
|
1716
1723
|
}, this);
|
|
@@ -1720,7 +1727,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1720
1727
|
...this._opts,
|
|
1721
1728
|
showTrackedChanges: e
|
|
1722
1729
|
};
|
|
1723
|
-
(!n || await
|
|
1730
|
+
(!n || await K(n, {
|
|
1724
1731
|
showTrackedChanges: e,
|
|
1725
1732
|
currentDate: r.currentDate
|
|
1726
1733
|
}, this)) && (this._destroyed || t !== this._layoutViewGeneration || n !== this._doc || (this._opts = r, this._find.invalidate(), this._currentPage = Math.max(0, Math.min(this._currentPage, this.pageCount - 1)), await this._render()));
|
|
@@ -1729,7 +1736,7 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1729
1736
|
let t = this._highlightLayer;
|
|
1730
1737
|
if (!t) return;
|
|
1731
1738
|
let { width: n, height: r } = this._canvasCssPx();
|
|
1732
|
-
|
|
1739
|
+
Z(t, e, this._find.pageHighlights(this._currentPage), n, r, (e) => this._measureForFont(e), this._opts.findHighlightColors);
|
|
1733
1740
|
}
|
|
1734
1741
|
_canvasCssPx() {
|
|
1735
1742
|
return {
|
|
@@ -1751,12 +1758,12 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1751
1758
|
}
|
|
1752
1759
|
_buildTextLayer(e, t) {
|
|
1753
1760
|
let { width: n, height: r } = this._canvasCssPx();
|
|
1754
|
-
|
|
1761
|
+
X(e, t, n, r, this._hyperlinkHandler(), (e) => this._measureForFont(e), this._currentPage);
|
|
1755
1762
|
}
|
|
1756
1763
|
_hyperlinkHandler() {
|
|
1757
1764
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
1758
1765
|
if (e.kind === "external") {
|
|
1759
|
-
|
|
1766
|
+
a(e.url, void 0, this._hostWindow);
|
|
1760
1767
|
return;
|
|
1761
1768
|
}
|
|
1762
1769
|
let t = this._doc;
|
|
@@ -1770,11 +1777,11 @@ var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
|
1770
1777
|
let r = e.getBookmarkPage(t);
|
|
1771
1778
|
r !== void 0 && await this.goToPage(r);
|
|
1772
1779
|
}
|
|
1773
|
-
},
|
|
1774
|
-
function
|
|
1775
|
-
return
|
|
1780
|
+
}, en = 150, tn = "0 1px 3px rgba(0,0,0,0.2)", nn = 12, rn = 13, an = Symbol("DocxScrollViewer.borrowedDocument"), on;
|
|
1781
|
+
function sn() {
|
|
1782
|
+
return on ??= import("./comment-ui-runtime-DAKBCpsM.js");
|
|
1776
1783
|
}
|
|
1777
|
-
var
|
|
1784
|
+
var cn = class e {
|
|
1778
1785
|
_documentOwner;
|
|
1779
1786
|
get _doc() {
|
|
1780
1787
|
return this._documentOwner.current;
|
|
@@ -1838,7 +1845,7 @@ var rn = class e {
|
|
|
1838
1845
|
_prevBase = 0;
|
|
1839
1846
|
_lastFitWidth = 0;
|
|
1840
1847
|
_pageShadow;
|
|
1841
|
-
_find = new
|
|
1848
|
+
_find = new Kt(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
1842
1849
|
_findActive = !1;
|
|
1843
1850
|
_findRequestGeneration = 0;
|
|
1844
1851
|
_showTrackedChanges;
|
|
@@ -1846,19 +1853,19 @@ var rn = class e {
|
|
|
1846
1853
|
_layoutViewGeneration = 0;
|
|
1847
1854
|
_layoutViewPublicationGeneration = 0;
|
|
1848
1855
|
static fromDocument(t, n, r = {}) {
|
|
1849
|
-
let i =
|
|
1856
|
+
let i = G(n);
|
|
1850
1857
|
return new e(t, {
|
|
1851
1858
|
...r,
|
|
1852
1859
|
currentDate: i.currentDate,
|
|
1853
1860
|
showTrackedChanges: i.showTrackedChanges,
|
|
1854
|
-
[
|
|
1861
|
+
[an]: n
|
|
1855
1862
|
});
|
|
1856
1863
|
}
|
|
1857
1864
|
constructor(e, t = {}) {
|
|
1858
1865
|
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.");
|
|
1859
|
-
this._container = e, this._opts = t, this._errorRouter = new ce("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ??
|
|
1860
|
-
let n = t[
|
|
1861
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new
|
|
1866
|
+
this._container = e, this._opts = t, this._errorRouter = new ce("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ?? tn;
|
|
1867
|
+
let n = t[an];
|
|
1868
|
+
this._borrowed = n !== void 0, n ? (this._documentOwner = new y("DocxScrollViewer", n, !1), this._mode = C("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new y("DocxScrollViewer"), this._mode = C("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && sn().then((e) => {
|
|
1862
1869
|
if (!this._destroyed) {
|
|
1863
1870
|
this._commentUi = e;
|
|
1864
1871
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -1885,7 +1892,7 @@ var rn = class e {
|
|
|
1885
1892
|
if (this._borrowed) throw Error("DocxScrollViewer.load() is unsupported on a Viewer created by fromDocument(); the borrowed document is already loaded.");
|
|
1886
1893
|
let t = !1;
|
|
1887
1894
|
try {
|
|
1888
|
-
let n = await this._documentOwner.replace(() =>
|
|
1895
|
+
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1889
1896
|
password: this._opts.password,
|
|
1890
1897
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1891
1898
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
@@ -1898,6 +1905,7 @@ var rn = class e {
|
|
|
1898
1905
|
threeD: this._opts.threeD,
|
|
1899
1906
|
regionMap: this._opts.regionMap,
|
|
1900
1907
|
chartEx: this._opts.chartEx,
|
|
1908
|
+
tiff: this._opts.tiff,
|
|
1901
1909
|
mode: this._mode,
|
|
1902
1910
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
1903
1911
|
...this._currentDate === void 0 ? {} : { currentDate: this._currentDate },
|
|
@@ -1935,7 +1943,7 @@ var rn = class e {
|
|
|
1935
1943
|
}
|
|
1936
1944
|
_bindLayoutDocument(e) {
|
|
1937
1945
|
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount, this._pendingLayoutPublication = null;
|
|
1938
|
-
let t =
|
|
1946
|
+
let t = zt(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Ft(e, () => ({
|
|
1939
1947
|
pageCount: e.pageCount,
|
|
1940
1948
|
exact: e.layoutComplete,
|
|
1941
1949
|
complete: e.layoutComplete
|
|
@@ -1990,17 +1998,17 @@ var rn = class e {
|
|
|
1990
1998
|
}
|
|
1991
1999
|
_revealPendingLayoutAtPresentedTail() {
|
|
1992
2000
|
let e = this._pendingLayoutPublication;
|
|
1993
|
-
!e || this._presentedPageCount === 0 ||
|
|
2001
|
+
!e || this._presentedPageCount === 0 || w(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, 0).end < this._presentedPageCount - 1 || (this._pendingLayoutPublication = null, this._applyLayoutPublication(e));
|
|
1994
2002
|
}
|
|
1995
2003
|
_revealPendingLayoutThroughPage(e) {
|
|
1996
2004
|
let t = this._pendingLayoutPublication;
|
|
1997
2005
|
!t || e < this._presentedPageCount || (this._pendingLayoutPublication = null, this._applyLayoutPublication(t));
|
|
1998
2006
|
}
|
|
1999
2007
|
_pageWidthPx(e) {
|
|
2000
|
-
return this._doc.pageSize(e).widthPt *
|
|
2008
|
+
return this._doc.pageSize(e).widthPt * j * this._scale;
|
|
2001
2009
|
}
|
|
2002
2010
|
_pageHeightPx(e) {
|
|
2003
|
-
return this._doc.pageSize(e).heightPt *
|
|
2011
|
+
return this._doc.pageSize(e).heightPt * j * this._scale;
|
|
2004
2012
|
}
|
|
2005
2013
|
_fitWidthPx() {
|
|
2006
2014
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -2022,7 +2030,7 @@ var rn = class e {
|
|
|
2022
2030
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
2023
2031
|
}
|
|
2024
2032
|
_commentMarginExtent() {
|
|
2025
|
-
return this._hasCommentMargin() ? (
|
|
2033
|
+
return this._hasCommentMargin() ? (nn + 280) * this._commentZoom() : 0;
|
|
2026
2034
|
}
|
|
2027
2035
|
_commentZoom() {
|
|
2028
2036
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -2039,15 +2047,16 @@ var rn = class e {
|
|
|
2039
2047
|
}
|
|
2040
2048
|
_syncCommentMarginGeometry(e) {
|
|
2041
2049
|
if (!e) return;
|
|
2042
|
-
|
|
2043
|
-
|
|
2050
|
+
e.style.display = this._hasCommentMargin() ? "" : "none";
|
|
2051
|
+
let t = this._commentZoom(), n = `calc(100% + ${nn * t}px)`;
|
|
2052
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${rn}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
2044
2053
|
}
|
|
2045
2054
|
_baseScale() {
|
|
2046
2055
|
if (!this._doc || this._doc.pageCount === 0) return 0;
|
|
2047
2056
|
let e = this._fitWidthPx();
|
|
2048
2057
|
if (e <= 0) return 0;
|
|
2049
2058
|
let t = this._doc.pageSize(0).widthPt;
|
|
2050
|
-
return t <= 0 ? 0 : e / (t *
|
|
2059
|
+
return t <= 0 ? 0 : e / (t * j);
|
|
2051
2060
|
}
|
|
2052
2061
|
relayout() {
|
|
2053
2062
|
this._relayout();
|
|
@@ -2101,7 +2110,7 @@ var rn = class e {
|
|
|
2101
2110
|
return a;
|
|
2102
2111
|
}
|
|
2103
2112
|
_range() {
|
|
2104
|
-
return
|
|
2113
|
+
return w(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
|
|
2105
2114
|
}
|
|
2106
2115
|
_syncSpacer() {
|
|
2107
2116
|
let e = this._range();
|
|
@@ -2172,11 +2181,11 @@ var rn = class e {
|
|
|
2172
2181
|
commentGeometry: null,
|
|
2173
2182
|
renderedPage: -1,
|
|
2174
2183
|
renderedScale: -1,
|
|
2175
|
-
dispatcher: new
|
|
2184
|
+
dispatcher: new S(n, this._mode === "worker")
|
|
2176
2185
|
};
|
|
2177
2186
|
}
|
|
2178
2187
|
_recycleSlot(e, t) {
|
|
2179
|
-
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
2188
|
+
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new S(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", this._clearTextLayerPreview(t.textLayer)), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.commentTintLayer && (t.commentTintLayer.replaceChildren(), t.commentTintLayer.style.transform = "", t.commentTintLayer.style.transformOrigin = "", t.commentTintLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren()), t.commentRuns = Object.freeze([]), t.commentGeometry = null, x(t.elementLayer, null), t.renderedPage = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
2180
2189
|
}
|
|
2181
2190
|
_positionSlot(e, t, n) {
|
|
2182
2191
|
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
@@ -2202,6 +2211,7 @@ var rn = class e {
|
|
|
2202
2211
|
p = $(this._doc, t.canvas, e, "main", {
|
|
2203
2212
|
width: i,
|
|
2204
2213
|
dpr: r,
|
|
2214
|
+
imageResources: this._opts.imageResources,
|
|
2205
2215
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2206
2216
|
currentDate: this._currentDate,
|
|
2207
2217
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
@@ -2214,7 +2224,7 @@ var rn = class e {
|
|
|
2214
2224
|
if (!(!s.isCurrent(c) || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedPage !== e)) {
|
|
2215
2225
|
if (t.renderedScale = o, u && t.textLayer) {
|
|
2216
2226
|
let { width: n, height: r } = this._canvasCssPx(t.canvas);
|
|
2217
|
-
|
|
2227
|
+
X(t.textLayer, l, n, r, this._hyperlinkHandler(), (e) => this._measureForFont(e), e);
|
|
2218
2228
|
}
|
|
2219
2229
|
d && this._refreshFindRuns(e, l), this._commitCommentRuns(e, t, l), this._redrawSlotHighlights(e, t);
|
|
2220
2230
|
}
|
|
@@ -2226,7 +2236,7 @@ var rn = class e {
|
|
|
2226
2236
|
_hyperlinkHandler() {
|
|
2227
2237
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
2228
2238
|
if (e.kind === "external") {
|
|
2229
|
-
|
|
2239
|
+
a(e.url);
|
|
2230
2240
|
return;
|
|
2231
2241
|
}
|
|
2232
2242
|
let t = this._doc;
|
|
@@ -2263,6 +2273,7 @@ var rn = class e {
|
|
|
2263
2273
|
let s = await $(this._doc, t.canvas, e, "worker", {
|
|
2264
2274
|
width: n,
|
|
2265
2275
|
dpr: r,
|
|
2276
|
+
imageResources: this._opts.imageResources,
|
|
2266
2277
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2267
2278
|
currentDate: this._currentDate,
|
|
2268
2279
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
@@ -2278,7 +2289,7 @@ var rn = class e {
|
|
|
2278
2289
|
})) return;
|
|
2279
2290
|
if (t.renderedScale = i, t.textLayer && (this._clearTextLayerPreview(t.textLayer), d)) {
|
|
2280
2291
|
let { width: n, height: r } = this._canvasCssPx(t.canvas);
|
|
2281
|
-
|
|
2292
|
+
X(t.textLayer, p, n, r, this._hyperlinkHandler(), (e) => this._measureForFont(e), e);
|
|
2282
2293
|
}
|
|
2283
2294
|
f && this._refreshFindRuns(e, p), this._commitCommentRuns(e, t, p), this._redrawSlotHighlights(e, t), u = !0;
|
|
2284
2295
|
} catch (n) {
|
|
@@ -2301,12 +2312,12 @@ var rn = class e {
|
|
|
2301
2312
|
f = Math.min(1, Math.max(0, f));
|
|
2302
2313
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
2303
2314
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2304
|
-
let h =
|
|
2315
|
+
let h = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
|
|
2305
2316
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
2306
2317
|
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;
|
|
2307
2318
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
2308
2319
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2309
|
-
this._scrollHost.scrollLeft =
|
|
2320
|
+
this._scrollHost.scrollLeft = b(m, i.x - p, a, r, { maxScroll: e });
|
|
2310
2321
|
}
|
|
2311
2322
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2312
2323
|
}
|
|
@@ -2327,9 +2338,9 @@ var rn = class e {
|
|
|
2327
2338
|
}
|
|
2328
2339
|
_fit(e) {
|
|
2329
2340
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2330
|
-
let t = this._doc.pageSize(0), n =
|
|
2331
|
-
contentWidth: t.widthPt *
|
|
2332
|
-
contentHeight: t.heightPt *
|
|
2341
|
+
let t = this._doc.pageSize(0), n = v({
|
|
2342
|
+
contentWidth: t.widthPt * j,
|
|
2343
|
+
contentHeight: t.heightPt * j,
|
|
2333
2344
|
containerWidth: this._fitWidthPx(),
|
|
2334
2345
|
containerHeight: this._scrollHost.clientHeight
|
|
2335
2346
|
}, e);
|
|
@@ -2366,7 +2377,7 @@ var rn = class e {
|
|
|
2366
2377
|
_scheduleSettle() {
|
|
2367
2378
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2368
2379
|
this._settleTimer = null, this._settleRender();
|
|
2369
|
-
},
|
|
2380
|
+
}, en);
|
|
2370
2381
|
}
|
|
2371
2382
|
_settleRender() {
|
|
2372
2383
|
if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._refreshSlotAtomically(e, t);
|
|
@@ -2380,10 +2391,11 @@ var rn = class e {
|
|
|
2380
2391
|
}
|
|
2381
2392
|
let o = document.createElement("canvas");
|
|
2382
2393
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2383
|
-
let s = new
|
|
2394
|
+
let s = new S(o, !1), c = s.begin(), l = [], u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive || !!t.commentTintLayer, f = d ? (e) => l.push(e) : void 0;
|
|
2384
2395
|
$(this._doc, o, e, "main", {
|
|
2385
2396
|
width: r,
|
|
2386
2397
|
dpr: n,
|
|
2398
|
+
imageResources: this._opts.imageResources,
|
|
2387
2399
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2388
2400
|
currentDate: this._currentDate,
|
|
2389
2401
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
@@ -2396,7 +2408,7 @@ var rn = class e {
|
|
|
2396
2408
|
let n = t.canvas;
|
|
2397
2409
|
if (t.dispatcher.destroy(), t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.dispatcher = s, t.renderedScale = i, t.textLayer && (this._clearTextLayerPreview(t.textLayer), u)) {
|
|
2398
2410
|
let { width: n, height: r } = this._canvasCssPx(o);
|
|
2399
|
-
|
|
2411
|
+
X(t.textLayer, l, n, r, this._hyperlinkHandler(), (e) => this._measureForFont(e), e);
|
|
2400
2412
|
}
|
|
2401
2413
|
d && this._refreshFindRuns(e, l), this._commitCommentRuns(e, t, l), this._redrawSlotHighlights(e, t);
|
|
2402
2414
|
}).catch((n) => {
|
|
@@ -2406,13 +2418,13 @@ var rn = class e {
|
|
|
2406
2418
|
async setShowTrackedChanges(e) {
|
|
2407
2419
|
let t = ++this._layoutViewGeneration, n = this._doc;
|
|
2408
2420
|
if (this._showTrackedChanges === e) {
|
|
2409
|
-
n && await
|
|
2421
|
+
n && await K(n, {
|
|
2410
2422
|
showTrackedChanges: e,
|
|
2411
2423
|
currentDate: this._currentDate
|
|
2412
2424
|
}, this);
|
|
2413
2425
|
return;
|
|
2414
2426
|
}
|
|
2415
|
-
(!n || await
|
|
2427
|
+
(!n || await K(n, {
|
|
2416
2428
|
showTrackedChanges: e,
|
|
2417
2429
|
currentDate: this._currentDate
|
|
2418
2430
|
}, this)) && (this._destroyed || t !== this._layoutViewGeneration || n !== this._doc || (this._showTrackedChanges = e, this._find.invalidate(), this._pendingLayoutPublication = null, this._applyLayoutPublication({
|
|
@@ -2425,7 +2437,7 @@ var rn = class e {
|
|
|
2425
2437
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2426
2438
|
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1));
|
|
2427
2439
|
this._revealPendingLayoutThroughPage(n);
|
|
2428
|
-
let r =
|
|
2440
|
+
let r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = r.offsets[n] ?? 0, a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
|
|
2429
2441
|
typeof s.scrollTo == "function" ? s.scrollTo({
|
|
2430
2442
|
top: o,
|
|
2431
2443
|
behavior: t?.behavior ?? "auto"
|
|
@@ -2433,7 +2445,7 @@ var rn = class e {
|
|
|
2433
2445
|
}
|
|
2434
2446
|
_scrollToPageTarget(e, t, n) {
|
|
2435
2447
|
this._revealPendingLayoutThroughPage(e);
|
|
2436
|
-
let r =
|
|
2448
|
+
let r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = this._pageWidthPx(e), { left: a } = this._padH(), o = Math.max(a, (this._scrollHost.clientWidth - i) / 2) + this._reviewOriginPx, s = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), c = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, l = Math.max(0, c - this._scrollHost.clientWidth), u = Math.min(s, Math.max(0, (r.offsets[e] ?? 0) + t.y + t.h / 2 - this._scrollHost.clientHeight / 2)), d = Math.min(l, Math.max(0, o + t.x + t.w / 2 - this._scrollHost.clientWidth / 2)), f = this._scrollHost;
|
|
2437
2449
|
typeof f.scrollTo == "function" ? f.scrollTo({
|
|
2438
2450
|
top: u,
|
|
2439
2451
|
left: d,
|
|
@@ -2448,7 +2460,7 @@ var rn = class e {
|
|
|
2448
2460
|
}
|
|
2449
2461
|
_indexCommentPages(e, t, n) {
|
|
2450
2462
|
if (!this._commentIndexedPages.has(e)) {
|
|
2451
|
-
for (let r of n) this._commentPageById.has(r.commentId) ||
|
|
2463
|
+
for (let r of n) this._commentPageById.has(r.commentId) || P(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
|
|
2452
2464
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2453
2465
|
}
|
|
2454
2466
|
}
|
|
@@ -2498,7 +2510,7 @@ var rn = class e {
|
|
|
2498
2510
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2499
2511
|
let u = await this._commentRunsForPage(s, n);
|
|
2500
2512
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2501
|
-
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) =>
|
|
2513
|
+
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => P(e, u))[0], !c)) return !1;
|
|
2502
2514
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2503
2515
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2504
2516
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2547,6 +2559,7 @@ var rn = class e {
|
|
|
2547
2559
|
}
|
|
2548
2560
|
_redrawSlotComments(e, t) {
|
|
2549
2561
|
if (!this._doc || !t.commentTintLayer) return;
|
|
2562
|
+
this._syncCommentMarginGeometry(t.commentMargin);
|
|
2550
2563
|
let n = this._commentUi;
|
|
2551
2564
|
if (!n) {
|
|
2552
2565
|
t.commentTintLayer.replaceChildren(), t.commentMargin?.replaceChildren(), t.commentDecorationLayer?.replaceChildren(), t.commentGeometry = null;
|
|
@@ -2617,7 +2630,7 @@ var rn = class e {
|
|
|
2617
2630
|
t.highlightLayer.innerHTML = "";
|
|
2618
2631
|
return;
|
|
2619
2632
|
}
|
|
2620
|
-
|
|
2633
|
+
Z(t.highlightLayer, n, this._find.pageHighlights(e), this._pageWidthPx(e), this._pageHeightPx(e), (e) => this._measureForFont(e), this._opts.findHighlightColors);
|
|
2621
2634
|
}
|
|
2622
2635
|
_onResize() {
|
|
2623
2636
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
@@ -2674,7 +2687,7 @@ var rn = class e {
|
|
|
2674
2687
|
}
|
|
2675
2688
|
getSelectionContext(e = {}) {
|
|
2676
2689
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2677
|
-
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ?
|
|
2690
|
+
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? qt(this._doc.comments, this._doc.commentAnchorRanges(), this._activeCommentId, this._activeCommentPage, e) : null) || ((this._opts.enableTextSelection ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Et(this._elementContext, e.maxTextCharacters) : null));
|
|
2678
2691
|
}
|
|
2679
2692
|
_emitSelectionContextChange() {
|
|
2680
2693
|
let e = this.getSelectionContext();
|
|
@@ -2694,11 +2707,11 @@ var rn = class e {
|
|
|
2694
2707
|
_redrawElementOutlineForSlot(e, t) {
|
|
2695
2708
|
let n = this._elementContext, r = this._doc;
|
|
2696
2709
|
if (!n || !r || n.pageIndex !== e) {
|
|
2697
|
-
|
|
2710
|
+
x(t.elementLayer, null);
|
|
2698
2711
|
return;
|
|
2699
2712
|
}
|
|
2700
2713
|
let i = r.pageSize(e);
|
|
2701
|
-
|
|
2714
|
+
x(t.elementLayer, {
|
|
2702
2715
|
x: n.bounds.xPt / i.widthPt,
|
|
2703
2716
|
y: n.bounds.yPt / i.heightPt,
|
|
2704
2717
|
width: n.bounds.widthPt / i.widthPt,
|
|
@@ -2734,7 +2747,7 @@ var rn = class e {
|
|
|
2734
2747
|
}, {
|
|
2735
2748
|
currentDate: this._currentDate,
|
|
2736
2749
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2737
|
-
maxTextCharacters:
|
|
2750
|
+
maxTextCharacters: F
|
|
2738
2751
|
});
|
|
2739
2752
|
} catch (e) {
|
|
2740
2753
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2752,7 +2765,7 @@ var rn = class e {
|
|
|
2752
2765
|
};
|
|
2753
2766
|
//#endregion
|
|
2754
2767
|
//#region packages/docx/src/types.ts
|
|
2755
|
-
function
|
|
2768
|
+
function ln(e) {
|
|
2756
2769
|
let t = [];
|
|
2757
2770
|
for (let n of e.content) {
|
|
2758
2771
|
if (n.type !== "paragraph") continue;
|
|
@@ -2764,23 +2777,25 @@ function an(e) {
|
|
|
2764
2777
|
}
|
|
2765
2778
|
//#endregion
|
|
2766
2779
|
//#region src/docx.ts
|
|
2767
|
-
var
|
|
2768
|
-
DocxDocument: () =>
|
|
2769
|
-
DocxScrollViewer: () =>
|
|
2770
|
-
DocxViewer: () =>
|
|
2771
|
-
OoxmlDecodedImageLimitError: () =>
|
|
2772
|
-
OoxmlError: () =>
|
|
2773
|
-
OoxmlResourceLimitError: () =>
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
+
var un = /* @__PURE__ */ e({
|
|
2781
|
+
DocxDocument: () => J,
|
|
2782
|
+
DocxScrollViewer: () => cn,
|
|
2783
|
+
DocxViewer: () => $t,
|
|
2784
|
+
OoxmlDecodedImageLimitError: () => Ye,
|
|
2785
|
+
OoxmlError: () => s,
|
|
2786
|
+
OoxmlResourceLimitError: () => l,
|
|
2787
|
+
TiffDecodeError: () => Xe,
|
|
2788
|
+
autoResize: () => _,
|
|
2789
|
+
buildDocxHighlightLayer: () => Z,
|
|
2790
|
+
buildDocxTextLayer: () => X,
|
|
2791
|
+
isOoxmlDecodedImageLimitError: () => Je,
|
|
2792
|
+
isTiffDecodeError: () => Ze,
|
|
2793
|
+
noteText: () => ln,
|
|
2794
|
+
openExternalHyperlink: () => a,
|
|
2780
2795
|
readDocxTextSelectionContext: () => Q,
|
|
2781
|
-
resolveCommentAnchorRuns: () =>
|
|
2782
|
-
resolveDocxCommentThreads: () =>
|
|
2783
|
-
resolveRevisionAnchorRuns: () =>
|
|
2796
|
+
resolveCommentAnchorRuns: () => P,
|
|
2797
|
+
resolveDocxCommentThreads: () => tt,
|
|
2798
|
+
resolveRevisionAnchorRuns: () => Mt
|
|
2784
2799
|
});
|
|
2785
2800
|
//#endregion
|
|
2786
|
-
export { Q as a,
|
|
2801
|
+
export { Q as a, J as c, $t as i, Mt as l, ln as n, Z as o, cn as r, X as s, un as t };
|