@silurus/ooxml 0.83.0 → 0.83.2
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 +3 -2
- package/dist/assets/{render-worker-DuztdEcX.js → render-worker-4GSYWsM3.js} +1 -1
- package/dist/assets/{render-worker-Bu31cf1J.js → render-worker-DwFpY197.js} +1 -1
- package/dist/{canvas-viewer-mechanics-h07vpVOQ.js → canvas-viewer-mechanics-DVGK-fLT.js} +56 -41
- package/dist/{document-pull-client-BAhqoTmm.js → document-pull-client-DSx36ZsB.js} +20 -9
- package/dist/{docx-Dg73PGgC.js → docx-DojUJSZd.js} +365 -288
- package/dist/docx.mjs +2 -2
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/index.mjs +3 -3
- package/dist/node.mjs +5 -5
- package/dist/{pptx-BcUCETmQ.js → pptx-Wh22eziy.js} +205 -185
- package/dist/pptx.mjs +3 -3
- package/dist/{render-CL-7V3E8.js → render-DtbFbO5c.js} +1 -1
- package/dist/{render-worker-host-FJ19-fUI.js → render-worker-host-D1jcACJV.js} +1 -1
- package/dist/{render-worker-host-DDZo0feh.js → render-worker-host-DCLyw6UR.js} +1 -1
- package/dist/{session-BjydZEDF.js → session-CxT-t0BX.js} +1 -1
- package/dist/{slide-pull-client-CwvvncPA.js → slide-pull-client-B9rcJdO4.js} +83 -53
- package/dist/types/docx.d.ts +6 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/pptx.d.ts +7 -1
- package/dist/{xlsx-BibrHQ52.js → xlsx-C3beLfwZ.js} +2 -2
- package/dist/xlsx.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
2
|
import { B as t, Qt as n, R as r, Vt as i, W as a, Zt as o, a as s, et as c, ft as l, lt as u, z as d } from "./line-metrics-Bpn7OeZD.js";
|
|
3
|
-
import { C as f, E as p, S as m, T as h, _ as g, a as _, b as ee, c as v, d as y, f as te, g as ne, h as re, i as b, l as x, m as ie, n as ae, o as oe, p as se, r as
|
|
4
|
-
import { a as
|
|
5
|
-
import { c as
|
|
6
|
-
import { A as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { a as
|
|
9
|
-
import { n as
|
|
10
|
-
import { n as
|
|
11
|
-
import { o as
|
|
12
|
-
import { i as
|
|
3
|
+
import { C as f, E as p, S as m, T as h, _ as g, a as _, b as ee, c as v, d as y, f as te, g as ne, h as re, i as b, l as x, 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-DVGK-fLT.js";
|
|
4
|
+
import { a as ge, i as _e, t as ve } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
5
|
+
import { c as ye, i as be, l as xe, n as Se, o as S, r as Ce, s as we, t as Te } from "./dom-interaction-boundary-CepOlXt6.js";
|
|
6
|
+
import { A as Ee, C, D as w, E as De, O as T, S as Oe, T as E, _ 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 D, o as Ve, p as He, s as Ue, t as O, v as We, w as Ge, x as Ke, y as qe } from "./document-pull-client-DSx36ZsB.js";
|
|
7
|
+
import { cn as Je, ln as Ye } from "./plot-area-frame-DHV02PJU.js";
|
|
8
|
+
import { a as k } from "./units-BzZ0gAxs.js";
|
|
9
|
+
import { n as Xe } from "./renderer-module-contract-DLbb7zY0.js";
|
|
10
|
+
import { n as Ze, t as A } from "./highlight-rect-Hes0z_Mj.js";
|
|
11
|
+
import { o as j } from "./source-key-BklvnEyQ.js";
|
|
12
|
+
import { i as Qe, n as M, r as $e, t as et } from "./comments-AAaNnQTi.js";
|
|
13
13
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
14
|
-
var Qe = "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)})}};", $e = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Qe], { type: "text/javascript;charset=utf-8" });
|
|
15
|
-
function
|
|
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 rt(e) {
|
|
16
16
|
let t;
|
|
17
17
|
try {
|
|
18
|
-
if (t =
|
|
18
|
+
if (t = nt && (self.URL || self.webkitURL).createObjectURL(nt), !t) throw "";
|
|
19
19
|
let n = new Worker(t, {
|
|
20
20
|
type: "module",
|
|
21
21
|
name: e?.name
|
|
@@ -24,7 +24,7 @@ function et(e) {
|
|
|
24
24
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
25
25
|
}), n;
|
|
26
26
|
} catch {
|
|
27
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
27
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(tt), {
|
|
28
28
|
type: "module",
|
|
29
29
|
name: e?.name
|
|
30
30
|
});
|
|
@@ -32,17 +32,17 @@ function et(e) {
|
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
35
|
-
var
|
|
35
|
+
var it = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region packages/docx/src/bookmark-nav.ts
|
|
38
|
-
function
|
|
38
|
+
function at(e) {
|
|
39
39
|
let t = /* @__PURE__ */ new Map();
|
|
40
40
|
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
41
|
return t;
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region packages/docx/src/embedded-fonts.ts
|
|
45
|
-
async function
|
|
45
|
+
async function ot(e, t) {
|
|
46
46
|
let n = e.embeddedFonts;
|
|
47
47
|
if (!n || n.length === 0) return [];
|
|
48
48
|
let r = (await Promise.all(n.map(async (e) => {
|
|
@@ -53,25 +53,25 @@ async function rt(e, t) {
|
|
|
53
53
|
bytes: n,
|
|
54
54
|
odttf: e.partPath.toLowerCase().endsWith(".odttf"),
|
|
55
55
|
fontKey: e.fontKey,
|
|
56
|
-
weight:
|
|
57
|
-
style:
|
|
56
|
+
weight: st(e.style),
|
|
57
|
+
style: ct(e.style)
|
|
58
58
|
};
|
|
59
59
|
} catch {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
62
|
}))).filter((e) => e !== null);
|
|
63
|
-
return r.length === 0 ? [] :
|
|
63
|
+
return r.length === 0 ? [] : ye(r);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function st(e) {
|
|
66
66
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ct(e) {
|
|
69
69
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region packages/docx/src/element-context.ts
|
|
73
|
-
var
|
|
74
|
-
function
|
|
73
|
+
var N = de, lt = 16384;
|
|
74
|
+
function ut(e, t) {
|
|
75
75
|
let n = Math.min(e.length, t);
|
|
76
76
|
if (n > 0 && n < e.length) {
|
|
77
77
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -79,7 +79,7 @@ function st(e, t) {
|
|
|
79
79
|
}
|
|
80
80
|
return e.slice(0, n);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function dt(e, t) {
|
|
83
83
|
let n = [], r = 0, i = !1;
|
|
84
84
|
for (let a of e) {
|
|
85
85
|
if (a.length === 0) continue;
|
|
@@ -90,7 +90,7 @@ function ct(e, t) {
|
|
|
90
90
|
}
|
|
91
91
|
n.push("\n"), r++;
|
|
92
92
|
}
|
|
93
|
-
let e =
|
|
93
|
+
let e = ut(a, Math.max(0, t - r));
|
|
94
94
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
95
95
|
i = !0;
|
|
96
96
|
break;
|
|
@@ -102,7 +102,7 @@ function ct(e, t) {
|
|
|
102
102
|
truncated: i
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
function*
|
|
105
|
+
function* P(e) {
|
|
106
106
|
if (e.kind === "paragraph") {
|
|
107
107
|
for (let t of e.lines) {
|
|
108
108
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -111,42 +111,42 @@ function* L(e) {
|
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
if (e.kind === "table") {
|
|
114
|
-
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield*
|
|
114
|
+
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* P(t.layout);
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield*
|
|
117
|
+
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* P(t);
|
|
118
118
|
}
|
|
119
|
-
function*
|
|
119
|
+
function* ft(e) {
|
|
120
120
|
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*
|
|
121
|
+
for (let t of e.textBoxes) yield* P(t);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
let t = e ??
|
|
123
|
+
function pt(e) {
|
|
124
|
+
let t = e ?? lt;
|
|
125
125
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
126
|
-
return Math.min(
|
|
126
|
+
return Math.min(N, Math.floor(t));
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function mt(e) {
|
|
129
129
|
return {
|
|
130
130
|
story: e.story,
|
|
131
131
|
storyInstance: e.storyInstance,
|
|
132
132
|
path: [...e.path]
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function ht(e) {
|
|
136
136
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
let t =
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
function gt(e) {
|
|
139
|
+
let t = ht(e), n = [
|
|
140
|
+
C(e.pointToPage, t),
|
|
141
|
+
C(e.pointToPage, {
|
|
142
142
|
xPt: t.xPt + t.widthPt,
|
|
143
143
|
yPt: t.yPt
|
|
144
144
|
}),
|
|
145
|
-
|
|
145
|
+
C(e.pointToPage, {
|
|
146
146
|
xPt: t.xPt,
|
|
147
147
|
yPt: t.yPt + t.heightPt
|
|
148
148
|
}),
|
|
149
|
-
|
|
149
|
+
C(e.pointToPage, {
|
|
150
150
|
xPt: t.xPt + t.widthPt,
|
|
151
151
|
yPt: t.yPt + t.heightPt
|
|
152
152
|
})
|
|
@@ -158,10 +158,10 @@ function ft(e) {
|
|
|
158
158
|
heightPt: o - i
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function F(e, t) {
|
|
162
162
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function _t(e, t) {
|
|
165
165
|
let n = !1;
|
|
166
166
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
167
167
|
let a = t[r], o = t[i];
|
|
@@ -169,35 +169,35 @@ function pt(e, t) {
|
|
|
169
169
|
}
|
|
170
170
|
return n;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
172
|
+
function vt(e, t) {
|
|
173
|
+
return F(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? F(e.clip.rect, t) : _t(t, e.clip.points) : !0 : !1;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function yt(e, t, n) {
|
|
176
176
|
for (let n of e.clips) {
|
|
177
|
-
let e =
|
|
178
|
-
if (!e || !
|
|
177
|
+
let e = Oe(n.pointToPage, t);
|
|
178
|
+
if (!e || !F(n.bounds, e)) return !1;
|
|
179
179
|
}
|
|
180
|
-
return "drawing" in e ?
|
|
180
|
+
return "drawing" in e ? vt(e.drawing, n) : F(e.placement.bounds, n);
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function I(e, t) {
|
|
183
183
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
185
|
+
function bt(e) {
|
|
186
|
+
return I(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" : I(e, "image") ? "image" : null;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
let o = "drawing" in e ?
|
|
188
|
+
function xt(e, t, n, r, i, a) {
|
|
189
|
+
let o = "drawing" in e ? bt(e.drawing) : e.placement.resourceKind;
|
|
190
190
|
if (!o) return null;
|
|
191
191
|
let s, c = !1, l, u;
|
|
192
192
|
if (o === "chart") {
|
|
193
|
-
let t = "drawing" in e ?
|
|
193
|
+
let t = "drawing" in e ? I(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = y(n.model, a);
|
|
194
194
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
195
195
|
} else if (o === "image") {
|
|
196
|
-
let t = "drawing" in e ?
|
|
196
|
+
let t = "drawing" in e ? I(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
|
|
197
197
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
198
198
|
l = n.mimeType;
|
|
199
199
|
} else {
|
|
200
|
-
let t =
|
|
200
|
+
let t = dt(ft(e), a);
|
|
201
201
|
s = t.text, c = t.truncated;
|
|
202
202
|
}
|
|
203
203
|
return {
|
|
@@ -207,8 +207,8 @@ function _t(e, t, n, r, i, a) {
|
|
|
207
207
|
elementIndex: n,
|
|
208
208
|
elementType: o,
|
|
209
209
|
point: { ...r },
|
|
210
|
-
bounds:
|
|
211
|
-
source:
|
|
210
|
+
bounds: gt(e),
|
|
211
|
+
source: mt("drawing" in e ? e.drawing.source : e.source),
|
|
212
212
|
...s === void 0 ? {} : { text: s },
|
|
213
213
|
...l === void 0 ? {} : { mimeType: l },
|
|
214
214
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -218,26 +218,26 @@ function _t(e, t, n, r, i, a) {
|
|
|
218
218
|
maxTextCharacters: a
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function St(e, t, n, r, i = {}) {
|
|
222
222
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
223
|
-
let a =
|
|
223
|
+
let a = pt(i.maxTextCharacters), o = je(e, t);
|
|
224
224
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
225
|
-
let i = o[e], s =
|
|
226
|
-
if (!s || !
|
|
227
|
-
let c =
|
|
225
|
+
let i = o[e], s = Oe(i.pointToPage, n);
|
|
226
|
+
if (!s || !yt(i, n, s)) continue;
|
|
227
|
+
let c = xt(i, t, e, n, r, a);
|
|
228
228
|
if (c) return c;
|
|
229
229
|
}
|
|
230
230
|
return null;
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
232
|
+
function Ct(e, t, n, r) {
|
|
233
|
+
return St(Ge(e, {
|
|
234
234
|
currentDate: r.currentDate,
|
|
235
235
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
236
236
|
showTrackedChanges: r.showTrackedChanges
|
|
237
|
-
}, t).layout, t, n,
|
|
237
|
+
}, t).layout, t, n, Re(e), r);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
let n =
|
|
239
|
+
function L(e, t) {
|
|
240
|
+
let n = pt(t), r = e.text === void 0 ? void 0 : ut(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
|
|
241
241
|
return {
|
|
242
242
|
...structuredClone(e),
|
|
243
243
|
...r === void 0 ? {} : { text: r },
|
|
@@ -249,20 +249,20 @@ function bt(e, t) {
|
|
|
249
249
|
}
|
|
250
250
|
//#endregion
|
|
251
251
|
//#region packages/docx/src/revisions.ts
|
|
252
|
-
function
|
|
253
|
-
let t =
|
|
252
|
+
function R(e) {
|
|
253
|
+
let t = Qe(e.id);
|
|
254
254
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function z(e) {
|
|
257
257
|
return Object.freeze({
|
|
258
258
|
...e,
|
|
259
259
|
path: Object.freeze([...e.path])
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function wt(e, t) {
|
|
263
263
|
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
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function B(e, t) {
|
|
266
266
|
let n = 0, r = e.length;
|
|
267
267
|
for (; n < r;) {
|
|
268
268
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -270,22 +270,22 @@ function U(e, t) {
|
|
|
270
270
|
}
|
|
271
271
|
return n;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function Tt(e, t) {
|
|
274
274
|
let n = Array(e.length), r;
|
|
275
275
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
276
276
|
n[i] = r;
|
|
277
|
-
let a = e[i], o = t.get(
|
|
277
|
+
let a = e[i], o = t.get(j(a.source))?.[0];
|
|
278
278
|
o !== void 0 && (r = Object.freeze({
|
|
279
|
-
source:
|
|
279
|
+
source: z(a.source),
|
|
280
280
|
sourceRunIndex: o
|
|
281
281
|
}));
|
|
282
282
|
}
|
|
283
283
|
let i = Array(e.length), a;
|
|
284
284
|
for (let n = 0; n < e.length; n += 1) {
|
|
285
285
|
i[n] = a;
|
|
286
|
-
let r = e[n], o = t.get(
|
|
286
|
+
let r = e[n], o = t.get(j(r.source))?.at(-1);
|
|
287
287
|
o !== void 0 && (a = Object.freeze({
|
|
288
|
-
source:
|
|
288
|
+
source: z(r.source),
|
|
289
289
|
sourceRunIndex: o
|
|
290
290
|
}));
|
|
291
291
|
}
|
|
@@ -294,17 +294,17 @@ function St(e, t) {
|
|
|
294
294
|
preceding: i
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
function
|
|
298
|
-
let o = r[e], s = i.get(
|
|
297
|
+
function Et(e, t, n, r, i, a) {
|
|
298
|
+
let o = r[e], s = i.get(j(o.source)) ?? [], c = s[B(s, n)], l = s[B(s, t) - 1], u = c ?? l;
|
|
299
299
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
300
|
-
source:
|
|
300
|
+
source: z(o.source),
|
|
301
301
|
sourceRunIndex: u
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function Dt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
305
305
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
306
306
|
e.forEach((e, t) => {
|
|
307
|
-
let n =
|
|
307
|
+
let n = R(e);
|
|
308
308
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
309
309
|
});
|
|
310
310
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -314,11 +314,11 @@ function wt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
314
314
|
source: e,
|
|
315
315
|
runs: n.runs
|
|
316
316
|
}] : [];
|
|
317
|
-
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s =
|
|
317
|
+
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Tt(a, o), c = [];
|
|
318
318
|
for (let [e, t] of a.entries()) {
|
|
319
319
|
let n = 0;
|
|
320
320
|
for (; n < t.runs.length;) {
|
|
321
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
321
|
+
let i = t.runs[n], l = i.revision?.kind ? R({
|
|
322
322
|
kind: i.revision.kind,
|
|
323
323
|
id: i.revision.id
|
|
324
324
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -329,16 +329,16 @@ function wt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
329
329
|
let d = n;
|
|
330
330
|
for (n += 1; n < t.runs.length;) {
|
|
331
331
|
let e = t.runs[n].revision;
|
|
332
|
-
if (!e?.kind ||
|
|
332
|
+
if (!e?.kind || R({
|
|
333
333
|
kind: e.kind,
|
|
334
334
|
id: e.id
|
|
335
335
|
}) !== l) break;
|
|
336
336
|
n += 1;
|
|
337
337
|
}
|
|
338
|
-
let f = n, p = o.get(
|
|
338
|
+
let f = n, p = o.get(j(t.source)) ?? [], m = (p[B(p, d)] ?? f) < f ? void 0 : Et(e, d, f, a, o, s);
|
|
339
339
|
c.push(Object.freeze({
|
|
340
340
|
revisionIndex: u,
|
|
341
|
-
source:
|
|
341
|
+
source: z(t.source),
|
|
342
342
|
startRunIndex: d,
|
|
343
343
|
endRunIndex: f,
|
|
344
344
|
...m === void 0 ? {} : { geometryFallback: m }
|
|
@@ -347,26 +347,26 @@ function wt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
347
347
|
}
|
|
348
348
|
return c;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Ot(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
351
351
|
if ((e?.length ?? 0) === 0) return [];
|
|
352
|
-
let i =
|
|
352
|
+
let i = Dt(e ?? [], t, n), a = r.completedSourceKeys;
|
|
353
353
|
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(
|
|
354
|
+
let t = n.get(j(e.source));
|
|
355
|
+
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(j(e.source));
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
|
-
function
|
|
359
|
-
let n = t.filter((t) => t.sourceRunIndex !== void 0 &&
|
|
358
|
+
function kt(e, t) {
|
|
359
|
+
let n = t.filter((t) => t.sourceRunIndex !== void 0 && wt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
|
|
360
360
|
if (n.length > 0) return n;
|
|
361
361
|
let r = e.geometryFallback;
|
|
362
|
-
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex &&
|
|
362
|
+
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && wt(e.source, r.source));
|
|
363
363
|
}
|
|
364
364
|
//#endregion
|
|
365
365
|
//#region packages/docx/src/layout/progressive.ts
|
|
366
|
-
var
|
|
367
|
-
async function
|
|
366
|
+
var At = 12;
|
|
367
|
+
async function jt(e, t, n, r = {}) {
|
|
368
368
|
let { onPreview: i, scheduler: a } = r;
|
|
369
|
-
return
|
|
369
|
+
return Fe(ke(e, t, n, i && e.sequence.length > At ? { onPages: (e, t) => {
|
|
370
370
|
i(Object.freeze({
|
|
371
371
|
layout: e,
|
|
372
372
|
exact: !1,
|
|
@@ -376,10 +376,10 @@ async function Ot(e, t, n, r = {}) {
|
|
|
376
376
|
}
|
|
377
377
|
//#endregion
|
|
378
378
|
//#region packages/docx/src/document-layout-events.ts
|
|
379
|
-
var
|
|
380
|
-
function
|
|
379
|
+
var V = /* @__PURE__ */ new WeakMap();
|
|
380
|
+
function H(e, t) {
|
|
381
381
|
let n = Object.freeze({ ...t });
|
|
382
|
-
for (let t of [...
|
|
382
|
+
for (let t of [...V.get(e) ?? []]) try {
|
|
383
383
|
t.notify(n);
|
|
384
384
|
} catch (e) {
|
|
385
385
|
try {
|
|
@@ -387,9 +387,9 @@ function G(e, t) {
|
|
|
387
387
|
} catch {}
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
function
|
|
391
|
-
let i =
|
|
392
|
-
i || (i = /* @__PURE__ */ new Set(),
|
|
390
|
+
function Mt(e, t, n, r) {
|
|
391
|
+
let i = V.get(e);
|
|
392
|
+
i || (i = /* @__PURE__ */ new Set(), V.set(e, i));
|
|
393
393
|
let a = Object.freeze({
|
|
394
394
|
notify: n,
|
|
395
395
|
report: r
|
|
@@ -403,15 +403,65 @@ function kt(e, t, n, r) {
|
|
|
403
403
|
} catch {}
|
|
404
404
|
}
|
|
405
405
|
return () => {
|
|
406
|
-
i?.delete(a), i?.size === 0 &&
|
|
406
|
+
i?.delete(a), i?.size === 0 && V.delete(e);
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region packages/docx/src/document-layout-view.ts
|
|
411
|
+
var U = /* @__PURE__ */ new WeakMap(), Nt = /* @__PURE__ */ new WeakMap(), Pt = Symbol("docxLayoutViewRequester");
|
|
412
|
+
function W(e) {
|
|
413
|
+
let t = w(e), n = t.activeLayoutOptions;
|
|
414
|
+
return {
|
|
415
|
+
showTrackedChanges: n?.showTrackedChanges === !0,
|
|
416
|
+
currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
async function G(e, t, n) {
|
|
420
|
+
let r = w(e), i = E(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
421
|
+
showTrackedChanges: i.showTrackedChanges === !0,
|
|
422
|
+
currentDate: i.currentDateMs
|
|
423
|
+
}), o = {
|
|
424
|
+
showTrackedChanges: a.showTrackedChanges,
|
|
425
|
+
currentDate: a.currentDate,
|
|
426
|
+
[Pt]: n
|
|
427
|
+
};
|
|
428
|
+
await e.setLayoutView(o);
|
|
429
|
+
let s = W(e);
|
|
430
|
+
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
431
|
+
}
|
|
432
|
+
function Ft(e, t) {
|
|
433
|
+
let n = Object.freeze({ ...W(e) }), r = (Nt.get(e) ?? 0) + 1;
|
|
434
|
+
Nt.set(e, r);
|
|
435
|
+
let i = Object.freeze({
|
|
436
|
+
view: n,
|
|
437
|
+
generation: r,
|
|
438
|
+
requester: t
|
|
439
|
+
});
|
|
440
|
+
for (let t of [...U.get(e) ?? []]) try {
|
|
441
|
+
t.notify(i);
|
|
442
|
+
} catch (e) {
|
|
443
|
+
try {
|
|
444
|
+
t.report(e);
|
|
445
|
+
} catch {}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function It(e, t, n) {
|
|
449
|
+
let r = U.get(e);
|
|
450
|
+
r || (r = /* @__PURE__ */ new Set(), U.set(e, r));
|
|
451
|
+
let i = Object.freeze({
|
|
452
|
+
notify: t,
|
|
453
|
+
report: n
|
|
454
|
+
});
|
|
455
|
+
return r.add(i), () => {
|
|
456
|
+
r?.delete(i), r?.size === 0 && U.delete(e);
|
|
407
457
|
};
|
|
408
458
|
}
|
|
409
459
|
//#endregion
|
|
410
460
|
//#region packages/docx/src/document.ts
|
|
411
|
-
function
|
|
461
|
+
function Lt(e, t) {
|
|
412
462
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
413
463
|
}
|
|
414
|
-
function
|
|
464
|
+
function Rt() {
|
|
415
465
|
let e, t;
|
|
416
466
|
return {
|
|
417
467
|
promise: new Promise((n, r) => {
|
|
@@ -421,12 +471,12 @@ function jt() {
|
|
|
421
471
|
reject: t
|
|
422
472
|
};
|
|
423
473
|
}
|
|
424
|
-
var
|
|
474
|
+
var zt = Object.freeze([]), Bt = Object.freeze([]), Vt = Object.freeze({
|
|
425
475
|
comments: Object.freeze([]),
|
|
426
476
|
revisions: Object.freeze([])
|
|
427
477
|
});
|
|
428
478
|
function K(e, t) {
|
|
429
|
-
return
|
|
479
|
+
return Ee({
|
|
430
480
|
comments: e,
|
|
431
481
|
revisions: t
|
|
432
482
|
}, "DOCX review metadata");
|
|
@@ -436,9 +486,9 @@ var q = class e {
|
|
|
436
486
|
_document = null;
|
|
437
487
|
_source = null;
|
|
438
488
|
_meta = null;
|
|
439
|
-
_review =
|
|
440
|
-
_layoutLifecycle = new
|
|
441
|
-
_layoutObservers = new
|
|
489
|
+
_review = Vt;
|
|
490
|
+
_layoutLifecycle = new be();
|
|
491
|
+
_layoutObservers = new Ce();
|
|
442
492
|
_layoutCompletion = null;
|
|
443
493
|
_layoutAbort = null;
|
|
444
494
|
_bookmarkPages = null;
|
|
@@ -456,7 +506,7 @@ var q = class e {
|
|
|
456
506
|
_chartEx;
|
|
457
507
|
_worker;
|
|
458
508
|
_bridge;
|
|
459
|
-
_rawParts = new
|
|
509
|
+
_rawParts = new ve({
|
|
460
510
|
maxEntries: 64,
|
|
461
511
|
maxBytes: i
|
|
462
512
|
});
|
|
@@ -465,7 +515,7 @@ var q = class e {
|
|
|
465
515
|
_localMetricFontFaces = [];
|
|
466
516
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
467
517
|
constructor(e, t, n, r) {
|
|
468
|
-
this._worker = e, this._mode = t,
|
|
518
|
+
this._worker = e, this._mode = t, De(this, n), this._bridge = new f(this._worker, {
|
|
469
519
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
470
520
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
471
521
|
toError: (e) => {
|
|
@@ -477,7 +527,7 @@ var q = class e {
|
|
|
477
527
|
});
|
|
478
528
|
}
|
|
479
529
|
});
|
|
480
|
-
let i = new URL(r ??
|
|
530
|
+
let i = new URL(r ?? it, location.href).href;
|
|
481
531
|
this._bridge.post({
|
|
482
532
|
type: "init",
|
|
483
533
|
wasmUrl: i
|
|
@@ -501,29 +551,29 @@ var q = class e {
|
|
|
501
551
|
t = await e.arrayBuffer();
|
|
502
552
|
} else t = n;
|
|
503
553
|
t = p(await h(t, i.password)), c.setSourceBytes(t.byteLength), c.checkpoint("container ready");
|
|
504
|
-
let r = s === "worker" ? (await import("./render-worker-host-
|
|
554
|
+
let r = s === "worker" ? (await import("./render-worker-host-DCLyw6UR.js")).createRenderWorker() : new rt(), l = s === "worker" ? Xe(i) : void 0, u = s === "worker" && !!i.progressiveLayout, d;
|
|
505
555
|
try {
|
|
506
556
|
d = new e(r, s, o, i.wasmUrl), d._metrics = c;
|
|
507
|
-
let n =
|
|
557
|
+
let n = w(d), f = E(i.currentDate, n.defaultCurrentDateMs, i.showTrackedChanges === !0);
|
|
508
558
|
if (n.activeLayoutOptions = f, await d._parse(t, a.policy, s === "worker" ? !!i.useGoogleFonts : !1, i.workerTimeoutMs, (e) => c.observeUsage(e), l, u ? {
|
|
509
559
|
onPartial: i.onLayoutPartial,
|
|
510
560
|
onComplete: i.onLayoutComplete,
|
|
511
561
|
onProgress: i.onLayoutProgress,
|
|
512
562
|
layoutOptions: f,
|
|
513
563
|
abort: new AbortController(),
|
|
514
|
-
firstPublication:
|
|
564
|
+
firstPublication: Rt(),
|
|
515
565
|
published: !1,
|
|
516
566
|
settled: !1
|
|
517
|
-
} : 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, d._mode === "main" && i.useGoogleFonts && d._document && (d._googleFontFaces = await
|
|
567
|
+
} : 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, d._mode === "main" && i.useGoogleFonts && d._document && (d._googleFontFaces = await _e(He(d._document), Pe)), d._mode === "main" && d._document?.embeddedFonts?.length) {
|
|
518
568
|
let e = d;
|
|
519
|
-
d._embeddedFontFaces = await
|
|
569
|
+
d._embeddedFontFaces = await ot(d._document, (t) => e.getFontBytes(t));
|
|
520
570
|
}
|
|
521
571
|
let p;
|
|
522
|
-
d._mode === "main" && d._document && (p = await
|
|
572
|
+
d._mode === "main" && d._document && (p = await Ne(d._document), d._localMetricFontFaces = p.faces);
|
|
523
573
|
let m;
|
|
524
|
-
if (d._mode === "main" && i.math && d._document &&
|
|
525
|
-
let e = d, t =
|
|
526
|
-
t.services =
|
|
574
|
+
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) {
|
|
575
|
+
let e = d, t = w(d);
|
|
576
|
+
t.services = ze(d._source, {
|
|
527
577
|
localMetrics: p?.metrics,
|
|
528
578
|
useGoogleFonts: !!i.useGoogleFonts,
|
|
529
579
|
embeddedFaces: d._embeddedFontFaces,
|
|
@@ -531,14 +581,14 @@ var q = class e {
|
|
|
531
581
|
mathResources: m?.records,
|
|
532
582
|
mathDrawables: m?.drawables
|
|
533
583
|
});
|
|
534
|
-
let n = t.services, r =
|
|
584
|
+
let n = t.services, r = Ae(d._source, n, t.defaultCurrentDateMs), a = d._source.fatalParse === null, o = t.activeLayoutOptions;
|
|
535
585
|
if (!o) throw Error("Active layout view was not recorded at load");
|
|
536
586
|
let s = { onProgress: i.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", i.onLayoutProgress, { committedUnits: t }) : void 0 };
|
|
537
587
|
if (a && i.progressiveLayout) {
|
|
538
588
|
let e = r.layoutVariants, t = d, a = new AbortController();
|
|
539
589
|
t._layoutAbort = a;
|
|
540
|
-
let c =
|
|
541
|
-
t._layoutCompletion =
|
|
590
|
+
let c = Rt(), l = null, u = !0;
|
|
591
|
+
t._layoutCompletion = jt(d._source.bodyLayoutInput, n, o, {
|
|
542
592
|
scheduler: {
|
|
543
593
|
...s,
|
|
544
594
|
signal: a.signal
|
|
@@ -550,14 +600,14 @@ var q = class e {
|
|
|
550
600
|
u = !1;
|
|
551
601
|
return;
|
|
552
602
|
}
|
|
553
|
-
if (l = a, r) t._layoutLifecycle.begin(),
|
|
603
|
+
if (l = a, r) t._layoutLifecycle.begin(), H(t, {
|
|
554
604
|
pageCount: n.layout.pages.length,
|
|
555
605
|
exact: n.exact,
|
|
556
606
|
complete: !1
|
|
557
607
|
}), c.resolve();
|
|
558
608
|
else {
|
|
559
609
|
if (!t._isLayoutViewActive(o)) return;
|
|
560
|
-
|
|
610
|
+
H(t, {
|
|
561
611
|
pageCount: n.layout.pages.length,
|
|
562
612
|
exact: n.exact,
|
|
563
613
|
complete: !1
|
|
@@ -568,7 +618,7 @@ var q = class e {
|
|
|
568
618
|
}
|
|
569
619
|
}
|
|
570
620
|
}).then((n) => {
|
|
571
|
-
u && t._replaceMainLayoutPublication(e, o, l, n) === null && (u = !1), t._layoutLifecycle.succeed(),
|
|
621
|
+
u && t._replaceMainLayoutPublication(e, o, l, n) === null && (u = !1), t._layoutLifecycle.succeed(), H(t, {
|
|
572
622
|
pageCount: t.pageCount,
|
|
573
623
|
exact: !0,
|
|
574
624
|
complete: !0
|
|
@@ -578,12 +628,12 @@ var q = class e {
|
|
|
578
628
|
c.reject(e);
|
|
579
629
|
return;
|
|
580
630
|
}
|
|
581
|
-
if (e instanceof
|
|
631
|
+
if (e instanceof Ie) {
|
|
582
632
|
t._layoutLifecycle.succeed();
|
|
583
633
|
return;
|
|
584
634
|
}
|
|
585
635
|
let n = t._layoutLifecycle.fail(e);
|
|
586
|
-
|
|
636
|
+
H(t, {
|
|
587
637
|
pageCount: t.pageCount,
|
|
588
638
|
exact: !1,
|
|
589
639
|
complete: !1,
|
|
@@ -591,7 +641,7 @@ var q = class e {
|
|
|
591
641
|
}), t._layoutObservers.notify("onLayoutComplete", i.onLayoutComplete, n);
|
|
592
642
|
}), await c.promise;
|
|
593
643
|
} else if (a && (i.sliceLayout || i.onLayoutProgress)) {
|
|
594
|
-
let e = await
|
|
644
|
+
let e = await Be(d._source.bodyLayoutInput, n, o, s);
|
|
595
645
|
r.layoutVariants.prime(o, e);
|
|
596
646
|
} else r.layoutVariants.layoutFor(o);
|
|
597
647
|
}
|
|
@@ -615,7 +665,7 @@ var q = class e {
|
|
|
615
665
|
data: e,
|
|
616
666
|
resourcePolicy: t,
|
|
617
667
|
useGoogleFonts: n,
|
|
618
|
-
defaultCurrentDateMs:
|
|
668
|
+
defaultCurrentDateMs: w(this).defaultCurrentDateMs,
|
|
619
669
|
...this._parseViewFields(),
|
|
620
670
|
renderers: a
|
|
621
671
|
} : {
|
|
@@ -626,14 +676,14 @@ var q = class e {
|
|
|
626
676
|
}, [e], { timeoutMs: r });
|
|
627
677
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
628
678
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
629
|
-
let e = await
|
|
679
|
+
let e = await D(this._bridge.transport(O), s, {
|
|
630
680
|
timeoutMs: r,
|
|
631
681
|
onUsage: i
|
|
632
682
|
});
|
|
633
683
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
634
684
|
} else this._meta = s.meta;
|
|
635
685
|
else {
|
|
636
|
-
let e = s, t = await
|
|
686
|
+
let e = s, t = await D(this._bridge.transport(O), e, {
|
|
637
687
|
timeoutMs: r,
|
|
638
688
|
onUsage: i
|
|
639
689
|
});
|
|
@@ -654,7 +704,7 @@ var q = class e {
|
|
|
654
704
|
let n = !t.published || this._isLayoutViewActive(t.layoutOptions);
|
|
655
705
|
if (n && this._applyLayoutPartial(e.partial), t.published) {
|
|
656
706
|
if (!n) return;
|
|
657
|
-
|
|
707
|
+
H(this, {
|
|
658
708
|
pageCount: e.partial.pageCount,
|
|
659
709
|
exact: e.partial.exact,
|
|
660
710
|
complete: !1
|
|
@@ -664,7 +714,7 @@ var q = class e {
|
|
|
664
714
|
});
|
|
665
715
|
return;
|
|
666
716
|
}
|
|
667
|
-
t.published = !0, this._layoutLifecycle.begin(),
|
|
717
|
+
t.published = !0, this._layoutLifecycle.begin(), H(this, {
|
|
668
718
|
pageCount: e.partial.pageCount,
|
|
669
719
|
exact: e.partial.exact,
|
|
670
720
|
complete: !1
|
|
@@ -700,7 +750,7 @@ var q = class e {
|
|
|
700
750
|
revisionAnchorRanges: t.revisionAnchorRanges
|
|
701
751
|
};
|
|
702
752
|
}
|
|
703
|
-
this._invalidateLayoutDerivedCaches(), this._review = K(e.comments, e.revisions), t && (t.settled = !0, this._layoutLifecycle.succeed(),
|
|
753
|
+
this._invalidateLayoutDerivedCaches(), this._review = K(e.comments, e.revisions), t && (t.settled = !0, this._layoutLifecycle.succeed(), H(this, {
|
|
704
754
|
pageCount: this.pageCount,
|
|
705
755
|
exact: !0,
|
|
706
756
|
complete: !0
|
|
@@ -715,7 +765,7 @@ var q = class e {
|
|
|
715
765
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
716
766
|
}
|
|
717
767
|
_isLayoutViewActive(e) {
|
|
718
|
-
return
|
|
768
|
+
return Lt(w(this).activeLayoutOptions, e);
|
|
719
769
|
}
|
|
720
770
|
_rearmParseWatchdog() {
|
|
721
771
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -736,7 +786,7 @@ var q = class e {
|
|
|
736
786
|
return;
|
|
737
787
|
}
|
|
738
788
|
let n = this._layoutLifecycle.fail(t);
|
|
739
|
-
|
|
789
|
+
H(this, {
|
|
740
790
|
pageCount: this.pageCount,
|
|
741
791
|
exact: !1,
|
|
742
792
|
complete: !1,
|
|
@@ -744,7 +794,7 @@ var q = class e {
|
|
|
744
794
|
}), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
|
|
745
795
|
}
|
|
746
796
|
_parseViewFields() {
|
|
747
|
-
let e =
|
|
797
|
+
let e = w(this), t = e.activeLayoutOptions;
|
|
748
798
|
return t ? {
|
|
749
799
|
...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
|
|
750
800
|
...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
|
|
@@ -757,7 +807,7 @@ var q = class e {
|
|
|
757
807
|
data: e,
|
|
758
808
|
resourcePolicy: t,
|
|
759
809
|
useGoogleFonts: n,
|
|
760
|
-
defaultCurrentDateMs:
|
|
810
|
+
defaultCurrentDateMs: w(this).defaultCurrentDateMs,
|
|
761
811
|
...this._parseViewFields(),
|
|
762
812
|
renderers: a,
|
|
763
813
|
progressiveLayout: !0
|
|
@@ -765,7 +815,7 @@ var q = class e {
|
|
|
765
815
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
766
816
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
767
817
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
768
|
-
let t = await
|
|
818
|
+
let t = await D(this._bridge.transport(O), e, {
|
|
769
819
|
timeoutMs: r,
|
|
770
820
|
onUsage: i
|
|
771
821
|
});
|
|
@@ -784,7 +834,7 @@ var q = class e {
|
|
|
784
834
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
785
835
|
}
|
|
786
836
|
destroy() {
|
|
787
|
-
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 =
|
|
837
|
+
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 = Vt, w(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 = []), l(this._fetchImage), u(this._fetchImage);
|
|
788
838
|
}
|
|
789
839
|
async getImage(e, t) {
|
|
790
840
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -845,32 +895,32 @@ var q = class e {
|
|
|
845
895
|
return this._reviewSnapshot().revisions;
|
|
846
896
|
}
|
|
847
897
|
commentAnchorRanges() {
|
|
848
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
898
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? zt;
|
|
849
899
|
if (!this._document || !this._source) return [];
|
|
850
900
|
let e = this._reviewSnapshot().comments;
|
|
851
|
-
if (e.length === 0) return
|
|
852
|
-
let t =
|
|
901
|
+
if (e.length === 0) return zt;
|
|
902
|
+
let t = w(this), n = t.services;
|
|
853
903
|
if (!n) throw Error("Document layout services are not initialized");
|
|
854
|
-
let r =
|
|
904
|
+
let r = T(n);
|
|
855
905
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
856
906
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
857
|
-
this._reviewProjectionIndex ??=
|
|
907
|
+
this._reviewProjectionIndex ??= Ke(a);
|
|
858
908
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
859
|
-
return this._commentAnchorRanges ??=
|
|
909
|
+
return this._commentAnchorRanges ??= et(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
860
910
|
}
|
|
861
911
|
revisionAnchorRanges() {
|
|
862
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
912
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? Bt;
|
|
863
913
|
if (!this._document || !this._source) return [];
|
|
864
914
|
let e = this._reviewSnapshot().revisions;
|
|
865
|
-
if (e.length === 0) return
|
|
866
|
-
let t =
|
|
915
|
+
if (e.length === 0) return Bt;
|
|
916
|
+
let t = w(this), n = t.services;
|
|
867
917
|
if (!n) throw Error("Document layout services are not initialized");
|
|
868
|
-
let r =
|
|
918
|
+
let r = T(n);
|
|
869
919
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
870
920
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
871
|
-
this._reviewProjectionIndex ??=
|
|
921
|
+
this._reviewProjectionIndex ??= Ke(a);
|
|
872
922
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
873
|
-
return this._revisionAnchorRanges ??=
|
|
923
|
+
return this._revisionAnchorRanges ??= Ot(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
874
924
|
}
|
|
875
925
|
_reviewSnapshot() {
|
|
876
926
|
return this._review ||= K(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
@@ -883,39 +933,39 @@ var q = class e {
|
|
|
883
933
|
}
|
|
884
934
|
_getLayout() {
|
|
885
935
|
if (!this._document) return null;
|
|
886
|
-
let e =
|
|
936
|
+
let e = w(this), t = e.services;
|
|
887
937
|
if (!t) throw Error("Document layout services are not initialized");
|
|
888
|
-
let n =
|
|
938
|
+
let n = T(t);
|
|
889
939
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
890
940
|
let r = e.activeLayoutOptions;
|
|
891
941
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
892
942
|
}
|
|
893
943
|
async setLayoutView(e = {}) {
|
|
894
|
-
let t =
|
|
895
|
-
if (!
|
|
944
|
+
let t = e[Pt], n = w(this), r = E(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
|
|
945
|
+
if (!Lt(a, r)) {
|
|
896
946
|
if (this._mode === "worker" && this._meta) {
|
|
897
947
|
let e = await this._bridge.request((e) => ({
|
|
898
948
|
type: "selectLayoutView",
|
|
899
949
|
id: e,
|
|
900
|
-
currentDateMs:
|
|
901
|
-
showTrackedChanges:
|
|
950
|
+
currentDateMs: r.currentDateMs,
|
|
951
|
+
showTrackedChanges: r.showTrackedChanges === !0
|
|
902
952
|
}));
|
|
903
|
-
if (
|
|
904
|
-
let
|
|
905
|
-
|
|
953
|
+
if (i !== this._layoutViewGeneration) return;
|
|
954
|
+
let a = e;
|
|
955
|
+
n.activeLayoutOptions = r, this._meta = {
|
|
906
956
|
...this._meta,
|
|
907
|
-
...
|
|
908
|
-
}, this._invalidateLayoutDerivedCaches();
|
|
957
|
+
...a.meta
|
|
958
|
+
}, this._invalidateLayoutDerivedCaches(), Ft(this, t);
|
|
909
959
|
return;
|
|
910
960
|
}
|
|
911
|
-
|
|
961
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), Ft(this, t);
|
|
912
962
|
}
|
|
913
963
|
}
|
|
914
964
|
_getBookmarkPages() {
|
|
915
965
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
916
966
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
917
967
|
let e = this._getLayout();
|
|
918
|
-
return e ? (this._bookmarkPages =
|
|
968
|
+
return e ? (this._bookmarkPages = at(e), this._bookmarkPages) : null;
|
|
919
969
|
}
|
|
920
970
|
getBookmarkPage(e) {
|
|
921
971
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -947,7 +997,7 @@ var q = class e {
|
|
|
947
997
|
};
|
|
948
998
|
}
|
|
949
999
|
_withActiveView(e) {
|
|
950
|
-
let t =
|
|
1000
|
+
let t = w(this).activeLayoutOptions;
|
|
951
1001
|
if (!t) return e;
|
|
952
1002
|
let n = { ...e };
|
|
953
1003
|
return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
|
|
@@ -955,11 +1005,11 @@ var q = class e {
|
|
|
955
1005
|
renderPage(e, t, n = {}) {
|
|
956
1006
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
957
1007
|
if (!this._source) throw Error("Document not loaded");
|
|
958
|
-
return
|
|
1008
|
+
return Me(this._source, e, t, {
|
|
959
1009
|
...this._withActiveView(n),
|
|
960
1010
|
fetchImage: this._fetchImage,
|
|
961
|
-
layoutServices:
|
|
962
|
-
defaultCurrentDateMs:
|
|
1011
|
+
layoutServices: w(this).services ?? void 0,
|
|
1012
|
+
defaultCurrentDateMs: w(this).defaultCurrentDateMs,
|
|
963
1013
|
threeD: this._threeD,
|
|
964
1014
|
regionMap: this._regionMap,
|
|
965
1015
|
chartEx: this._chartEx
|
|
@@ -994,9 +1044,9 @@ var q = class e {
|
|
|
994
1044
|
pageIndex: e,
|
|
995
1045
|
opts: n
|
|
996
1046
|
}))).runs;
|
|
997
|
-
let r =
|
|
1047
|
+
let r = w(this), i = r.services;
|
|
998
1048
|
if (!i) throw Error("Document layout services are not initialized");
|
|
999
|
-
return
|
|
1049
|
+
return qe(i, e, {
|
|
1000
1050
|
currentDate: n.currentDate,
|
|
1001
1051
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
1002
1052
|
width: n.width,
|
|
@@ -1005,7 +1055,7 @@ var q = class e {
|
|
|
1005
1055
|
}
|
|
1006
1056
|
async getCommentThreads(e, t = {}) {
|
|
1007
1057
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1008
|
-
return
|
|
1058
|
+
return $e(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1009
1059
|
}
|
|
1010
1060
|
async getElementContextAt(e, t, n = {}) {
|
|
1011
1061
|
let r = this._withActiveView(n);
|
|
@@ -1016,9 +1066,9 @@ var q = class e {
|
|
|
1016
1066
|
point: t,
|
|
1017
1067
|
opts: r
|
|
1018
1068
|
}))).context;
|
|
1019
|
-
let i =
|
|
1069
|
+
let i = w(this), a = i.services;
|
|
1020
1070
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1021
|
-
return
|
|
1071
|
+
return Ct(a, e, t, {
|
|
1022
1072
|
...r,
|
|
1023
1073
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1024
1074
|
});
|
|
@@ -1026,7 +1076,7 @@ var q = class e {
|
|
|
1026
1076
|
};
|
|
1027
1077
|
//#endregion
|
|
1028
1078
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1029
|
-
function
|
|
1079
|
+
function Ht(e, t) {
|
|
1030
1080
|
if (!e.eastAsianVert) return 1;
|
|
1031
1081
|
let n = t(e.text);
|
|
1032
1082
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
@@ -1044,11 +1094,11 @@ function Y(e, t, n, r, i, a, o) {
|
|
|
1044
1094
|
J(t, "ooxmlSelectionRun", "docx"), J(t, "runIndex", String(o)), c.paragraphId !== void 0 && J(t, "paragraphId", c.paragraphId), c.source !== void 0 && (J(t, "sourceStory", c.source.story), J(t, "sourceStoryInstance", c.source.storyInstance), J(t, "sourcePath", JSON.stringify(c.source.path))), t.textContent = c.text;
|
|
1045
1095
|
let l = c.transform ?? "";
|
|
1046
1096
|
if (a && c.eastAsianVert) {
|
|
1047
|
-
let e =
|
|
1097
|
+
let e = Ht(c, a(c.font));
|
|
1048
1098
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1049
1099
|
}
|
|
1050
1100
|
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`;
|
|
1051
|
-
t.style.cssText = `position:absolute;left:${
|
|
1101
|
+
t.style.cssText = `position:absolute;left:${A(c.x, n)};top:${A(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
|
|
1052
1102
|
e.preventDefault(), i(d);
|
|
1053
1103
|
})), e.appendChild(t);
|
|
1054
1104
|
}
|
|
@@ -1061,16 +1111,16 @@ function X(e, t, n, r, i, a, o = {}) {
|
|
|
1061
1111
|
for (let s of o.slices) {
|
|
1062
1112
|
let o = t[s.runIndex];
|
|
1063
1113
|
if (!o) continue;
|
|
1064
|
-
let c = a(o.font), l =
|
|
1114
|
+
let c = a(o.font), l = Ze(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, _ = Ht(o, c), ee = h * _, v = g * _;
|
|
1065
1115
|
if (v <= 0) continue;
|
|
1066
1116
|
let y = document.createElement("div"), te = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
1067
|
-
y.style.cssText = `position:absolute;left:${
|
|
1117
|
+
y.style.cssText = `position:absolute;left:${A(o.x + ee, r)};top:${A(o.y, i)};width:${A(v, r)};height:${A(o.h, i)};` + te + `background:${n};pointer-events:none;`, e.appendChild(y);
|
|
1068
1118
|
}
|
|
1069
1119
|
}
|
|
1070
1120
|
}
|
|
1071
1121
|
//#endregion
|
|
1072
1122
|
//#region packages/docx/src/find.ts
|
|
1073
|
-
var
|
|
1123
|
+
var Ut = class {
|
|
1074
1124
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1075
1125
|
_matches = [];
|
|
1076
1126
|
_active = -1;
|
|
@@ -1162,7 +1212,7 @@ var Z = class {
|
|
|
1162
1212
|
};
|
|
1163
1213
|
//#endregion
|
|
1164
1214
|
//#region packages/docx/src/selection-context.ts
|
|
1165
|
-
function
|
|
1215
|
+
function Wt(e, t, n, r, i = {}) {
|
|
1166
1216
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1167
1217
|
if (!a) return null;
|
|
1168
1218
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1176,7 +1226,7 @@ function It(e, t, n, r, i = {}) {
|
|
|
1176
1226
|
t = e;
|
|
1177
1227
|
}
|
|
1178
1228
|
return !1;
|
|
1179
|
-
}), c =
|
|
1229
|
+
}), c = Se({
|
|
1180
1230
|
id: a.id,
|
|
1181
1231
|
author: a.author,
|
|
1182
1232
|
date: a.date,
|
|
@@ -1205,19 +1255,19 @@ function It(e, t, n, r, i = {}) {
|
|
|
1205
1255
|
maxTextCharacters: c.maxTextCharacters
|
|
1206
1256
|
});
|
|
1207
1257
|
}
|
|
1208
|
-
function
|
|
1258
|
+
function Z(e) {
|
|
1209
1259
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1210
1260
|
let t = Number(e);
|
|
1211
1261
|
return Number.isSafeInteger(t) ? t : null;
|
|
1212
1262
|
}
|
|
1213
|
-
function
|
|
1263
|
+
function Gt(e) {
|
|
1214
1264
|
for (let t = e; t; t = t.parentElement) {
|
|
1215
|
-
let e =
|
|
1265
|
+
let e = Z(t.dataset.pageIndex);
|
|
1216
1266
|
if (e !== null) return e;
|
|
1217
1267
|
}
|
|
1218
1268
|
return null;
|
|
1219
1269
|
}
|
|
1220
|
-
var
|
|
1270
|
+
var Kt = new Set([
|
|
1221
1271
|
"body",
|
|
1222
1272
|
"header",
|
|
1223
1273
|
"footer",
|
|
@@ -1225,9 +1275,9 @@ var zt = new Set([
|
|
|
1225
1275
|
"endnote",
|
|
1226
1276
|
"textbox"
|
|
1227
1277
|
]);
|
|
1228
|
-
function
|
|
1278
|
+
function qt(e) {
|
|
1229
1279
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1230
|
-
if (!t || !
|
|
1280
|
+
if (!t || !Kt.has(t) || !n || !r) return null;
|
|
1231
1281
|
try {
|
|
1232
1282
|
let e = JSON.parse(r);
|
|
1233
1283
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1240,13 +1290,13 @@ function Bt(e) {
|
|
|
1240
1290
|
}
|
|
1241
1291
|
}
|
|
1242
1292
|
function Q(e, t, n = {}) {
|
|
1243
|
-
let r =
|
|
1244
|
-
let t =
|
|
1293
|
+
let r = le(e, t, (e) => {
|
|
1294
|
+
let t = Gt(e), n = Z(e.dataset.runIndex);
|
|
1245
1295
|
return t === null || n === null ? null : {
|
|
1246
1296
|
pageIndex: t,
|
|
1247
1297
|
runIndex: n,
|
|
1248
1298
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1249
|
-
...
|
|
1299
|
+
...qt(e) === null ? {} : { source: qt(e) }
|
|
1250
1300
|
};
|
|
1251
1301
|
}, {
|
|
1252
1302
|
maxChars: n.maxTextCharacters,
|
|
@@ -1275,7 +1325,7 @@ function $(e, t, n, r, i) {
|
|
|
1275
1325
|
}
|
|
1276
1326
|
//#endregion
|
|
1277
1327
|
//#region packages/docx/src/viewer.ts
|
|
1278
|
-
var
|
|
1328
|
+
var Jt = Symbol("DocxViewer.borrowedDocument"), Yt = class e {
|
|
1279
1329
|
_documentOwner;
|
|
1280
1330
|
get _doc() {
|
|
1281
1331
|
return this._documentOwner.current;
|
|
@@ -1303,6 +1353,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1303
1353
|
_elementContext = null;
|
|
1304
1354
|
_elementHitGeneration = 0;
|
|
1305
1355
|
_layoutViewGeneration = 0;
|
|
1356
|
+
_layoutViewPublicationGeneration = 0;
|
|
1306
1357
|
_navigationGeneration = 0;
|
|
1307
1358
|
_layoutUnsubscribe = null;
|
|
1308
1359
|
_internalHyperlinkGeneration = 0;
|
|
@@ -1312,21 +1363,24 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1312
1363
|
_elementClickListener = null;
|
|
1313
1364
|
_contextMenuListener = null;
|
|
1314
1365
|
static fromDocument(t, n, r = {}) {
|
|
1366
|
+
let i = W(n);
|
|
1315
1367
|
return new e(t, {
|
|
1316
1368
|
...r,
|
|
1317
|
-
|
|
1369
|
+
currentDate: i.currentDate,
|
|
1370
|
+
showTrackedChanges: i.showTrackedChanges,
|
|
1371
|
+
[Jt]: n
|
|
1318
1372
|
});
|
|
1319
1373
|
}
|
|
1320
1374
|
constructor(e, t = {}) {
|
|
1321
1375
|
this._canvas = e, this._opts = t;
|
|
1322
|
-
let n = t[
|
|
1376
|
+
let n = t[Jt];
|
|
1323
1377
|
this._borrowed = n !== void 0, this._mode = x("DocxViewer", t.mode, n), this._documentOwner = new _("DocxViewer", n ?? null, !1);
|
|
1324
1378
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1325
1379
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
1326
|
-
this._hostWindow = r, this._canvasMount = new
|
|
1380
|
+
this._hostWindow = r, this._canvasMount = new ue(e, {
|
|
1327
1381
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1328
1382
|
forceDisplayBlock: !0
|
|
1329
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new b(e, this._mode === "worker"), this._errorRouter = new
|
|
1383
|
+
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new b(e, this._mode === "worker"), this._errorRouter = new ce("DocxViewer", t.onError);
|
|
1330
1384
|
let i = new ae(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1331
1385
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
|
|
1332
1386
|
"position:absolute",
|
|
@@ -1341,7 +1395,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1341
1395
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1342
1396
|
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) => {
|
|
1343
1397
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1344
|
-
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new
|
|
1398
|
+
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new Ut(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
|
|
1345
1399
|
}
|
|
1346
1400
|
async load(e) {
|
|
1347
1401
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
@@ -1420,7 +1474,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1420
1474
|
await this.goToPage(this._currentPage - 1);
|
|
1421
1475
|
}
|
|
1422
1476
|
_naturalWidthPx() {
|
|
1423
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
1477
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * k;
|
|
1424
1478
|
}
|
|
1425
1479
|
_renderWidth() {
|
|
1426
1480
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1443,10 +1497,10 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1443
1497
|
this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
|
|
1444
1498
|
}
|
|
1445
1499
|
async zoomIn() {
|
|
1446
|
-
await this.setScale(
|
|
1500
|
+
await this.setScale(fe(this.getScale()));
|
|
1447
1501
|
}
|
|
1448
1502
|
async zoomOut() {
|
|
1449
|
-
await this.setScale(
|
|
1503
|
+
await this.setScale(he(this.getScale()));
|
|
1450
1504
|
}
|
|
1451
1505
|
async fitWidth() {
|
|
1452
1506
|
await this._fit("width");
|
|
@@ -1459,8 +1513,8 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1459
1513
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1460
1514
|
if (!n) return;
|
|
1461
1515
|
let r = g({
|
|
1462
|
-
contentWidth: t.widthPt *
|
|
1463
|
-
contentHeight: t.heightPt *
|
|
1516
|
+
contentWidth: t.widthPt * k,
|
|
1517
|
+
contentHeight: t.heightPt * k,
|
|
1464
1518
|
containerWidth: n.clientWidth,
|
|
1465
1519
|
containerHeight: n.clientHeight
|
|
1466
1520
|
}, e);
|
|
@@ -1499,7 +1553,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1499
1553
|
}
|
|
1500
1554
|
getSelectionContext(e = {}) {
|
|
1501
1555
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1502
|
-
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ?
|
|
1556
|
+
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? L(this._elementContext, e.maxTextCharacters) : null);
|
|
1503
1557
|
}
|
|
1504
1558
|
_emitSelectionContextChange() {
|
|
1505
1559
|
let e = this.getSelectionContext();
|
|
@@ -1554,7 +1608,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1554
1608
|
}, {
|
|
1555
1609
|
currentDate: this._opts.currentDate,
|
|
1556
1610
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1557
|
-
maxTextCharacters:
|
|
1611
|
+
maxTextCharacters: N
|
|
1558
1612
|
});
|
|
1559
1613
|
} catch (e) {
|
|
1560
1614
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1563,7 +1617,7 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1563
1617
|
return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
|
|
1564
1618
|
}
|
|
1565
1619
|
destroy() {
|
|
1566
|
-
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(),
|
|
1620
|
+
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), We(this._canvas), this._documentOwner.close(), this._find.invalidate(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._wrapper.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._wrapper.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._canvasMount.restore());
|
|
1567
1621
|
}
|
|
1568
1622
|
async _render() {
|
|
1569
1623
|
let e = this._renderDispatcher.begin();
|
|
@@ -1597,19 +1651,21 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1597
1651
|
this._textLayer && this._buildTextLayer(this._textLayer, o), this._find.setPageRuns(this._currentPage, o), this._buildHighlightLayer(o), this._opts.onPageChange?.(this._currentPage, this.pageCount, this.layoutComplete);
|
|
1598
1652
|
}
|
|
1599
1653
|
_bindLayoutDocument(e) {
|
|
1600
|
-
this._unbindLayoutDocument(), this._layoutFailed = !1;
|
|
1601
|
-
let t = !0
|
|
1602
|
-
this._layoutUnsubscribe = kt(e, () => ({
|
|
1654
|
+
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1655
|
+
let t = It(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Mt(e, () => ({
|
|
1603
1656
|
pageCount: e.pageCount,
|
|
1604
1657
|
exact: e.layoutComplete,
|
|
1605
1658
|
complete: e.layoutComplete
|
|
1606
|
-
}), (
|
|
1607
|
-
if (
|
|
1608
|
-
|
|
1659
|
+
}), (t) => {
|
|
1660
|
+
if (n) {
|
|
1661
|
+
n = !1;
|
|
1609
1662
|
return;
|
|
1610
1663
|
}
|
|
1611
|
-
this._onLayoutPublication(e,
|
|
1664
|
+
this._onLayoutPublication(e, t);
|
|
1612
1665
|
}, (e) => this._reportRenderError(e));
|
|
1666
|
+
this._layoutUnsubscribe = () => {
|
|
1667
|
+
r(), t();
|
|
1668
|
+
};
|
|
1613
1669
|
}
|
|
1614
1670
|
_unbindLayoutDocument() {
|
|
1615
1671
|
this._layoutUnsubscribe?.(), this._layoutUnsubscribe = null, this._layoutFailed = !1, this._cancelPendingNavigation();
|
|
@@ -1623,6 +1679,13 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1623
1679
|
this._find.invalidate(), this._currentPage = Math.max(0, Math.min(this._currentPage, t.pageCount - 1)), this._render().catch((e) => this._reportRenderError(e));
|
|
1624
1680
|
}
|
|
1625
1681
|
}
|
|
1682
|
+
_onLayoutViewPublication(e, t) {
|
|
1683
|
+
this._destroyed || e !== this._doc || t.generation <= this._layoutViewPublicationGeneration || (this._layoutViewPublicationGeneration = t.generation, t.requester !== this && (this._layoutViewGeneration++, this._opts = {
|
|
1684
|
+
...this._opts,
|
|
1685
|
+
currentDate: t.view.currentDate,
|
|
1686
|
+
showTrackedChanges: t.view.showTrackedChanges
|
|
1687
|
+
}, this._find.invalidate(), this._currentPage = Math.max(0, Math.min(this._currentPage, e.pageCount - 1)), this._render().catch((e) => this._reportRenderError(e))));
|
|
1688
|
+
}
|
|
1626
1689
|
async _waitForPage(e, t, n) {
|
|
1627
1690
|
await this._errorRouter.ownBackgroundLifecycle(async () => {
|
|
1628
1691
|
for (; !this._destroyed && n === this._navigationGeneration && e === this._doc && t >= e.pageCount && !e.layoutComplete && !this._layoutFailed;) await new Promise((e) => {
|
|
@@ -1645,20 +1708,20 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1645
1708
|
async setShowTrackedChanges(e) {
|
|
1646
1709
|
let t = ++this._layoutViewGeneration, n = this._doc;
|
|
1647
1710
|
if (this._opts.showTrackedChanges === !0 === e) {
|
|
1648
|
-
await n
|
|
1711
|
+
n && await G(n, {
|
|
1649
1712
|
showTrackedChanges: e,
|
|
1650
1713
|
currentDate: this._opts.currentDate
|
|
1651
|
-
});
|
|
1714
|
+
}, this);
|
|
1652
1715
|
return;
|
|
1653
1716
|
}
|
|
1654
1717
|
let r = {
|
|
1655
1718
|
...this._opts,
|
|
1656
1719
|
showTrackedChanges: e
|
|
1657
1720
|
};
|
|
1658
|
-
await n
|
|
1721
|
+
(!n || await G(n, {
|
|
1659
1722
|
showTrackedChanges: e,
|
|
1660
1723
|
currentDate: r.currentDate
|
|
1661
|
-
}
|
|
1724
|
+
}, 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()));
|
|
1662
1725
|
}
|
|
1663
1726
|
_buildHighlightLayer(e) {
|
|
1664
1727
|
let t = this._highlightLayer;
|
|
@@ -1705,11 +1768,11 @@ var Vt = Symbol("DocxViewer.borrowedDocument"), Ht = class e {
|
|
|
1705
1768
|
let r = e.getBookmarkPage(t);
|
|
1706
1769
|
r !== void 0 && await this.goToPage(r);
|
|
1707
1770
|
}
|
|
1708
|
-
},
|
|
1709
|
-
function
|
|
1710
|
-
return
|
|
1771
|
+
}, Xt = 150, Zt = "0 1px 3px rgba(0,0,0,0.2)", Qt = 12, $t = 13, en = Symbol("DocxScrollViewer.borrowedDocument"), tn;
|
|
1772
|
+
function nn() {
|
|
1773
|
+
return tn ??= import("./comment-ui-runtime-DD5a3x3k.js");
|
|
1711
1774
|
}
|
|
1712
|
-
var
|
|
1775
|
+
var rn = class e {
|
|
1713
1776
|
_documentOwner;
|
|
1714
1777
|
get _doc() {
|
|
1715
1778
|
return this._documentOwner.current;
|
|
@@ -1773,22 +1836,27 @@ var Xt = class e {
|
|
|
1773
1836
|
_prevBase = 0;
|
|
1774
1837
|
_lastFitWidth = 0;
|
|
1775
1838
|
_pageShadow;
|
|
1776
|
-
_find = new
|
|
1839
|
+
_find = new Ut(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
1777
1840
|
_findActive = !1;
|
|
1778
1841
|
_findRequestGeneration = 0;
|
|
1779
1842
|
_showTrackedChanges;
|
|
1843
|
+
_currentDate;
|
|
1780
1844
|
_layoutViewGeneration = 0;
|
|
1845
|
+
_layoutViewPublicationGeneration = 0;
|
|
1781
1846
|
static fromDocument(t, n, r = {}) {
|
|
1847
|
+
let i = W(n);
|
|
1782
1848
|
return new e(t, {
|
|
1783
1849
|
...r,
|
|
1784
|
-
|
|
1850
|
+
currentDate: i.currentDate,
|
|
1851
|
+
showTrackedChanges: i.showTrackedChanges,
|
|
1852
|
+
[en]: n
|
|
1785
1853
|
});
|
|
1786
1854
|
}
|
|
1787
1855
|
constructor(e, t = {}) {
|
|
1788
1856
|
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.");
|
|
1789
|
-
this._container = e, this._opts = t, this._errorRouter = new
|
|
1790
|
-
let n = t[
|
|
1791
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new _("DocxScrollViewer", n, !1), this._mode = x("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new _("DocxScrollViewer"), this._mode = x("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() &&
|
|
1857
|
+
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 ?? Zt;
|
|
1858
|
+
let n = t[en];
|
|
1859
|
+
this._borrowed = n !== void 0, n ? (this._documentOwner = new _("DocxScrollViewer", n, !1), this._mode = x("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new _("DocxScrollViewer"), this._mode = x("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() && nn().then((e) => {
|
|
1792
1860
|
if (!this._destroyed) {
|
|
1793
1861
|
this._commentUi = e;
|
|
1794
1862
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -1796,7 +1864,7 @@ var Xt = class e {
|
|
|
1796
1864
|
}).catch((e) => this._reportRenderError(e)), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1797
1865
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1798
1866
|
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), t.comments && (this._commentOutsidePointerListener = (e) => {
|
|
1799
|
-
if (!
|
|
1867
|
+
if (!Te(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
|
|
1800
1868
|
this._activeCommentId = null, this._activeCommentPage = null;
|
|
1801
1869
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
1802
1870
|
this._emitSelectionContextChange();
|
|
@@ -1807,7 +1875,7 @@ var Xt = class e {
|
|
|
1807
1875
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
1808
1876
|
x: n,
|
|
1809
1877
|
y: r
|
|
1810
|
-
} : null, this.setScale(
|
|
1878
|
+
} : null, this.setScale(me(this._scale, e.deltaY, e.deltaMode));
|
|
1811
1879
|
}, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && (this._bindLayoutDocument(n), this.relayout());
|
|
1812
1880
|
}
|
|
1813
1881
|
async load(e) {
|
|
@@ -1830,7 +1898,7 @@ var Xt = class e {
|
|
|
1830
1898
|
chartEx: this._opts.chartEx,
|
|
1831
1899
|
mode: this._mode,
|
|
1832
1900
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
1833
|
-
...this.
|
|
1901
|
+
...this._currentDate === void 0 ? {} : { currentDate: this._currentDate },
|
|
1834
1902
|
...this._opts.progressiveLayout ? { progressiveLayout: !0 } : {},
|
|
1835
1903
|
...this._opts.sliceLayout ? { sliceLayout: !0 } : {},
|
|
1836
1904
|
onLayoutProgress: this._opts.onLayoutProgress,
|
|
@@ -1864,19 +1932,21 @@ var Xt = class e {
|
|
|
1864
1932
|
});
|
|
1865
1933
|
}
|
|
1866
1934
|
_bindLayoutDocument(e) {
|
|
1867
|
-
this._unbindLayoutDocument(), this._presentedPageCount = e.pageCount, this._pendingLayoutPublication = null;
|
|
1868
|
-
let t = !0
|
|
1869
|
-
this._layoutUnsubscribe = kt(e, () => ({
|
|
1935
|
+
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount, this._pendingLayoutPublication = null;
|
|
1936
|
+
let t = It(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = Mt(e, () => ({
|
|
1870
1937
|
pageCount: e.pageCount,
|
|
1871
1938
|
exact: e.layoutComplete,
|
|
1872
1939
|
complete: e.layoutComplete
|
|
1873
|
-
}), (
|
|
1874
|
-
if (
|
|
1875
|
-
|
|
1940
|
+
}), (t) => {
|
|
1941
|
+
if (n) {
|
|
1942
|
+
n = !1;
|
|
1876
1943
|
return;
|
|
1877
1944
|
}
|
|
1878
|
-
this._onLayoutPublication(e,
|
|
1945
|
+
this._onLayoutPublication(e, t);
|
|
1879
1946
|
}, (e) => this._reportRenderError(e));
|
|
1947
|
+
this._layoutUnsubscribe = () => {
|
|
1948
|
+
r(), t();
|
|
1949
|
+
};
|
|
1880
1950
|
}
|
|
1881
1951
|
_unbindLayoutDocument() {
|
|
1882
1952
|
this._layoutUnsubscribe?.(), this._layoutUnsubscribe = null, this._presentedPageCount = 0, this._pendingLayoutPublication = null;
|
|
@@ -1898,6 +1968,13 @@ var Xt = class e {
|
|
|
1898
1968
|
this._pendingLayoutPublication = null, this._applyLayoutPublication(t);
|
|
1899
1969
|
}
|
|
1900
1970
|
}
|
|
1971
|
+
_onLayoutViewPublication(e, t) {
|
|
1972
|
+
this._destroyed || e !== this._doc || t.generation <= this._layoutViewPublicationGeneration || (this._layoutViewPublicationGeneration = t.generation, t.requester !== this && (this._layoutViewGeneration++, this._showTrackedChanges = t.view.showTrackedChanges, this._currentDate = t.view.currentDate, this._find.invalidate(), this._pendingLayoutPublication = null, this._applyLayoutPublication({
|
|
1973
|
+
pageCount: e.pageCount,
|
|
1974
|
+
exact: !0,
|
|
1975
|
+
complete: e.layoutComplete
|
|
1976
|
+
})));
|
|
1977
|
+
}
|
|
1901
1978
|
_refreshCommentSurface() {
|
|
1902
1979
|
if (!(!this._commentsEnabled() || this._slots.size === 0)) {
|
|
1903
1980
|
this._syncSpacerWidth();
|
|
@@ -1911,17 +1988,17 @@ var Xt = class e {
|
|
|
1911
1988
|
}
|
|
1912
1989
|
_revealPendingLayoutAtPresentedTail() {
|
|
1913
1990
|
let e = this._pendingLayoutPublication;
|
|
1914
|
-
!e || this._presentedPageCount === 0 ||
|
|
1991
|
+
!e || this._presentedPageCount === 0 || S(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, 0).end < this._presentedPageCount - 1 || (this._pendingLayoutPublication = null, this._applyLayoutPublication(e));
|
|
1915
1992
|
}
|
|
1916
1993
|
_revealPendingLayoutThroughPage(e) {
|
|
1917
1994
|
let t = this._pendingLayoutPublication;
|
|
1918
1995
|
!t || e < this._presentedPageCount || (this._pendingLayoutPublication = null, this._applyLayoutPublication(t));
|
|
1919
1996
|
}
|
|
1920
1997
|
_pageWidthPx(e) {
|
|
1921
|
-
return this._doc.pageSize(e).widthPt *
|
|
1998
|
+
return this._doc.pageSize(e).widthPt * k * this._scale;
|
|
1922
1999
|
}
|
|
1923
2000
|
_pageHeightPx(e) {
|
|
1924
|
-
return this._doc.pageSize(e).heightPt *
|
|
2001
|
+
return this._doc.pageSize(e).heightPt * k * this._scale;
|
|
1925
2002
|
}
|
|
1926
2003
|
_fitWidthPx() {
|
|
1927
2004
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -1943,7 +2020,7 @@ var Xt = class e {
|
|
|
1943
2020
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
1944
2021
|
}
|
|
1945
2022
|
_commentMarginExtent() {
|
|
1946
|
-
return this._hasCommentMargin() ? (
|
|
2023
|
+
return this._hasCommentMargin() ? (Qt + 280) * this._commentZoom() : 0;
|
|
1947
2024
|
}
|
|
1948
2025
|
_commentZoom() {
|
|
1949
2026
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -1960,15 +2037,15 @@ var Xt = class e {
|
|
|
1960
2037
|
}
|
|
1961
2038
|
_syncCommentMarginGeometry(e) {
|
|
1962
2039
|
if (!e) return;
|
|
1963
|
-
let t = this._commentZoom(), n = `calc(100% + ${
|
|
1964
|
-
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${
|
|
2040
|
+
let t = this._commentZoom(), n = `calc(100% + ${Qt * t}px)`;
|
|
2041
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${$t}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
1965
2042
|
}
|
|
1966
2043
|
_baseScale() {
|
|
1967
2044
|
if (!this._doc || this._doc.pageCount === 0) return 0;
|
|
1968
2045
|
let e = this._fitWidthPx();
|
|
1969
2046
|
if (e <= 0) return 0;
|
|
1970
2047
|
let t = this._doc.pageSize(0).widthPt;
|
|
1971
|
-
return t <= 0 ? 0 : e / (t *
|
|
2048
|
+
return t <= 0 ? 0 : e / (t * k);
|
|
1972
2049
|
}
|
|
1973
2050
|
relayout() {
|
|
1974
2051
|
this._relayout();
|
|
@@ -1991,7 +2068,7 @@ var Xt = class e {
|
|
|
1991
2068
|
_recomputeHeights() {
|
|
1992
2069
|
let e = Math.min(this._presentedPageCount, this._doc.pageCount), t = Array(e);
|
|
1993
2070
|
for (let n = 0; n < e; n++) t[n] = this._pageHeightPx(n);
|
|
1994
|
-
this._heights = t, this._scrollGeometry =
|
|
2071
|
+
this._heights = t, this._scrollGeometry = we(t, this._gap(), this._pad());
|
|
1995
2072
|
}
|
|
1996
2073
|
_gap() {
|
|
1997
2074
|
return this._opts.gap ?? 16;
|
|
@@ -2022,7 +2099,7 @@ var Xt = class e {
|
|
|
2022
2099
|
return a;
|
|
2023
2100
|
}
|
|
2024
2101
|
_range() {
|
|
2025
|
-
return
|
|
2102
|
+
return S(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
|
|
2026
2103
|
}
|
|
2027
2104
|
_syncSpacer() {
|
|
2028
2105
|
let e = this._range();
|
|
@@ -2124,7 +2201,7 @@ var Xt = class e {
|
|
|
2124
2201
|
width: i,
|
|
2125
2202
|
dpr: r,
|
|
2126
2203
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2127
|
-
currentDate: this.
|
|
2204
|
+
currentDate: this._currentDate,
|
|
2128
2205
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2129
2206
|
onTextRun: f
|
|
2130
2207
|
});
|
|
@@ -2185,7 +2262,7 @@ var Xt = class e {
|
|
|
2185
2262
|
width: n,
|
|
2186
2263
|
dpr: r,
|
|
2187
2264
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2188
|
-
currentDate: this.
|
|
2265
|
+
currentDate: this._currentDate,
|
|
2189
2266
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2190
2267
|
onTextRun: f ? (e) => p.push(e) : void 0
|
|
2191
2268
|
});
|
|
@@ -2222,7 +2299,7 @@ var Xt = class e {
|
|
|
2222
2299
|
f = Math.min(1, Math.max(0, f));
|
|
2223
2300
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
2224
2301
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2225
|
-
let h =
|
|
2302
|
+
let h = S(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
|
|
2226
2303
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
2227
2304
|
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;
|
|
2228
2305
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
@@ -2235,10 +2312,10 @@ var Xt = class e {
|
|
|
2235
2312
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2236
2313
|
}
|
|
2237
2314
|
zoomIn() {
|
|
2238
|
-
this.setScale(
|
|
2315
|
+
this.setScale(fe(this.getScale()));
|
|
2239
2316
|
}
|
|
2240
2317
|
zoomOut() {
|
|
2241
|
-
this.setScale(
|
|
2318
|
+
this.setScale(he(this.getScale()));
|
|
2242
2319
|
}
|
|
2243
2320
|
fitWidth() {
|
|
2244
2321
|
this._fit("width");
|
|
@@ -2249,8 +2326,8 @@ var Xt = class e {
|
|
|
2249
2326
|
_fit(e) {
|
|
2250
2327
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2251
2328
|
let t = this._doc.pageSize(0), n = g({
|
|
2252
|
-
contentWidth: t.widthPt *
|
|
2253
|
-
contentHeight: t.heightPt *
|
|
2329
|
+
contentWidth: t.widthPt * k,
|
|
2330
|
+
contentHeight: t.heightPt * k,
|
|
2254
2331
|
containerWidth: this._fitWidthPx(),
|
|
2255
2332
|
containerHeight: this._scrollHost.clientHeight
|
|
2256
2333
|
}, e);
|
|
@@ -2287,7 +2364,7 @@ var Xt = class e {
|
|
|
2287
2364
|
_scheduleSettle() {
|
|
2288
2365
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2289
2366
|
this._settleTimer = null, this._settleRender();
|
|
2290
|
-
},
|
|
2367
|
+
}, Xt);
|
|
2291
2368
|
}
|
|
2292
2369
|
_settleRender() {
|
|
2293
2370
|
if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._refreshSlotAtomically(e, t);
|
|
@@ -2306,7 +2383,7 @@ var Xt = class e {
|
|
|
2306
2383
|
width: r,
|
|
2307
2384
|
dpr: n,
|
|
2308
2385
|
defaultTextColor: this._opts.defaultTextColor,
|
|
2309
|
-
currentDate: this.
|
|
2386
|
+
currentDate: this._currentDate,
|
|
2310
2387
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2311
2388
|
onTextRun: f
|
|
2312
2389
|
}).then(() => {
|
|
@@ -2327,26 +2404,26 @@ var Xt = class e {
|
|
|
2327
2404
|
async setShowTrackedChanges(e) {
|
|
2328
2405
|
let t = ++this._layoutViewGeneration, n = this._doc;
|
|
2329
2406
|
if (this._showTrackedChanges === e) {
|
|
2330
|
-
await n
|
|
2407
|
+
n && await G(n, {
|
|
2331
2408
|
showTrackedChanges: e,
|
|
2332
|
-
currentDate: this.
|
|
2333
|
-
});
|
|
2409
|
+
currentDate: this._currentDate
|
|
2410
|
+
}, this);
|
|
2334
2411
|
return;
|
|
2335
2412
|
}
|
|
2336
|
-
await n
|
|
2413
|
+
(!n || await G(n, {
|
|
2337
2414
|
showTrackedChanges: e,
|
|
2338
|
-
currentDate: this.
|
|
2339
|
-
}
|
|
2415
|
+
currentDate: this._currentDate
|
|
2416
|
+
}, this)) && (this._destroyed || t !== this._layoutViewGeneration || n !== this._doc || (this._showTrackedChanges = e, this._find.invalidate(), this._pendingLayoutPublication = null, this._applyLayoutPublication({
|
|
2340
2417
|
pageCount: n?.pageCount ?? 0,
|
|
2341
2418
|
exact: !0,
|
|
2342
2419
|
complete: n?.layoutComplete !== !1
|
|
2343
|
-
}));
|
|
2420
|
+
})));
|
|
2344
2421
|
}
|
|
2345
2422
|
scrollToPage(e, t) {
|
|
2346
2423
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2347
2424
|
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1));
|
|
2348
2425
|
this._revealPendingLayoutThroughPage(n);
|
|
2349
|
-
let r =
|
|
2426
|
+
let r = S(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;
|
|
2350
2427
|
typeof s.scrollTo == "function" ? s.scrollTo({
|
|
2351
2428
|
top: o,
|
|
2352
2429
|
behavior: t?.behavior ?? "auto"
|
|
@@ -2354,7 +2431,7 @@ var Xt = class e {
|
|
|
2354
2431
|
}
|
|
2355
2432
|
_scrollToPageTarget(e, t, n) {
|
|
2356
2433
|
this._revealPendingLayoutThroughPage(e);
|
|
2357
|
-
let r =
|
|
2434
|
+
let r = S(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;
|
|
2358
2435
|
typeof f.scrollTo == "function" ? f.scrollTo({
|
|
2359
2436
|
top: u,
|
|
2360
2437
|
left: d,
|
|
@@ -2369,7 +2446,7 @@ var Xt = class e {
|
|
|
2369
2446
|
}
|
|
2370
2447
|
_indexCommentPages(e, t, n) {
|
|
2371
2448
|
if (!this._commentIndexedPages.has(e)) {
|
|
2372
|
-
for (let r of n) this._commentPageById.has(r.commentId) ||
|
|
2449
|
+
for (let r of n) this._commentPageById.has(r.commentId) || M(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
|
|
2373
2450
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2374
2451
|
}
|
|
2375
2452
|
}
|
|
@@ -2380,7 +2457,7 @@ var Xt = class e {
|
|
|
2380
2457
|
scale: n,
|
|
2381
2458
|
runs: t.collectPageRuns(e, {
|
|
2382
2459
|
width: this._pageWidthPx(e),
|
|
2383
|
-
currentDate: this.
|
|
2460
|
+
currentDate: this._currentDate,
|
|
2384
2461
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {}
|
|
2385
2462
|
})
|
|
2386
2463
|
}, this._commentRunsByPage.set(e, r));
|
|
@@ -2419,7 +2496,7 @@ var Xt = class e {
|
|
|
2419
2496
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2420
2497
|
let u = await this._commentRunsForPage(s, n);
|
|
2421
2498
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2422
|
-
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) =>
|
|
2499
|
+
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => M(e, u))[0], !c)) return !1;
|
|
2423
2500
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2424
2501
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2425
2502
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2450,7 +2527,7 @@ var Xt = class e {
|
|
|
2450
2527
|
async _collectPageRuns(e) {
|
|
2451
2528
|
return this._doc ? this._doc.collectPageRuns(e, {
|
|
2452
2529
|
width: this._pageWidthPx(e),
|
|
2453
|
-
currentDate: this.
|
|
2530
|
+
currentDate: this._currentDate,
|
|
2454
2531
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {}
|
|
2455
2532
|
}) : [];
|
|
2456
2533
|
}
|
|
@@ -2595,7 +2672,7 @@ var Xt = class e {
|
|
|
2595
2672
|
}
|
|
2596
2673
|
getSelectionContext(e = {}) {
|
|
2597
2674
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2598
|
-
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ?
|
|
2675
|
+
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? Wt(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 ? L(this._elementContext, e.maxTextCharacters) : null));
|
|
2599
2676
|
}
|
|
2600
2677
|
_emitSelectionContextChange() {
|
|
2601
2678
|
let e = this.getSelectionContext();
|
|
@@ -2653,9 +2730,9 @@ var Xt = class e {
|
|
|
2653
2730
|
xPt: s / o.width * u.widthPt,
|
|
2654
2731
|
yPt: c / o.height * u.heightPt
|
|
2655
2732
|
}, {
|
|
2656
|
-
currentDate: this.
|
|
2733
|
+
currentDate: this._currentDate,
|
|
2657
2734
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2658
|
-
maxTextCharacters:
|
|
2735
|
+
maxTextCharacters: N
|
|
2659
2736
|
});
|
|
2660
2737
|
} catch (e) {
|
|
2661
2738
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2673,7 +2750,7 @@ var Xt = class e {
|
|
|
2673
2750
|
};
|
|
2674
2751
|
//#endregion
|
|
2675
2752
|
//#region packages/docx/src/types.ts
|
|
2676
|
-
function
|
|
2753
|
+
function an(e) {
|
|
2677
2754
|
let t = [];
|
|
2678
2755
|
for (let n of e.content) {
|
|
2679
2756
|
if (n.type !== "paragraph") continue;
|
|
@@ -2685,23 +2762,23 @@ function Zt(e) {
|
|
|
2685
2762
|
}
|
|
2686
2763
|
//#endregion
|
|
2687
2764
|
//#region src/docx.ts
|
|
2688
|
-
var
|
|
2765
|
+
var on = /* @__PURE__ */ e({
|
|
2689
2766
|
DocxDocument: () => q,
|
|
2690
|
-
DocxScrollViewer: () =>
|
|
2691
|
-
DocxViewer: () =>
|
|
2692
|
-
OoxmlDecodedImageLimitError: () =>
|
|
2767
|
+
DocxScrollViewer: () => rn,
|
|
2768
|
+
DocxViewer: () => Yt,
|
|
2769
|
+
OoxmlDecodedImageLimitError: () => Je,
|
|
2693
2770
|
OoxmlError: () => o,
|
|
2694
2771
|
OoxmlResourceLimitError: () => n,
|
|
2695
|
-
autoResize: () =>
|
|
2772
|
+
autoResize: () => pe,
|
|
2696
2773
|
buildDocxHighlightLayer: () => X,
|
|
2697
2774
|
buildDocxTextLayer: () => Y,
|
|
2698
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
2699
|
-
noteText: () =>
|
|
2775
|
+
isOoxmlDecodedImageLimitError: () => Ye,
|
|
2776
|
+
noteText: () => an,
|
|
2700
2777
|
openExternalHyperlink: () => s,
|
|
2701
2778
|
readDocxTextSelectionContext: () => Q,
|
|
2702
|
-
resolveCommentAnchorRuns: () =>
|
|
2703
|
-
resolveDocxCommentThreads: () =>
|
|
2704
|
-
resolveRevisionAnchorRuns: () =>
|
|
2779
|
+
resolveCommentAnchorRuns: () => M,
|
|
2780
|
+
resolveDocxCommentThreads: () => $e,
|
|
2781
|
+
resolveRevisionAnchorRuns: () => kt
|
|
2705
2782
|
});
|
|
2706
2783
|
//#endregion
|
|
2707
|
-
export { Q as a, q as c,
|
|
2784
|
+
export { Q as a, q as c, Yt as i, kt as l, an as n, X as o, rn as r, Y as s, on as t };
|