@betteroffice/docx 0.4.1 → 0.4.3
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/dist/{chunk-2HLVVQIL.mjs → chunk-3RPZ44TT.mjs} +1 -1
- package/dist/chunk-5Z22FORG.mjs +1 -0
- package/dist/chunk-7ZV6P6NZ.mjs +57 -0
- package/dist/{chunk-2QHGQA3V.mjs → chunk-AXFMDV66.mjs} +1 -1
- package/dist/{chunk-YLFKV2NT.mjs → chunk-EBYC3CX7.mjs} +1 -1
- package/dist/chunk-FK7X7557.mjs +1 -0
- package/dist/{chunk-3CYO46ML.mjs → chunk-GKWXOZZH.mjs} +1 -1
- package/dist/chunk-HGKSOBXK.mjs +1 -0
- package/dist/{chunk-DKWD4P4J.mjs → chunk-LIOWZSE7.mjs} +1 -1
- package/dist/chunk-ML6E23W2.mjs +1 -0
- package/dist/{chunk-NVN26RHH.mjs → chunk-MLEMGJP7.mjs} +1 -1
- package/dist/chunk-QBMNRD5V.mjs +2 -0
- package/dist/chunk-SHVHVJUB.mjs +1 -0
- package/dist/chunk-UBUTIWXN.mjs +1 -0
- package/dist/{chunk-7DDF4RHB.mjs → chunk-VH7P4734.mjs} +1 -1
- package/dist/collaboration/index.d.mts +5 -5
- package/dist/compareDocx-URPCPAQT.mjs +1 -0
- package/dist/{computeLayout-4MNWHE2T.mjs → computeLayout-ZTO6TBWX.mjs} +1 -1
- package/dist/{content-BzoC6bSz.d.mts → content-DSb-6a9T.d.mts} +5 -5
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-DnHmHUPY.d.mts → displayListQueries-BVBDVXoP.d.mts} +2 -2
- package/dist/docx/index.d.mts +1 -1
- package/dist/docx/index.mjs +2 -2
- package/dist/editor/index.d.mts +10 -6
- package/dist/editor/index.mjs +1 -1
- package/dist/{frameDelta-ByU7HBuB.d.mts → frameDelta-CLeO7K5z.d.mts} +5 -2
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/{index-yOtBET85.d.mts → index-DzZVJC8-.d.mts} +230 -86
- package/dist/layout/index.d.mts +2 -2
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +3 -3
- package/dist/layout/render/index.d.mts +9 -9
- package/dist/layout/render/index.mjs +1 -1
- package/dist/{parseWasm-NLAG22EU.mjs → parseWasm-BESKFFA3.mjs} +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +5 -5
- package/dist/plugin-api/index.d.mts +1 -1
- package/dist/plugin-api/resolveItemPositions.d.mts +1 -1
- package/dist/{rustDisplayList-DcaA5iok.d.mts → rustDisplayList-B7uPoItK.d.mts} +2 -2
- package/dist/types/content.d.mts +1 -1
- package/dist/types/document.d.mts +2 -2
- package/dist/{types-Buyw6dFd.d.mts → types-Cz7S77Ut.d.mts} +3 -1
- package/dist/utils/comments.d.mts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/{wasm-IBCLSJQU.mjs → wasm-JPDPN2B2.mjs} +1 -1
- package/dist/wasm-KSZTTO3B.mjs +1 -0
- package/dist/wasm-QI7MWC5D.mjs +1 -0
- package/dist/wasm-edit.d.mts +27 -2
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +4 -4
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-3OWET2KZ.mjs +0 -1
- package/dist/chunk-4GEXNR7A.mjs +0 -1
- package/dist/chunk-4QHAMEAS.mjs +0 -1
- package/dist/chunk-6CHGYCFU.mjs +0 -1
- package/dist/chunk-C5BX34CG.mjs +0 -2
- package/dist/chunk-EIPVFGIC.mjs +0 -1
- package/dist/chunk-FMOSOX5V.mjs +0 -57
- package/dist/compareDocx-QX2YF3EF.mjs +0 -1
- package/dist/wasm-6WSIEYWC.mjs +0 -1
- package/dist/wasm-GSI2XMOH.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-
|
|
1
|
+
export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-3RPZ44TT.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-EUUIJVM6.mjs';export{e as createEditSession,b as editWasmModule,g as exportDocxMarkdownJson,f as exportDocxStructuredJson,j as findDocxContentControlsJson,i as listDocxContentControlsJson,a as preloadEditWasm,c as preloadEditWasmFrom,h as renderDocxMarkdownJson,k as renderDocxMarkdownWithPagesJson,d as setEditWasmHeapLimit}from'./chunk-SHVHVJUB.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-HPZFJGGM.mjs';export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-AXFMDV66.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/wasm-edit.d.mts
CHANGED
|
@@ -293,6 +293,10 @@ declare class EditSession {
|
|
|
293
293
|
* has `deletedTable: true`.
|
|
294
294
|
*/
|
|
295
295
|
delete_table(table_json: string): string;
|
|
296
|
+
/**
|
|
297
|
+
* The number of text batches applied directly to the live document.
|
|
298
|
+
*/
|
|
299
|
+
direct_batches_applied(): number;
|
|
296
300
|
/**
|
|
297
301
|
* Region-aware hit test against the resident display list, so no
|
|
298
302
|
* display-list JSON crosses the boundary. `x`/`y` are page-local px.
|
|
@@ -455,6 +459,7 @@ declare class EditSession {
|
|
|
455
459
|
* Returns `{"ok":true,"version"}` or a refusal.
|
|
456
460
|
*/
|
|
457
461
|
format_text_target_json(target_json: string, delta_json: string): string;
|
|
462
|
+
geometry_position_outline_json(root: string): string;
|
|
458
463
|
/**
|
|
459
464
|
* Whether the document has a story with this id.
|
|
460
465
|
*/
|
|
@@ -716,7 +721,10 @@ declare class EditSession {
|
|
|
716
721
|
/**
|
|
717
722
|
* The paragraph IDs a save applies, as the package writer's
|
|
718
723
|
* `paragraphIds` request field: `{"assignments":[{"part","ordinal",
|
|
719
|
-
* "paraId"}],"patchedParts":[{"part","paraIds":[[ordinal,"ID"]]}]}
|
|
724
|
+
* "paraId"}],"patchedParts":[{"part","paraIds":[[ordinal,"ID"]]}]}`,
|
|
725
|
+
* plus `"splicedParts":[{"part","sha256","paragraphs":[[ordinal,"key"]],
|
|
726
|
+
* "changed":[ordinal]}]`, whose session keys the caller resolves to the
|
|
727
|
+
* model paragraphs it marks with their ordinals.
|
|
720
728
|
*/
|
|
721
729
|
paragraph_save_plan(): string;
|
|
722
730
|
/**
|
|
@@ -743,6 +751,7 @@ declare class EditSession {
|
|
|
743
751
|
* when nothing was changed.
|
|
744
752
|
*/
|
|
745
753
|
persist_paragraph_ids(): string;
|
|
754
|
+
proposal_revision_ranges_json(ids_json: string): string;
|
|
746
755
|
/**
|
|
747
756
|
* Versioned paragraph texts:
|
|
748
757
|
* `{"story"?,"paraIds"?,"view":"accepted"|"original"}` ->
|
|
@@ -785,6 +794,10 @@ declare class EditSession {
|
|
|
785
794
|
* receipt and error contract.
|
|
786
795
|
*/
|
|
787
796
|
reject_change(target_json: string): string;
|
|
797
|
+
/**
|
|
798
|
+
* Release display pages; an empty result means the request was superseded.
|
|
799
|
+
*/
|
|
800
|
+
release_display_pages_frame(pages: Uint32Array, expected_frame_epoch: number): Uint8Array;
|
|
788
801
|
/**
|
|
789
802
|
* Replaces `[start, end)` with `text` in one transaction. The inserted
|
|
790
803
|
* text adopts the first replaced unit's formatting; in suggesting mode
|
|
@@ -961,6 +974,10 @@ declare class EditSession {
|
|
|
961
974
|
* position holds no embed.
|
|
962
975
|
*/
|
|
963
976
|
set_content_control_value_at(story: string, para_id: string, offset: number, value_json: string): void;
|
|
977
|
+
/**
|
|
978
|
+
* Apply admitted paragraph-local text batches directly. Off by default.
|
|
979
|
+
*/
|
|
980
|
+
set_direct_batches(enabled: boolean): void;
|
|
964
981
|
/**
|
|
965
982
|
* Keep every previously built page while windowed builds are on.
|
|
966
983
|
*/
|
|
@@ -995,6 +1012,10 @@ declare class EditSession {
|
|
|
995
1012
|
* Errors when that position holds no image.
|
|
996
1013
|
*/
|
|
997
1014
|
set_image_geometry_at(story: string, para_id: string, offset: number, geometry_json: string): void;
|
|
1015
|
+
/**
|
|
1016
|
+
* Let an eligible resident text edit re-lower only its paragraph. Off by default.
|
|
1017
|
+
*/
|
|
1018
|
+
set_local_lowering(enabled: boolean): void;
|
|
998
1019
|
/**
|
|
999
1020
|
* Whether [`EditSession::open_docx`] seeds images as `media:{n}` tokens,
|
|
1000
1021
|
* which only a replica opened from the same package resolves, instead of
|
|
@@ -1225,6 +1246,10 @@ declare class EditSession {
|
|
|
1225
1246
|
|
|
1226
1247
|
/** Load + instantiate the editing-core wasm (browser path). Idempotent. */
|
|
1227
1248
|
declare function preloadEditWasm(input?: WasmAsyncInput): Promise<void>;
|
|
1249
|
+
/** @internal */
|
|
1250
|
+
declare function editWasmModule(): Promise<WebAssembly.Module | null>;
|
|
1251
|
+
/** @internal */
|
|
1252
|
+
declare function preloadEditWasmFrom(source: Promise<WebAssembly.Module | null>): Promise<void>;
|
|
1228
1253
|
/**
|
|
1229
1254
|
* Caps the bytes the editing core in this thread may allocate at once; an
|
|
1230
1255
|
* allocation past the cap fails as if the memory were full. Undefined removes it.
|
|
@@ -1249,4 +1274,4 @@ declare function findDocxContentControlsJson(bytes: Uint8Array, query: string, o
|
|
|
1249
1274
|
/** Markdown rendering of a paged export's JSON, with optional page markers. */
|
|
1250
1275
|
declare function renderDocxMarkdownWithPagesJson(content: string, options: string): string;
|
|
1251
1276
|
|
|
1252
|
-
export { EditSession, createEditSession, exportDocxMarkdownJson, exportDocxStructuredJson, findDocxContentControlsJson, listDocxContentControlsJson, preloadEditWasm, renderDocxMarkdownJson, renderDocxMarkdownWithPagesJson, setEditWasmHeapLimit };
|
|
1277
|
+
export { EditSession, createEditSession, editWasmModule, exportDocxMarkdownJson, exportDocxStructuredJson, findDocxContentControlsJson, listDocxContentControlsJson, preloadEditWasm, preloadEditWasmFrom, renderDocxMarkdownJson, renderDocxMarkdownWithPagesJson, setEditWasmHeapLimit };
|
package/dist/wasm-edit.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{e as createEditSession,b as editWasmModule,g as exportDocxMarkdownJson,f as exportDocxStructuredJson,j as findDocxContentControlsJson,i as listDocxContentControlsJson,a as preloadEditWasm,c as preloadEditWasmFrom,h as renderDocxMarkdownJson,k as renderDocxMarkdownWithPagesJson,d as setEditWasmHeapLimit}from'./chunk-SHVHVJUB.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/wasm-layout.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-
|
|
1
|
+
export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-3RPZ44TT.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/wasm-opc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-
|
|
1
|
+
export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-AXFMDV66.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/wasm-parse.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{h as decodeTiffImage,b as parseDocxS9Wire,c as parseRelationshipsXmlWire,a as preloadParseWasm,d as serializeDocxS10Wire,e as serializeDocxS11Wire,f as serializeDocxS12Wire,g as writeDocxS13Wire}from'./chunk-
|
|
1
|
+
export{h as decodeTiffImage,b as parseDocxS9Wire,c as parseRelationshipsXmlWire,a as preloadParseWasm,d as serializeDocxS10Wire,e as serializeDocxS11Wire,f as serializeDocxS12Wire,g as writeDocxS13Wire}from'./chunk-GKWXOZZH.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/yrs/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import '../formatting-gqLFeJ9X.mjs';
|
|
2
2
|
import '../types/document.mjs';
|
|
3
|
-
export { A as AnchorGeometryTarget, x as AnchorReader, y as AnchorResolutionFailure, z as CreateYrsSessionOptions, D as DocxOccurrence, B as DocxParagraphAnchor, E as DocxParagraphAnchorResult, F as DocxParagraphIdAssignment, G as DocxParagraphIdDiagnostic, H as DocxParagraphIdOrigin, I as DocxParagraphIdRefusal, J as DocxParagraphIdentity, K as DocxParagraphIdentityReceipt, L as DocxParagraphIdentitySnapshot, M as DocxParagraphOrigin, N as DocxParagraphRef, O as DocxParagraphSavePlan, P as DocxPersistedParagraphAnchor, Q as DocxProposalFailure, R as DocxProposalInput, S as DocxProposalRecord, T as DocxProposalRegistryState, U as DocxProposalRequest, V as DocxProposalResult, W as DocxProposalSnapshot, X as DocxProposalState, Z as DocxProposalStateRequest, _ as DocxProposalWithdrawRequest, $ as DocxSavedDocument, a0 as DocxSavedParagraph, a1 as DocxSessionParagraphAnchor, a2 as DocxSessionSave, a3 as DocxSourceParagraphAnchor, a4 as DocxSourceStory, a5 as ProposalDisplayTarget, a6 as ProposalGeometryMirror, a7 as ProposalGeometryReader, a8 as
|
|
3
|
+
export { A as AnchorGeometryTarget, x as AnchorReader, y as AnchorResolutionFailure, z as CreateYrsSessionOptions, D as DocxOccurrence, B as DocxParagraphAnchor, E as DocxParagraphAnchorResult, F as DocxParagraphIdAssignment, G as DocxParagraphIdDiagnostic, H as DocxParagraphIdOrigin, I as DocxParagraphIdRefusal, J as DocxParagraphIdentity, K as DocxParagraphIdentityReceipt, L as DocxParagraphIdentitySnapshot, M as DocxParagraphOrigin, N as DocxParagraphRef, O as DocxParagraphSavePlan, P as DocxPersistedParagraphAnchor, Q as DocxProposalFailure, R as DocxProposalInput, S as DocxProposalRecord, T as DocxProposalRegistryState, U as DocxProposalRequest, V as DocxProposalResult, W as DocxProposalSnapshot, X as DocxProposalState, Z as DocxProposalStateRequest, _ as DocxProposalWithdrawRequest, $ as DocxSavedDocument, a0 as DocxSavedParagraph, a1 as DocxSessionParagraphAnchor, a2 as DocxSessionSave, a3 as DocxSourceParagraphAnchor, a4 as DocxSourceStory, a5 as ProposalDisplayTarget, a6 as ProposalGeometryMirror, a7 as ProposalGeometryReader, a8 as ProposalGeometryRevision, a9 as ProposalGeometryTarget, aa as RawAnchorRange, ab as ResidentCaretPaintStyle, ac as ResidentEngineOffscreenPage, ad as ResidentEngineWorkerApplyResult, ae as ResidentEngineWorkerClient, af as ResidentEngineWorkerFrame, ag as ResidentEngineWorkerOpened, ah as ResidentProposalReply, ai as ResidentWorkerFailureError, aj as ResidentWorkerOutOfMemoryError, ak as YrsAuthor, al as YrsCellBorder, am as YrsCellBorders, an as YrsCellLoc, ao as YrsChangeTarget, ap as YrsCommentInfo, aq as YrsCommentReceipt, ar as YrsContentControlValue, as as YrsDocxHost, at as YrsEngineApplyProfile, au as YrsHyperlinkAttrs, av as YrsImageGeometry, aw as YrsInlineFormatDelta, ax as YrsInputParagraphSeed, ay as YrsInputParagraphSpan, az as YrsInputPositionMap, u as YrsLoc, aA as YrsLocProjection, aB as YrsMediaSource, aC as YrsNumberingProperties, aD as YrsOpeningOptions, aE as YrsParaOffset, aF as YrsParagraph, aG as YrsParagraphAttrs, aH as YrsParagraphLength, aI as YrsParagraphReceipt, aJ as YrsParagraphSeed, aK as YrsParagraphSpan, aL as YrsParagraphTabStop, aM as YrsPointerProjectionTarget, aN as YrsPositionOutline, aO as YrsPositionProjection, aP as YrsProjectedCell, aQ as YrsProjectedNode, aR as YrsProjectedTable, aS as YrsRawOp, aT as YrsRegionLayoutProgress, a as YrsRenderEnv, aU as YrsReplaceReceipt, aV as YrsResidentCaretRect, aW as YrsResidentCaretSnapshot, aX as YrsResidentFontRegistration, aY as YrsResidentWorkerSnapshot, aZ as YrsResidentWorkerSyncOptions, a_ as YrsResolveReceipt, a$ as YrsResolvedCommentAnchor, w as YrsRevisionInfo, b0 as YrsRevisionReceipt, b1 as YrsRunMark, j as YrsSelection, b2 as YrsSelectionContext, b3 as YrsSelectionText, Y as YrsSession, b4 as YrsSplitReceipt, b5 as YrsStickyPosition, b6 as YrsStoryRange, b7 as YrsStorySeed, v as YrsStorySegment, b8 as YrsStorySegmentSource, b9 as YrsTableLoc, ba as YrsTableRange, bb as YrsTableReceipt, bc as YrsTargetEditResult, bd as YrsTextColor, be as YrsTextMatch, bf as YrsTextSearchOptions, bg as YrsTriState, bh as YrsUndoCaptureMode, bi as YrsWatermark, bj as YrsWorkerDocumentMirror, bk as anchorFailure, bl as canUseResidentEngineWorker, bm as captureSessionSave, bn as compareYrsLocs, bo as computeProposalGeometryMirror, bp as createYrsInputPositionMap, bq as createYrsLocProjectionFromOutline, br as createYrsPositionProjection, bs as createYrsSession, bt as decodeDocxHostJson, bu as displayPositionToYrsLoc, bv as documentToYrs, bw as editorSaveKeys, bx as hiddenRanges, by as isBodyStory, bz as ownProjectedParagraphs, bA as preloadDocxEngine, bB as preloadResidentEngineWorker, bC as prepareDocxBytes, bD as preparedDocxDigest, bE as projectYrsDisplayPosition, bF as proposalRevisionPreview, bG as proposalSetIdentity, bH as residentCaretDeviceRect, bI as residentCaretSnapshotForFrame, bJ as resolveAnchorTarget, bK as resolveMirroredNavigationTarget, bL as resolveNavigationTarget, bM as retainPreloadedResidentEngineWorker, bN as sameYrsSelection, bO as saveYrsDocx, bP as sessionSourcePackage, bQ as takePreloadedResidentEngineWorker, bR as textRangeToRaw, bS as writeSessionSave, bT as yrsLocToDisplayPosition, bU as yrsLocToProjectedDisplayPosition, bV as yrsToDocument } from '../index-DzZVJC8-.mjs';
|
|
4
4
|
export { o as DocxAnchor, p as DocxAnchorScope, ad as DocxAtomKind, q as DocxCachedResult, r as DocxCommentMetadata, s as DocxContentControl, t as DocxContentControlDiagnostic, l as DocxContentControlQuery, k as DocxContentControlReadFailure, u as DocxContentControlSelector, v as DocxContentControlValue, m as DocxContentControlsOptions, w as DocxContentControlsResult, n as DocxContentControlsSnapshot, x as DocxControlMetadata, a1 as DocxEditFailure, a2 as DocxEditFailureCode, ae as DocxEditFailureReason, af as DocxEditGuard, ag as DocxEditHistory, ah as DocxEditOperation, ai as DocxEditPreview, aj as DocxEditReceipt, ac as DocxEditRefusal, a8 as DocxEditRequest, aa as DocxEditResult, ak as DocxEditSource, al as DocxEditStep, a0 as DocxEditSuggestion, am as DocxEditTarget, y as DocxExportBlock, z as DocxExportCell, A as DocxExportDiagnostic, B as DocxExportDiagnosticCode, D as DocxExportFailure, C as DocxExportFailureCode, E as DocxExportInline, a as DocxExportOptions, F as DocxExportPage, G as DocxExportRefusal, H as DocxExportResult, I as DocxExportStory, J as DocxExportTable, a6 as DocxFindTextRequest, a7 as DocxFindTextResult, K as DocxFormattingMark, L as DocxFragmentGeometry, M as DocxHeadingInfo, N as DocxHeadlessFont, e as DocxHeadlessLayoutOptions, O as DocxInlineRevision, i as DocxLayoutMap, P as DocxLayoutProvenance, Q as DocxListInfo, b as DocxMarkdownContent, h as DocxMarkdownOptions, R as DocxPageDiagnostic, d as DocxPageExportOptions, S as DocxPageFragment, T as DocxPageMapContent, j as DocxPageMarkdownOptions, f as DocxPagedStructuredContent, U as DocxParagraphData, V as DocxParagraphHeading, an as DocxParagraphInput, ao as DocxParagraphTarget, ap as DocxParagraphText, a4 as DocxReadParagraphsRequest, a5 as DocxReadParagraphsResult, aq as DocxResolvedControl, W as DocxRevisionView, ar as DocxSearchScope, as as DocxSetContentControlTextStep, g as DocxSnapshotLayoutMap, X as DocxSnapshotLayoutProvenance, Y as DocxStoryKind, Z as DocxStoryOccurrence, _ as DocxStorySelection, c as DocxStructuredContent, at as DocxTextAtom, au as DocxTextMatch, av as DocxTextPosition, a3 as DocxTextRange, ab as DocxTextTarget, aw as DocxTextView, $ as DocxUnlocatedReason, a9 as DocxValidationResult, ax as EditSuccess, ay as OperationFailure, az as OperationRefusal, aA as ValidationSuccess } from '../pagedExport-BmSlEhoP.mjs';
|
|
5
5
|
export { b as WASM32_MEMORY_LIMIT_BYTES, c as WasmHeapStats, a as WasmModuleMemory, w as wasmModuleMemories } from '../loadWasmAsset-Cr95TImt.mjs';
|
|
6
|
-
import '../content-
|
|
6
|
+
import '../content-DSb-6a9T.mjs';
|
|
7
7
|
import '../docx/wrapTypes.mjs';
|
|
8
8
|
import '../styles-AryxLAhx.mjs';
|
|
9
|
-
import '../frameDelta-
|
|
10
|
-
import '../rezip-Bxiq4Z_R.mjs';
|
|
9
|
+
import '../frameDelta-CLeO7K5z.mjs';
|
|
11
10
|
import '../plugin-api/index.mjs';
|
|
11
|
+
import '../rezip-Bxiq4Z_R.mjs';
|
package/dist/yrs/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {g,h,d as d$2,b as b$2,e,f}from'../chunk-4QHAMEAS.mjs';export{a as sessionSourcePackage,h as yrsToDocument}from'../chunk-4QHAMEAS.mjs';import {d as d$3,a}from'../chunk-3OWET2KZ.mjs';export{m as YrsPositionProjection,o as anchorFailure,h as compareYrsLocs,u as computeProposalGeometryMirror,e as createYrsInputPositionMap,k as createYrsPositionProjection,g as displayPositionToYrsLoc,r as hiddenRanges,p as isBodyStory,l as projectYrsDisplayPosition,c as proposalRevisionPreview,t as proposalSetIdentity,i as residentCaretDeviceRect,j as residentCaretSnapshotForFrame,s as resolveAnchorTarget,v as resolveNavigationTarget,q as textRangeToRaw,f as yrsLocToDisplayPosition,n as yrsLocToProjectedDisplayPosition}from'../chunk-3OWET2KZ.mjs';import'../chunk-DKWD4P4J.mjs';import {d as d$1}from'../chunk-C5BX34CG.mjs';import {b as b$6}from'../chunk-OBQGPMPQ.mjs';import {d,a as a$1,b as b$4}from'../chunk-47Q2FMFF.mjs';import {b as b$3,p}from'../chunk-LTVVQMHB.mjs';import {b as b$5}from'../chunk-CTBUQRYQ.mjs';import {c,b as b$1}from'../chunk-YLFKV2NT.mjs';import'../chunk-LT2GCWZ3.mjs';import'../chunk-HPZFJGGM.mjs';import'../chunk-2QHGQA3V.mjs';import'../chunk-3CYO46ML.mjs';export{a as WASM32_MEMORY_LIMIT_BYTES,b as wasmModuleMemories}from'../chunk-6CHGYCFU.mjs';import {b}from'../chunk-TTRUPDAB.mjs';function ke(e,r){let n=c=>{let{content:u,...g}=c;return g},o=c=>[...c??[]].map(([u,g])=>[u,n(g)]),i=c=>(c??[]).map(u=>{let{verbatimXml:g,sourceOrdinal:b,...R}=n(u);return R}),{package:s}=e,a={finalSectionProperties:s.document.finalSectionProperties,sections:s.document.sections?.map(n),headers:o(s.headers),footers:o(s.footers),footnotes:i(s.footnotes),endnotes:i(s.endnotes),relationships:[...s.relationships??[]]},d=c=>JSON.stringify(c,(u,g)=>g instanceof Map?[...g]:g),p=r??s.document.comments??[];return {metadata:d(a),comments:d(p),commentIds:p.map(c=>c.id)}}var Nt=new Set(["bootstrap","sync","buildFrame","applyInput","applyDelete"]),xe=6e4;function Jt(){return new Worker(new URL("./residentEngineWorker.mjs",import.meta.url),{type:"module",name:"openooxml-resident-engine"})}var le=class{constructor(r=Jt()){b(this,"worker",r);b(this,"pending",new Map);b(this,"watchdog",null);b(this,"nextId",1);b(this,"terminalError",null);b(this,"ready",false);b(this,"revision",0);b(this,"remoteVector",null);b(this,"appliedFontsRevision",null);b(this,"bootstrapped",false);b(this,"openedHeapLimit",null);b(this,"bootstraps",0);b(this,"lastSnapshotId",0);b(this,"keepSurfaces",false);b(this,"lastMemory",null);b(this,"answeredFrameEpoch",0);b(this,"retainBuiltPages",false);this.worker.onmessage=n=>{let o=n.data;if(o.memory&&(this.lastMemory=o.memory),o.ok&&o.caret&&(this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,o.caret.frameEpoch)),o.ok&&o.id>=this.lastSnapshotId){let s=o.proposal?.stateVector??o.stateVector;s&&(this.remoteVector=new Uint8Array(s));}if(!o.ok&&o.terminal){this.fail(o.outOfMemory?new Q(o.error,o.memory??[]):new V(o.error));return}this.pending.size>0&&this.armWatchdog();let i=this.pending.get(o.id);i&&(this.pending.delete(o.id),this.pending.size===0&&this.disarmWatchdog(),o.ok?i.resolve(o):i.reject(Bt(o.error,o.residentUnavailable)));},this.worker.onerror=n=>{this.fail(new I(`Resident engine worker failed: ${n.message}`));},this.worker.onmessageerror=()=>{this.fail(new I("Resident engine worker returned an unreadable message"));};}isReady(){return this.ready}hasFailed(){return this.terminalError!==null}memory(){return this.lastMemory}layoutRevision(){return this.revision}answeredFrame(){return this.answeredFrameEpoch}setRetainBuiltPages(r){this.retainBuiltPages=r;}frameRequestPending(){for(let{type:r}of this.pending.values())if(Nt.has(r))return true;return false}remoteStateVector(){return this.remoteVector}syncedFontsRevision(){return this.appliedFontsRevision}bootstrapSent(){return this.bootstrapped}rebootstrap(){this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null,this.lastSnapshotId=0,this.revision=0,this.keepSurfaces=true,this.openedHeapLimit=null;}async open(r,n={}){if(this.openedHeapLimit||this.bootstrapped)throw new I("Resident engine worker already holds a document");let o={bytes:n.heapLimitBytes};this.openedHeapLimit=o;let i;try{let s=new Uint8Array(r);i=await this.request({type:"open",bytes:s.buffer,...n.digest!==void 0?{digest:n.digest}:{},...n.generation!==void 0?{generation:n.generation}:{},...n.heapLimitBytes!==void 0?{heapLimitBytes:n.heapLimitBytes}:{}},[s.buffer]);}catch(s){throw this.openedHeapLimit===o&&(this.openedHeapLimit=null),s}if(i.hostJson===void 0||!i.stateVector)throw new I("Resident engine worker omitted the opened document");return {hostJson:i.hostJson,stateVector:new Uint8Array(i.stateVector)}}async fontRequirements(r){let n=await this.request({type:"fontRequirements",layoutInput:r});if(n.requirementsJson===void 0)throw new I("Resident engine worker omitted the font requirements");return n.requirementsJson}async proposal(r){if(!this.bootstrapped)throw new I("Resident engine worker has not laid out its document");let n=await this.request({type:"proposal",operation:r});if(!n.proposal)throw new I("Resident engine worker omitted the proposal result");return {...n.proposal,updates:n.proposal.updates.map(o=>new Uint8Array(o)),stateVector:new Uint8Array(n.proposal.stateVector)}}async documentRead(r){let n=await this.request({type:"documentRead",read:r});if(!n.read)throw new I("Resident engine worker omitted the document read");return n.read}async handOver(){let r=await this.request({type:"encodeState"});if(!r.state||r.version===void 0||!r.proposals)throw new I("Resident engine worker omitted its document handoff");return {state:new Uint8Array(r.state),version:r.version,proposals:r.proposals}}async encodeState(){let r=await this.request({type:"encodeState"});if(!r.state)throw new I("Resident engine worker omitted its state");return new Uint8Array(r.state)}async revisionCount(){let r=await this.request({type:"revisionCount"});if(typeof r.revisionCount!="number"||!Number.isInteger(r.revisionCount)||r.revisionCount<0)throw new I("Resident engine worker omitted a valid revision count");return r.revisionCount}async warm(){await this.request({type:"warm"});}async bootstrap(r,n,o={}){if(o.opened&&!this.openedHeapLimit)throw new I("Resident engine worker has no opened document");if(o.opened&&o.heapLimitBytes!==void 0&&o.heapLimitBytes!==this.openedHeapLimit?.bytes)throw new I("Resident engine worker opened its document under another heap limit");let i=r.fontsRevision;this.bootstrapped=true;let s=this.keepSurfaces;this.keepSurfaces=false;let a=++this.bootstraps,d=this.request({type:"bootstrap",snapshot:r,extras:n,expectedFrameEpoch:o.frameEpoch??0,...o.layoutExtras!==void 0?{layoutExtras:o.layoutExtras}:{},...o.displayWindow?{displayWindow:o.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{},...o.provisionalPages!==void 0?{provisionalPages:o.provisionalPages}:{},...s?{keepSurfaces:true}:{},...o.opened?{opened:true}:{},...o.heapLimitBytes!==void 0?{heapLimitBytes:o.heapLimitBytes}:{}},tt(r));this.recordSent(o.stateVector,i);let p;try{p=await d;}catch(u){throw o.opened&&!this.openedHeapLimit&&a===this.bootstraps&&(this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null),u}let c=q(p);return this.recordSync(p,i),this.ready=true,this.revision=c.layoutRevision,c}async sync(r,n,o,i=false,s={}){let a=r.fontsRevision,d=this.request({type:"sync",snapshot:r,extras:n,expectedFrameEpoch:o,paintCaret:i,...s.layoutExtras!==void 0?{layoutExtras:s.layoutExtras}:{},...s.displayWindow?{displayWindow:s.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}},tt(r));this.recordSent(s.stateVector,a);let p=await d,c=q(p);return this.recordSync(p,a),this.ready=true,this.revision=c.layoutRevision,c}async completeLayout(r,n=false,o){let i=await this.request({type:"completeLayout",expectedFrameEpoch:r,paintCaret:n,...o?{sliceBlocks:o}:{}});return i.frame?q(i):null}async buildFrame(r,n,o=false,i){return q(await this.request({type:"buildFrame",extras:r,expectedFrameEpoch:n,paintCaret:o,...i?{displayWindow:i,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}}))}async buildPages(r,n,o=false){return q(await this.request({type:"buildPages",pages:r,expectedFrameEpoch:n,paintCaret:o}))}async applyInput(r,n,o,i=false,s=false,a){if(!this.ready)return {applied:false};try{return {applied:!0,...q(await this.request({type:"applyInput",text:r,selection:n,expectedFrameEpoch:o,profile:i,paintCaret:s,...a?{displayWindow:a,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(d){if(et(d))return {applied:false};throw d}}async applyDelete(r,n,o,i=false,s=false,a=1,d){if(!this.ready)return {applied:false};try{return {applied:!0,...q(await this.request({type:"applyDelete",direction:r,count:a,selection:n,expectedFrameEpoch:o,profile:i,paintCaret:s,...d?{displayWindow:d,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(p){if(et(p))return {applied:false};throw p}}eraseCaret(){if(this.terminalError)return;let n={id:this.nextId++,type:"eraseCaret"};this.worker.postMessage(n);}invalidate(r,n){if(this.terminalError)return;this.ready=false;let o=r.slice(),s={id:this.nextId++,type:"applyUpdate",update:o,selection:n};this.worker.postMessage(s,[o.buffer]);}async attachCanvases(r,n,o,i,s){let a=r.map(d=>d.canvas);await this.request({type:"attachCanvases",pages:r,activePageIds:n,devicePixelRatio:o,zoom:i,caretStyle:s},a);}destroy(){if(this.terminalError)return;let n={id:this.nextId++,type:"destroy"};this.worker.postMessage(n),this.fail(new I("Resident engine worker was destroyed"));}request(r,n=[]){if(this.terminalError)return Promise.reject(this.terminalError);let o=this.nextId++;return new Promise((i,s)=>{this.pending.size===0&&this.armWatchdog(),this.pending.set(o,{type:r.type,resolve:i,reject:s}),this.worker.postMessage({...r,id:o},n);})}recordSent(r,n){this.terminalError||(this.lastSnapshotId=this.nextId-1,r&&(this.remoteVector=r.slice()),this.appliedFontsRevision=n);}armWatchdog(){this.disarmWatchdog(),this.watchdog=setTimeout(()=>{this.watchdog=null;let r=this.pending.values().next().value?.type??"a request";this.fail(new I(`Resident engine worker did not answer ${r} within ${xe}ms`));},xe);}disarmWatchdog(){this.watchdog!==null&&(clearTimeout(this.watchdog),this.watchdog=null);}recordSync(r,n){r.id>=this.lastSnapshotId&&(this.appliedFontsRevision=n);}fail(r){this.terminalError=r,this.ready=false,this.disarmWatchdog(),this.worker.terminate();for(let n of this.pending.values())n.reject(r);this.pending.clear();}},V=class extends Error{},I=class extends Error{},Q=class extends V{constructor(n,o){super(n);b(this,"memory",o);}};function et(e){return e instanceof V&&!(e instanceof Q)}function Bt(e,r=false){return r?new V(e):new Error(e)}function tt(e){return [e.state.buffer,...e.fonts.flatMap(r=>r instanceof Uint8Array?[r.buffer]:[])]}function q(e){if(!e.frame)throw new I("Resident engine worker response omitted its FrameDelta");if(!e.caret)throw new I("Resident engine worker response omitted its caret snapshot");if(e.selection===void 0)throw new I("Resident engine worker response omitted its selection");return {frame:new Uint8Array(e.frame),updates:(e.updates??[]).map(r=>new Uint8Array(r)),engineMs:e.engineMs??0,workerTotalMs:e.workerTotalMs??0,engineProfile:e.engineProfile,caret:e.caret,selection:e.selection,caretPainted:e.caretPainted??false,replayMs:e.replayMs??0,replayedPages:e.replayedPages??0,layoutRevision:e.layoutRevision??0,deletedUnits:e.deletedUnits??0,...e.layoutJson!==void 0?{layoutJson:e.layoutJson}:{},...e.layoutProvisional?{layoutProvisional:true}:{}}}function Pe(){return typeof Worker<"u"}var O=null;function de(e){e.idleTimer!==null&&clearTimeout(e.idleTimer),e.releaseTimer!==null&&clearTimeout(e.releaseTimer),e.idleTimer=null,e.releaseTimer=null;}function X(e){O===e&&(O=null,de(e),e.client.destroy());}function we(){if(!Pe())return Promise.resolve();if(O&&(O.factory!==Worker||O.client.hasFailed())&&X(O),!O){let r={client:new le,factory:Worker,ready:Promise.resolve(),owners:0,idleTimer:null,releaseTimer:null};O=r,r.ready=r.client.warm().catch(n=>{throw X(r),n});}let e=O;return de(e),e.owners===0&&(e.idleTimer=setTimeout(()=>X(e),xe)),e.ready}function Wt(){let e=O;if(!e)return ()=>{};de(e),e.owners+=1;let r=false;return ()=>{r||(r=true,e.owners-=1,e.owners===0&&O===e&&(e.releaseTimer=setTimeout(()=>X(e),0)));}}function Lt(){let e=O;return e?!Pe()||e.factory!==Worker||e.client.hasFailed()?(X(e),null):(O=null,de(e),e.client):null}async function Ut(){let e=[import('../wasm-6WSIEYWC.mjs').then(n=>n.preloadEditWasm()),import('../wasm-GSI2XMOH.mjs').then(n=>n.preloadOpcWasm()),import('../parseWasm-NLAG22EU.mjs').then(n=>n.preloadParseWasm()),import('../wasm-IBCLSJQU.mjs').then(n=>n.preloadLayoutWasm())],r;try{r=we();}catch(n){r=Promise.reject(n);}await Promise.all([...e,r]);}function ve(e,r,n,o,i,s){let a=r?.pPr;if(!r?.tblStylePr?.some(C=>C.pPr))return a;let d=e.formatting?.look??r.tblPr?.look,p=(C,E)=>d?.[C]??(Number.parseInt(d?.value??(d?"0":"04A0"),16)&E)!==0,c=p("firstRow",32),u=p("lastRow",64),g=p("firstColumn",128),b=p("lastColumn",256),R=e.rows[n].formatting?.gridBefore??0;o+=R,i+=R;let S=!!c&&n===0,f=!!u&&n===e.rows.length-1,k=!!g&&o===0,h=!!b&&i===s,P=e.formatting?.styleRowBandSize??r.tblPr?.styleRowBandSize??1,_=e.formatting?.styleColBandSize??r.tblPr?.styleColBandSize??1,Y=[];!p("noHBand",512)&&!S&&!f&&P>0&&Y.push(Math.floor((n-+!!c)/P)%2===0?"band1Horz":"band2Horz"),!p("noVBand",1024)&&!k&&!h&&_>0&&Y.push(Math.floor((o-+!!g)/_)%2===0?"band1Vert":"band2Vert");for(let[C,E]of [["firstCol",k],["lastCol",h],["firstRow",S],["lastRow",f],["nwCell",S&&k],["neCell",S&&h],["swCell",f&&k],["seCell",f&&h]])E&&Y.push(C);for(let C of Y)a=b$4(a,r.tblStylePr.find(E=>E.type===C)?.pPr);return a}function rt(e){return Math.max(e.columnWidths?.length??0,...e.rows.map(r=>r.cells.reduce((n,o)=>n+(o.formatting?.gridSpan??1),(r.formatting?.gridBefore??0)+(r.formatting?.gridAfter??0))))}function N(e){if(Array.isArray(e))return e.map(N);if(e!==null&&typeof e=="object"){let r={};for(let[n,o]of Object.entries(e))o!=null&&(r[n]=N(o));return r}return e}var jt={styleId:"pStyle",_sectionProperties:"sectPr"},qt=new Set(["paraId","textId","renderedPageBreakBefore","numPrFromStyle"]);function nt(e){let r={};for(let[n,o]of Object.entries(e))qt.has(n)||o===null||o===void 0||(r[jt[n]??n]=N(o));return r}var Ht=new Set(["columnWidths"]);function ue(e,r=new Set){let n={};for(let[o,i]of Object.entries(e))r.has(o)||i===null||i===void 0||(n[o]=N(i));return n}function ot(e){return ue(e,Ht)}function st(e){let r=e.columnWidths;return Array.isArray(r)?r.map(N):[]}function it(e){return ue(e)}function at(e,r){let n=ue(e);return r&&(n.header=true),n}function Ce(e,r,n,o){return `${e}:t${r}:r${n}c${o}`}function lt(e,r){return `${e}:sdt${r}`}function dt(e){return ue(e)}function pe(e){return `hf:${e}`}function ut(e){return `fn:${e}`}function pt(e){return `en:${e}`}function zt(e){let r=e.package.settings?.compatibilityFlags?.compatibilityMode;return typeof r=="number"&&Number.isFinite(r)?Math.trunc(r):12}var Vt=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function K(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(K).join(",")}]`;if(typeof e=="object"){let r=e;return `{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${K(r[n])}`).join(",")}}`}return JSON.stringify(e)}function $t(e,r){if(!e||!r)return e;let n=r.resolveRunStyle(e.styleId);return n?a$1(n,e):e}function gt(e){if(!e)return [];let r=[],n=(a,d={})=>r.push({name:a,attrs:d});e.bold&&n("bold"),e.italic&&n("italic"),e.underline&&e.underline.style!=="none"&&n("underline",{style:e.underline.style,color:e.underline.color??null}),(e.strike||e.doubleStrike)&&n("strike",{double:e.doubleStrike||false}),e.color&&!e.color.auto&&n("textColor",{rgb:e.color.rgb??null,themeColor:e.color.themeColor??null,themeTint:e.color.themeTint??null,themeShade:e.color.themeShade??null});let o=e.shading?.fill,i=(!e.shading?.pattern||e.shading.pattern==="clear")&&o?.rgb&&!o.auto?p(o.rgb):void 0,s=e.highlight&&e.highlight!=="none"?e.highlight:i;return s&&n("highlight",{color:s}),(e.fontSize!=null||e.fontSizeCs!=null)&&n("fontSize",{size:e.fontSize??null,sizeCs:e.fontSizeCs??null}),e.fontFamily&&n("fontFamily",{ascii:e.fontFamily.ascii??null,hAnsi:e.fontFamily.hAnsi??null,eastAsia:e.fontFamily.eastAsia??null,cs:e.fontFamily.cs??null,asciiTheme:e.fontFamily.asciiTheme??null,hAnsiTheme:e.fontFamily.hAnsiTheme??null,eastAsiaTheme:e.fontFamily.eastAsiaTheme??null,csTheme:e.fontFamily.csTheme??null}),e.vertAlign==="superscript"?n("superscript"):e.vertAlign==="subscript"&&n("subscript"),e.allCaps&&n("allCaps"),e.smallCaps&&n("smallCaps"),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&n("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null}),e.emboss&&n("emboss"),e.imprint&&n("imprint"),e.shadow&&n("textShadow"),e.emphasisMark&&e.emphasisMark!=="none"&&n("emphasisMark",{type:e.emphasisMark}),e.outline&&n("textOutline"),e.hidden&&n("hidden"),e.rtl&&n("rtl"),e.snapToGrid===false&&r.push({name:"snapToGrid",attrs:{}}),e.effect&&e.effect!=="none"&&n("textEffect",{effect:e.effect}),e.modernEffects&&n("modernTextEffects",{effects:e.modernEffects}),e.styleId&&n("runStyle",{styleId:e.styleId}),r}function yt(e){let r={};for(let n of e)n.name==="comment"||n.name==="footnoteRef"||(Vt.has(n.name)?r[n.name]=true:n.name==="snapToGrid"?r.snapToGrid=false:n.name==="highlight"?r.highlight=n.attrs.color:n.name==="insertion"||n.name==="deletion"?r[n.name==="insertion"?"ins":"del"]=N({id:n.attrs.revisionId,author:n.attrs.author,date:n.attrs.date}):r[n.name]=N(n.attrs));return r}function Kt(e){return e.filter(r=>r.name!=="hyperlink"&&r.name!=="comment").map(r=>`${r.name}:${JSON.stringify(r.attrs)}`).sort().join("|")}function Gt(e,r){return [...e.filter(n=>n.name!==r.name),r]}function Z(e,r){return {kind:"text",text:e,attrs:yt(r),pmSize:e.length,marks:[...r]}}function T(e,r,n=[],o=1){return {kind:"embed",embedKind:e,payload:r,attrs:yt(n),pmSize:o,marks:[...n]}}function ht(e,r,n){let o=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=gt(a$1(a$1(r,o),e.formatting)),s=e.formatting?.styleId,a=s?n?.getStyle(s)?.name:void 0;if([s,a].some(d=>/^(?:Followed)?Hyperlink$/i.test(d??""))){for(let[d,p]of [["color","textColor"],["underline","underline"]])if(e.formatting?.[d]===void 0&&o?.[d]!==void 0){let c=i.find(u=>u.name===p);c&&(c.attrs.inheritedHyperlink=true);}}return i}function Xt(e){let r=e.size?.width?b$5(e.size.width):void 0,n=e.size?.height?b$5(e.size.height):void 0,o=e.wrap.type,i=e.wrap.wrapText,s=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?i==="left"?a="right":i==="right"?a="left":s==="left"||s==="right"?a=s:a="none":a="none";let d=o==="inline"?"inline":o==="topAndBottom"?"block":b$6(o)||a&&a!=="none"?"float":"block",p=[];e.transform?.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform?.flipH&&p.push("scaleX(-1)"),e.transform?.flipV&&p.push("scaleY(-1)");let c,u,g;if(e.outline?.width){c=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`);let b={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};g=e.outline.style&&b[e.outline.style]||"solid";}return N({src:e.src||"",alt:e.alt??null,title:e.title??null,width:r??null,height:n??null,rId:e.rId??null,wrapType:o,displayMode:d,cssFloat:a??null,transform:p.length>0?p.join(" "):null,distTop:e.wrap.distT!=null?b$5(e.wrap.distT):null,distBottom:e.wrap.distB!=null?b$5(e.wrap.distB):null,distLeft:e.wrap.distL!=null?b$5(e.wrap.distL):null,distRight:e.wrap.distR!=null?b$5(e.wrap.distR):null,position:e.position?{relativeHeight:e.position.relativeHeight,behindDoc:e.position.behindDoc,horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0}:null,borderWidth:c??null,borderColor:u??null,borderStyle:g??null,wrapText:i??null,hlinkHref:e.hlinkHref??null,cropTop:e.crop?.top??null,cropRight:e.crop?.right??null,cropBottom:e.crop?.bottom??null,cropLeft:e.crop?.left??null,shapeType:e.shapeType??null,opacity:e.opacity??null,effectExtentTop:e.padding?.top!=null?b$5(e.padding.top):null,effectExtentBottom:e.padding?.bottom!=null?b$5(e.padding.bottom):null,effectExtentLeft:e.padding?.left!=null?b$5(e.padding.left):null,effectExtentRight:e.padding?.right!=null?b$5(e.padding.right):null,layoutInCell:e.layoutInCell??null,allowOverlap:e.allowOverlap??null})}function Qt(e){return {shapeJson:JSON.stringify(e)}}function Zt(e){return N({chartJson:JSON.stringify(e),chartType:e.chartType??null,title:e.title??null,width:e.size?.width?b$5(e.size.width):320,height:e.size?.height?b$5(e.size.height):220,rId:e.rId??null,path:e.path??null})}function te(e,r){let n="",o,i=e.type==="simpleField"?e.content:e.fieldResult;for(let d of i)if(d.type==="run"){for(let p of d.content)p.type==="text"&&(n+=p.text);!o&&d.formatting&&(o=d.formatting);}let s=o??(e.type==="complexField"?e.formatting:void 0),a=e.fieldTree?.displayMode??"result";return {payload:{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false,displayMode:a,hasCachedResult:n.length>0,fieldData:JSON.stringify(e),modelKind:"field"},marks:gt(a$1(r,s))}}function $(e){let r=new Set,n=[[e,false]];for(;n.length>0;){let[o,i]=n.pop();if(Array.isArray(o))for(let s=o.length-1;s>=0;s--)n.push([o[s],i]);else if(o!==null&&typeof o=="object"){let s=o;if(o!==e&&(s.type==="complexField"||s.type==="simpleField")&&typeof s.instruction=="string"){let d=ce(s.instruction);d!==void 0&&r.add(d);}if(s.type==="hyperlink"&&!i)for(let d of re(o))r.add(d);let a=i||s.type==="hyperlink";for(let d of Object.keys(s).sort().reverse())n.push([s[d],a]);}}return [...r]}function re(e){let r=[e],n=[],o=[],i=s=>{if(Array.isArray(s))for(let a=s.length-1;a>=0;a--)r.push(s[a]);};for(;r.length>0;){let s=r.pop();if(s){if((s.type==="simpleField"||s.type==="complexField")&&typeof s.instruction=="string"){let a=ce(s.instruction);a!==void 0&&o.push(a);}switch(s.type){case "hyperlink":i(s.structuredChildren??s.children);break;case "inlineSdt":i(s.content);break;case "simpleField":i(s.structuredResult?.inline??s.fieldTree?.result?.inline??s.content);break;case "complexField":i(s.structuredResult?.inline??s.fieldTree?.result?.inline??s.fieldResult),i(s.structuredCode?.inline??s.fieldTree?.code?.inline??s.fieldCode);break;case "run":if(!Array.isArray(s.content))break;for(let a of s.content){if(!a)continue;let d;if(a.type==="fieldChar")a.charType==="begin"?n.push(""):a.charType==="separate"&&n.length>0?(d=n[n.length-1],n[n.length-1]=void 0):a.charType==="end"&&(d=n.pop());else if(a.type==="instrText"){let c=n.length-1;n[c]!==void 0&&(n[c]+=typeof a.text=="string"?a.text:"");}let p=d===void 0?void 0:ce(d);p!==void 0&&o.push(p);}break}}}return o}function ce(e){let r=e.matchAll(/"([^"]*)(?:"|$)|([^\p{White_Space}]+)/gu),n=r.next().value,o=r.next().value,i=n?.[1]??n?.[2],s=o?.[1]??o?.[2];if(!(!i||!/^[sS][eE][qQ]$/.test(i)||s===void 0||s.startsWith("\\")))return s.toLowerCase()}function _e(e){return {display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""}}function er(e){return {name:"hyperlink",attrs:{href:e.href||(e.anchor?`#${e.anchor}`:""),tooltip:e.tooltip??null,rId:e.rId??null}}}function tr(e,r,n,o,i){let s=e.structuredResult?.inline??[],d=[...(e.type==="complexField"?e.structuredCode?.inline??[]:[]).map((b,R)=>({child:b,index:-R-1})),...s.map((b,R)=>({child:b,index:R}))];if(e.type!=="complexField"||!d.some(({child:b})=>b.type==="hyperlink"||b.type==="simpleField")){i.push(...$(e));let b=te(e,r);return [T("field",b.payload,b.marks)]}let p=[],c=[];d.forEach(({child:b,index:R})=>{if(b.type!=="hyperlink"&&b.type!=="simpleField")return;i.push(...b.type==="hyperlink"?re(b):$(b));let S=b.type==="simpleField"?te(b,r):null,f=b.type==="hyperlink"?me(b,r,n,i):[T("field",S.payload,S.marks)];c.push({index:R,items:f.map(k=>k.kind==="text"?{kind:"text",text:k.text,attributes:k.attrs}:{kind:"embed",embedKind:k.embedKind,payload:k.payload,attributes:k.attrs})});for(let k of f)k.attrs={...k.attrs,fieldResult:{id:o,index:R}};p.push(...f);});let u={...e,fieldResult:s.filter(b=>b.type==="run")},g=te(u,r);return i.push(...$(ce(e.instruction??"")===void 0?u:e)),g.payload.fieldData=JSON.stringify(e),g.payload.resultProjection={id:o,children:c},p.push(T("field",g.payload,g.marks)),p}function ct(e,r,n){let o={name:"footnoteRef",attrs:{id:String(e),noteType:r}},i=[...n,o];return T("noteRef",r==="endnote"?{endnoteRefId:e}:{footnoteRefId:e},i)}function Te(e){return e.filter(r=>r.name==="insertion"||r.name==="deletion")}function De(e,r,n){if((e.type==="drawing"||e.type==="shape"||e.type==="chart")&&r.some(o=>o.name==="hidden")){let o=e.type==="drawing"?e.image:e.type==="shape"?e.shape:e.chart;n.push(...$(o));}switch(e.type){case "text":return e.text?[Z(e.text,r)]:[];case "tab":return [Z(" ",r)];case "break":return e.breakType===void 0||e.breakType==="textWrapping"?[T("break",{},r)]:[];case "softHyphen":return [Z("\xAD",r)];case "noBreakHyphen":return [Z("\u2011",r)];case "symbol":{let o=Number.parseInt(e.char,16);if(!Number.isInteger(o)||o<0||o>1114111)return [];let i={name:"fontFamily",attrs:{ascii:e.font||null,hAnsi:e.font||null,eastAsia:e.font||null,cs:e.font||null,asciiTheme:null,hAnsiTheme:null,eastAsiaTheme:null,csTheme:null}};return [Z(String.fromCodePoint(o),Gt(r,i))]}case "commentReference":return [T("field",{fieldType:"COMMENT",instruction:"",displayText:"",fieldKind:"simple",fldLock:false,dirty:false,displayMode:"result",hasCachedResult:false,modelKind:"commentReference",...e.id!==void 0?{commentId:e.id}:{}})];case "drawing":return [T("image",Xt(e.image),Te(r))];case "horizontalRule":return [T("horizontalRule",{rule:e.rule},r)];case "shape":return [T("shape",Qt(e.shape),Te(r))];case "chart":return [T("chart",Zt(e.chart),Te(r))];case "footnoteRef":return [ct(e.id,"footnote",r)];case "endnoteRef":return [ct(e.id,"endnote",r)];default:return []}}function fe(e,r,n,o,i=[]){let s=[...ht(e,r,n),...i];return e.content.flatMap(a=>De(a,s,o))}function me(e,r,n,o,i=[]){let s=[],a=er(e);for(let d of e.structuredChildren??e.children)if(d.type==="run"){let p=[...ht(d,r,n),...i,a];for(let c of d.content)s.push(...De(c,p,o));}else if(d.type==="simpleField"||d.type==="complexField"){o.push(...$(d));let p=te(d,r);s.push(T("field",p.payload,[...p.marks,...i,a]));}else d.type==="mathEquation"&&s.push(T("math",_e(d),[...i,a]));return s}function rr(e,r,n){return {name:r,attrs:{revisionId:e.id,author:e.author,date:e.date??null,isMovePair:n}}}function nr(e,r,n,o){let i=e.type==="insertion"||e.type==="moveTo"?"insertion":"deletion",s=rr(e.info,i,e.type==="moveFrom"||e.type==="moveTo"),a=[];for(let d of e.content)if(d.type==="run")a.push(...fe(d,r,n,o,[s]));else {o.push(...re(d));let p=me(d,r,n,o,[s]);a.push(...p);}return a}function bt(e$1,r,n,o){let i=[],s=a=>{if(a.kind==="text"){if((a.text===" "?"tab":"text")==="tab"){i.push({kind:"tab",attrs:a.attrs});return}let p=i[i.length-1];p&&"text"in p&&K(p.attrs)===K(a.attrs)?p.text+=a.text:i.push({kind:"text",text:a.text,attrs:a.attrs});return}i.push({kind:a.embedKind,payload:a.payload,attrs:a.attrs});};for(let a of e$1.content)if(a.type==="run")fe(a,r,n,o).forEach(s);else if(a.type==="hyperlink")o.push(...re(a)),me(a,r,n,o).forEach(s);else if(a.type==="simpleField"||a.type==="complexField"){o.push(...$(a));let d=te(a,r);s(T("field",d.payload,d.marks));}else a.type==="inlineSdt"?s(T("sdt",bt(a,r,n,o))):a.type==="mathEquation"&&s(T("math",_e(a)));return N({...e(e$1.properties),propertiesJson:JSON.stringify(e$1.properties),content:i})}function or(e,r,n){let o=r?r.resolveParagraphStyle(e.formatting?.styleId).runFormatting:void 0;return a$1(o,n)}function sr(e){let r=[];for(let n of e.content)n.type==="footnoteRefMark"?r.push("footnote"):n.type==="endnoteRefMark"&&r.push("endnote");return r}function St(e){return e.map(r=>{if(r.kind==="text")return r.text;let n=r.payload.footnoteRefId??r.payload.endnoteRefId;return String(n??"")}).join("")}function ft(e){return e.type!=="break"?null:e.breakType==="page"||e.breakType==="column"?e.breakType:null}function ir(e){if(!e.content.some(o=>ft(o)!==null))return [];let r=[],n=0;for(let o of e.content){let i=ft(o);if(i!==null){r.push({offset:n,type:i});continue}n+=St(De(o,[],[])).length;}return r}function ar(e,r,n){let o=fe(e,r,n,[]);if(o.some(p=>p.kind!=="text"&&p.embedKind!=="noteRef"))return null;let i=o.map(p=>Kt(p.marks));if(i.some(p=>p!==i[0]))return null;let s=sr(e),a=ir(e),d=i[0];return {text:St(o),...s.length>0?{noteMarks:s}:{},...a.length>0?{breaks:a}:{},...d!==void 0?{marksKey:d}:{},...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{}}}function lr(e,r,n,o,i){let s=e.formatting,a=s?.styleId,d=s?.indentFirstLine===0?void 0:s?.indentFirstLine,p=d??e.listRendering?.indentFirstLine??s?.indentFirstLine,c=d===void 0&&e.listRendering?.indentFirstLine!==void 0?e.listRendering.hangingIndent:s?.hangingIndent??e.listRendering?.hangingIndent,u={paraId:e.paraId??null,textId:e.textId??null,styleId:a??null,numPr:s?.numPr??null,numPrFromStyle:s?.numPrFromStyle??null,listNumFmt:e.listRendering?.numFmt??null,listIsBullet:e.listRendering?.isBullet??null,listMarker:e.listRendering?.marker??null,listMarkerHidden:e.listRendering?.markerHidden||null,listMarkerFontFamily:e.listRendering?.markerFontFamily||null,listMarkerFontSize:e.listRendering?.markerFontSize||null,listMarkerBold:e.listRendering?.markerBold??null,listMarkerItalic:e.listRendering?.markerItalic??null,listMarkerColor:e.listRendering?.markerColor??null,listMarkerSuffix:e.listRendering?.markerSuffix||null,listLevelNumFmts:e.listRendering?.levelNumFmts||null,listAbstractNumId:e.listRendering?.abstractNumId??null,listStartOverride:e.listRendering?.startOverride??null,_originalFormatting:s??null};if(r){let S=r.resolveParagraphStyle(a,i),f=S.paragraphFormatting;u.alignment=s?.alignment??f?.alignment??null,u.spaceBefore=s?.spaceBefore??f?.spaceBefore??null,u.spaceAfter=s?.spaceAfter??f?.spaceAfter??null,u.spaceBeforeLines=s?.spaceBeforeLines??f?.spaceBeforeLines??null,u.spaceAfterLines=s?.spaceAfterLines??f?.spaceAfterLines??null,u.beforeAutospacing=s?.beforeAutospacing??f?.beforeAutospacing??null,u.afterAutospacing=s?.afterAutospacing??f?.afterAutospacing??null,u.lineSpacing=s?.lineSpacing??f?.lineSpacing??null,u.lineSpacingRule=s?.lineSpacingRule??f?.lineSpacingRule??null,u.spacingExplicit=s?.spacingExplicit||null,u.indentLeft=s?.indentLeft??e.listRendering?.indentLeft??f?.indentLeft??null,u.indentRight=s?.indentRight??f?.indentRight??null;let h=s?.numPr?.numId===0&&f?.numPr&&f.numPr.numId!==0?void 0:f;u.indentFirstLine=p??h?.indentFirstLine??null,u.hangingIndent=c??h?.hangingIndent??false,u.borders=s?.borders??f?.borders??null,u.shading=s?.shading??f?.shading??null,u.tabs=s?.tabs??f?.tabs??null,u.pageBreakBefore=s?.pageBreakBefore??f?.pageBreakBefore??null,u.keepNext=s?.keepNext??f?.keepNext??null,u.keepLines=s?.keepLines??f?.keepLines??null,u.widowControl=s?.widowControl??f?.widowControl??null,u.contextualSpacing=s?.contextualSpacing??f?.contextualSpacing??null,u.snapToGrid=s?.snapToGrid??f?.snapToGrid??null,u.autoSpaceDE=s?.autoSpaceDE??f?.autoSpaceDE??null,u.autoSpaceDN=s?.autoSpaceDN??f?.autoSpaceDN??null,u.outlineLevel=s?.outlineLevel??f?.outlineLevel??null,u.bidi=s?.bidi??f?.bidi??null;let P=r.getDefaultCharacterStyle()?.rPr,_=P?a$1(S.runFormatting,P):S.runFormatting;u.defaultTextFormatting=a$1(_,$t(s?.runProperties,r))??null,!s?.numPr&&f?.numPr&&f.numPr.numId!==0&&(u.numPr=f.numPr,u.numPrFromStyle=f.numPr);}else u.alignment=s?.alignment??null,u.spaceBefore=s?.spaceBefore??null,u.spaceAfter=s?.spaceAfter??null,u.spaceBeforeLines=s?.spaceBeforeLines??null,u.spaceAfterLines=s?.spaceAfterLines??null,u.beforeAutospacing=s?.beforeAutospacing??null,u.afterAutospacing=s?.afterAutospacing??null,u.lineSpacing=s?.lineSpacing??null,u.lineSpacingRule=s?.lineSpacingRule??null,u.spacingExplicit=s?.spacingExplicit||null,u.indentLeft=s?.indentLeft??e.listRendering?.indentLeft??null,u.indentRight=s?.indentRight??null,u.indentFirstLine=p??null,u.hangingIndent=c??false,u.borders=s?.borders??null,u.shading=s?.shading??null,u.tabs=s?.tabs??null,u.pageBreakBefore=s?.pageBreakBefore??null,u.keepNext=s?.keepNext??null,u.keepLines=s?.keepLines??null,u.widowControl=s?.widowControl??null,u.snapToGrid=s?.snapToGrid??null,u.autoSpaceDE=s?.autoSpaceDE??null,u.autoSpaceDN=s?.autoSpaceDN??null,u.outlineLevel=s?.outlineLevel??null,u.bidi=s?.bidi??null,u.defaultTextFormatting=s?.runProperties??null;if(e.sectionProperties){u._sectionProperties=e.sectionProperties;let S=e.sectionProperties.sectionStart;(S==="nextPage"||S==="continuous"||S==="oddPage"||S==="evenPage"||S==="nextColumn")&&(u.sectionBreakType=S);}e.renderedPageBreakBefore&&(u.renderedPageBreakBefore=true),pr(e)&&(u.pageBreakBeforeRun=true),e.pPrIns&&(u.pPrIns={revisionId:e.pPrIns.id,author:e.pPrIns.author,date:e.pPrIns.date??null}),e.pPrDel&&(u.pPrDel={revisionId:e.pPrDel.id,author:e.pPrDel.author,date:e.pPrDel.date??null}),e.propertyChanges?.length&&(u.pPrChange=e.propertyChanges);let g=[],b=0,R=0;for(let S of e.content)if(S.type==="bookmarkStart")g.push({id:S.id,name:S.name,kind:"start",offset:R,...S.colFirst!==void 0?{colFirst:S.colFirst}:{},...S.colLast!==void 0?{colLast:S.colLast}:{}});else if(S.type==="bookmarkEnd")g.push({id:S.id,kind:"end",offset:R});else {let f=dr(S);for(let k=0;k<f;k+=1)R+=n[b]?.pmSize??0,b+=1;}return g.length>0&&(u.bookmarks=g),o?.length&&(u._originalRunBoundaries=o),u}var Rt=new WeakMap;function dr(e){return Rt.get(e)??0}function ur(e,r,n,o){let i=[],s=[],a=[],d=[],p=or(e,r,n);for(let[u,g]of e.content.entries()){let b=i.length;if(g.type==="commentRangeStart"||g.type==="commentRangeEnd")a.push({unit:b,start:g.type==="commentRangeStart",id:g.id});else if(g.type==="run"){let R=ar(g,p,r);R&&d?d.push(R):d=void 0,i.push(...fe(g,p,r,s));}else if(g.type==="hyperlink"){d=void 0,s.push(...re(g));let R=me(g,p,r,s);i.push(...R);}else g.type==="simpleField"||g.type==="complexField"?(d=void 0,i.push(...tr(g,p,r,u,s))):g.type==="inlineSdt"?(d=void 0,i.push(T("sdt",bt(g,p,r,s),[],2))):g.type==="insertion"||g.type==="deletion"||g.type==="moveFrom"||g.type==="moveTo"?(d=void 0,i.push(...nr(g,p,r,s))):g.type==="mathEquation"?(d=void 0,i.push(T("math",_e(g)))):g.type!=="bookmarkStart"&&g.type!=="bookmarkEnd"&&g.type!=="rawXml"&&(d=void 0);Rt.set(g,i.length-b);}let c=lr(e,r,i,d,o);return {units:i,commentMarks:a,ppr:nt(c),opaqueSequences:s}}function ee(e,r){for(let n of e.content)n.type==="break"&&n.breakType==="page"?r.push("pageBreak"):(n.type!=="text"||n.text.length>0)&&r.push("visible");}function Ye(e,r){for(let n of e)if(n.type==="run")ee(n,r);else if(n.type==="hyperlink")for(let o of n.children)o.type==="run"&&ee(o,r);else if(n.type==="simpleField")for(let o of n.content)o.type==="run"&&ee(o,r);else if(n.type==="complexField")for(let o of [...n.fieldCode,...n.fieldResult])ee(o,r);else if(n.type==="inlineSdt")Ye(n.content,r);else if(n.type==="insertion"||n.type==="deletion"||n.type==="moveFrom"||n.type==="moveTo")for(let o of n.content)o.type==="run"&&ee(o,r);else n.type==="mathEquation"&&r.push("visible");}function pr(e){let r=[];return Ye(e.content,r),r[0]==="pageBreak"}function cr(e){let r=[];Ye(e.content,r);let n=false,o=false;for(let i of r)if(i==="pageBreak"){if(o||n)return true;n=true;}else o=true;return false}function fr(e){let r=new Map,n=new Map;return e.rows.forEach((o,i)=>{let s=0,a=o.cells.map(p=>{let c=s;return s+=p.formatting?.gridSpan??1,{column:c,vMerge:p.formatting?.vMerge,key:`${i}-${c}`}});if(a.length>0&&a.every(p=>p.vMerge==="continue"&&n.has(p.column))){for(let p of a)n.delete(p.column),r.set(p.key,{rowSpan:1,skip:false});return}for(let p of a)if(p.vMerge==="restart")n.set(p.column,i),r.set(p.key,{rowSpan:1,skip:false});else if(p.vMerge==="continue"){let c=n.get(p.column);if(c===void 0)r.set(p.key,{rowSpan:1,skip:false});else {let u=r.get(`${c}-${p.column}`);u&&(u.rowSpan+=1),r.set(p.key,{rowSpan:1,skip:true});}}else n.delete(p.column),r.set(p.key,{rowSpan:1,skip:false});}),r}function Ie(e){return {revisionId:e.id,author:e.author,date:e.date??null}}function mr(e,r,n,o,i,s){let a=r?{top:n?r.top:r.insideH,bottom:o?r.bottom:r.insideH,left:i?r.left:r.insideV,right:s?r.right:r.insideV}:void 0;return a||e?.borders?{...a??{},...e?.borders??{}}:void 0}function mt(e,r){let n=e.formatting,o=b$3(n?.shading?.fill,r.theme),i=n?.width?.value??r.gridWidth,s=n?.width?.type??(r.gridWidth!==void 0?"pct":null),a={colspan:n?.gridSpan??1,rowspan:r.rowspan,width:i??null,widthType:s,verticalAlign:n?.verticalAlign??null,backgroundColor:o??null,borders:mr(n,r.tableBorders,r.firstRow,r.lastRow,r.firstColumn,r.lastColumn)??null,margins:n?.margins?{top:n.margins.top?.value,bottom:n.margins.bottom?.value,left:n.margins.left?.value??(r.tableBidi?n.margins.end?.value:n.margins.start?.value),right:n.margins.right?.value??(r.tableBidi?n.margins.start?.value:n.margins.end?.value)}:r.defaultMargins??null,textDirection:n?.textDirection??null,noWrap:n?.noWrap??false,_originalFormatting:n??null,_originalResolvedFill:o??null};if(e.structuralChange){let d=e.structuralChange,p=Ie(d.info);d.type==="tableCellInsertion"?a.cellMarker={kind:"ins",info:p}:d.type==="tableCellDeletion"?a.cellMarker={kind:"del",info:p}:d.type==="tableCellMerge"&&(a.cellMarker={kind:"merge",info:p,vMerge:d.vMerge??"cont",...d.vMergeOrig?{vMergeOrig:d.vMergeOrig}:{}});}return e.propertyChanges?.length&&(a.tcPrChange=e.propertyChanges),{attrs:at(a,r.isHeader),content:e.content.length>0?e.content:[{type:"paragraph",content:[]}]}}function gr(e,r,n,o,i,s,a,d,p){let c={height:e.formatting?.height?.value??null,heightRule:e.formatting?.heightRule??null,isHeader:!!e.formatting?.header,_originalFormatting:e.formatting??null};e.structuralChange&&(e.structuralChange.type==="tableRowInsertion"?c.trIns=Ie(e.structuralChange.info):e.structuralChange.type==="tableRowDeletion"&&(c.trDel=Ie(e.structuralChange.info))),e.propertyChanges?.length&&(c.trPrChange=e.propertyChanges);let u=r.columnWidths,g=u?.reduce((f,k)=>f+k,0)??0,b=u?.length??Math.max(0,...r.rows.map(f=>f.cells.reduce((k,h)=>k+(h.formatting?.gridSpan??1),0))),R=0,S=[];return e.cells.forEach(f=>{let k=f.formatting?.gridSpan??1,h=R,P=o.get(`${n}-${h}`),_;if(u&&g>0){let Y=0;for(let C=0;C<k&&h+C<u.length;C+=1)Y+=u[h+C];_=Math.round(Y/g*100);}R+=k,!P?.skip&&S.push({paragraphFormatting:ve(r,d,n,h,R,p),...mt(f,{isHeader:n===0&&!!r.formatting?.look?.firstRow,rowspan:P?.rowSpan??1,gridWidth:_,firstRow:n===0,lastRow:n===r.rows.length-1,firstColumn:h===0,lastColumn:R===b,tableBorders:i,defaultMargins:s,theme:a,tableBidi:!!r.formatting?.bidi})});}),S.length===0&&S.push({paragraphFormatting:ve(r,d,n,0,b,p),...mt({formatting:b>1?{gridSpan:b}:void 0,content:[{type:"paragraph",content:[]}]},{isHeader:n===0&&!!r.formatting?.look?.firstRow,rowspan:1,gridWidth:g>0?100:void 0,firstRow:n===0,lastRow:n===r.rows.length-1,firstColumn:true,lastColumn:true,tableBorders:i,defaultMargins:s,theme:a,tableBidi:!!r.formatting?.bidi})}),{attrs:it(c),cells:S}}function yr(e,r,n,o){let i=r?.getDefaultTableStyle(),s=e.formatting?.styleId,a=s??i?.styleId,d=a?r?.getStyle(a):void 0,p=e.formatting?.borders??d?.tblPr?.borders??i?.tblPr?.borders,c=e.formatting?.cellMargins??d?.tblPr?.cellMargins??i?.tblPr?.cellMargins,u=e.formatting?.bidi?c?.end:c?.start,g=e.formatting?.bidi?c?.start:c?.end,b=c?{top:c.top?.value,bottom:c.bottom?.value,left:c.left?.value??u?.value,right:c.right?.value??g?.value}:void 0,R=[],S=new Set,f=d;for(;f?.basedOn&&R.length<32&&!S.has(f.basedOn);)S.add(f.basedOn),R.unshift(f.basedOn),f=r?.getStyle(f.basedOn);let k={...e.formatting??{},styleCascade:{...s?{selectedStyleId:s}:{},...i?.styleId?{defaultStyleId:i.styleId}:{},...R.length>0?{basedOnStyleIds:R}:{}}},h={styleId:s??null,width:e.formatting?.width?.value??null,widthType:e.formatting?.width?.type??null,justification:e.formatting?.justification??null,columnWidths:e.columnWidths??null,tableLayout:e.formatting?.layout??null,floating:e.formatting?.floating??null,cellMargins:b??null,look:e.formatting?.look??null,bidi:e.formatting?.bidi||null,compatibilityMode:o===12?null:o,_originalFormatting:k};e.propertyChanges?.length&&(h.tblPrChange=e.propertyChanges);let P=fr(e),_=rt(e);return {attrs:h,rows:e.rows.map((Y,C)=>gr(Y,e,C,P,p,b,n,d??i,_))}}function hr(e$1){return dt(e(e$1))}function br(e){let r=(s,a,d)=>{if(d<=a)return;let p=e.commentCoverage.get(s),c=p[p.length-1];c&&c[1]===a?c[1]=d:p.push([a,d]);},n=[],o=0,i=0;for(let s=0;s<=e.units.length;s+=1){for(;e.commentMarks[i]?.unit===s;){let d=e.commentMarks[i++];if(d.start){if(n.some(p=>p.id===d.id))continue;e.commentCoverage.has(d.id)||e.commentCoverage.set(d.id,[]),n.push({id:d.id,start:o});}else {let p=n.findIndex(c=>c.id===d.id);if(p!==-1){let[c]=n.splice(p,1);r(c.id,c.start,o);}}}let a=e.units[s];if(a){if(a.kind==="embed"&&a.embedKind==="pilcrow")for(let d of n)d.paragraphEnd??(d.paragraphEnd=o);o+=a.kind==="text"?a.text.length:1;}}for(let s of n)r(s.id,s.start,s.paragraphEnd??o);for(let[s,a]of e.commentCoverage)a.length===0&&e.commentCoverage.delete(s);}function Ae(e,r,n){if(d$2(n))return null;if(n.type==="paragraph"){let o=e.paragraph++;return !n.repeatedParaId&&n.paraId||`${r}:p${o}`}return n.type==="table"?`${r}:t${e.table++}`:lt(r,e.sdt++)}function Sr(e){return /^\d+$/.test(e.trim())}function Rr(e){let r=e.structuredResult?.blocks??[],n=r[r.length-1];return !n||n.type!=="paragraph"||(n.content?.length??0)>0?null:r.length}function kr(e,r,n,o,i,s){for(let a of e){if(a.kind!=="embed"||a.embedKind!=="field")continue;let d=a.payload.instruction;if(typeof d!="string"||!Sr(d))continue;let p=a.payload.fieldData;if(typeof p!="string")continue;let c;try{c=JSON.parse(p);}catch{continue}let u=Rr(c);if(u===null||o+1+u>n.length)continue;let g={...i},b=[];for(let R=0;R<u;R+=1){let S=n[o+1+R],f=Ae(g,r,S);f!==null&&(S.type==="table"&&s.set(o+1+R,f),b.push(f));}b.length>0&&(a.payload.fieldResultBlocks=b);}}function xr(e){return !d$2(e)&&e.type==="paragraph"&&(e.content?.some(r=>r.type==="run"&&r.content.some(n=>n.type==="fieldChar"&&n.charType==="separate"))??false)}function Pr(e,r,n,o,i){for(let s of e){if(s.kind!=="embed"||s.embedKind!=="field")continue;let a=s.payload.fieldData;if(typeof a!="string"||!a.includes('"blocks"'))continue;let d;try{d=JSON.parse(a);}catch{continue}if(!d||typeof d!="object")continue;let p=d.structuredCode?.blocks,c=d.structuredResult?.blocks,u=Array.isArray(p)?p.length:0,g=Array.isArray(c)&&c.length>0,b;if(u===0){let h=n[o+1];if(!g||!h||!xr(h))continue;b=0;}else b=g?u:u-1;if(o+1+b+1>n.length)continue;let R=n.slice(o+1,o+1+b+1);if(R.some(h=>d$2(h)||h.type!=="paragraph"))continue;let S={...i},f=[];for(let h of R){let P=Ae(S,r,h);P!==null&&f.push(P);}let k=f.pop();k!==void 0&&(s.payload.fieldCodeMarks=f,s.payload.fieldCodeTarget=k);}}function H(e,r,n,o){let i={storyId:r,units:[],commentMarks:[],commentCoverage:new Map};e.plans.push(i);let s=n.length>0,a=s?[...n]:[{type:"paragraph",content:[]}],d={paragraph:0,table:0,sdt:0},p=new Map,c=null;for(let[u,g]of a.entries()){if(d$2(g))continue;let b=d.table,R=Ae(d,r,g);if(R===null)continue;if(g.type==="paragraph"){let f=ur(g,e.styleResolver,o.extraRunFormatting,o.tableParagraphFormatting);e.opaqueSequences.push(...f.opaqueSequences),kr(f.units,r,a,u,d,p),Pr(f.units,r,a,u,d);let k=i.units.length;i.commentMarks.push(...f.commentMarks.map(h=>({...h,unit:k+h.unit}))),i.units.push(...f.units),i.units.push(T("pilcrow",{...f.ppr,...s&&g.paraId?{sourceParaId:g.paraId}:{},...s?{}:{paraOrigin:"synthetic"},paraId:R})),o.includePageBreaks&&cr(g)&&i.units.push(T("pageBreak",{})),c="paragraph";continue}if(g.type==="table"){let f=yr(g,e.styleResolver,e.theme,e.compatibilityMode),k=f.rows.map((P,_)=>({trPr:P.attrs,cells:P.cells.map((Y,C)=>({tcPr:Y.attrs,story:Ce(r,b,_,C)}))})),h=p.get(u);i.units.push(T("table",{tblPr:ot(f.attrs),grid:st(f.attrs),rows:k,...h===void 0?{}:{blockId:h}})),f.rows.forEach((P,_)=>{P.cells.forEach((Y,C)=>{H(e,Ce(r,b,_,C),Y.content,{includePageBreaks:false,appendBodyTail:false,seedComments:o.seedComments,extraRunFormatting:Y.extraRunFormatting,tableParagraphFormatting:Y.paragraphFormatting});});}),c="table";continue}let S=R;i.units.push(T("blockSdt",{...hr(g.properties),story:S})),H(e,S,g.content,{includePageBreaks:o.includePageBreaks,appendBodyTail:false,seedComments:o.seedComments,tableParagraphFormatting:o.tableParagraphFormatting}),c="blockSdt";}o.appendBodyTail&&(c==="table"||c==="blockSdt")&&i.units.push(T("pilcrow",{hangingIndent:false,paraId:`${r}:p${d.paragraph}`,paraOrigin:"synthetic"})),o.seedComments&&br(i);}function wr(e){let r=[{op:"delete",index:0,len:1}],n=0,o="",i={},s=K(i),a=()=>{o&&(r.push({op:"insert",index:n,text:o,attrs:i}),n+=o.length,o="");};for(let d of e)if(d.kind==="text"){let p=K(d.attrs);o&&p!==s&&a(),i=d.attrs,s=p,o+=d.text;}else a(),r.push({op:"insertEmbed",index:n,kind:d.embedKind,payload:d.payload,attrs:d.attrs}),n+=1;return a(),r}function vr(e,r){let n=wr(r.units);for(let[o,i]of r.commentCoverage)n.push({op:"setComment",id:String(o),ranges:i,author:"",date:"",body:null});e.applySeedRawOps(r.storyId,n);}function Cr(e,r,n={}){g(e,"all");let o={styleResolver:r.package.styles?d(r.package.styles):null,theme:r.package.theme??null,plans:[],compatibilityMode:zt(r),opaqueSequences:[]};H(o,"body",r.package.document.content,{includePageBreaks:true,appendBodyTail:true,seedComments:true});for(let[i,s]of r.package.headers??[])H(o,pe(i),s.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let[i,s]of r.package.footers??[])o.plans.some(a=>a.storyId===pe(i))||H(o,pe(i),s.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of r.package.footnotes??[])H(o,ut(i.id),i.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of r.package.endnotes??[])H(o,pt(i.id),i.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of o.plans)e.createStory(i.storyId,"","Normal","left");for(let i of o.plans)vr(e,i);e.seedOpaqueSequences(o.opaqueSequences),e.beginOpening(n.generation);}function Tr(e){let r=e.package;return [r.document.content,...[...r.headers?.values()??[]].map(n=>n.content),...[...r.footers?.values()??[]].map(n=>n.content),...(r.footnotes??[]).map(n=>n.content),...(r.endnotes??[]).map(n=>n.content)]}var Ir="word/comments.xml";function kt(e){if(Array.isArray(e)&&e.length>0&&e.every(n=>n?.type==="paragraph"))return e;let r=typeof e=="string"?e:"";return [{type:"paragraph",formatting:{},content:r?[{type:"run",formatting:{},content:[{type:"text",text:r}]}]:[]}]}function _r(e,r){let n=r.package.document.comments??[],o=new Map(e.listComments().map(c=>[c.id,c])),i=false,s=n.map(c=>{let u=o.get(String(c.id));return o.delete(String(c.id)),!u||!u.author&&!u.date&&u.body==null?c:(i=true,{...c,...u.author?{author:u.author}:{},...u.date?{date:u.date}:{},...u.body==null?{}:{content:kt(u.body)}})}),a=new Set(n.map(c=>c.id)),d=new Map,p=Math.max(0,...a)+1;for(let c of o.values()){i=true;let u=/^\d+$/.test(c.id)?Number(c.id):Number.NaN;if(!Number.isSafeInteger(u)||a.has(u)){for(;a.has(p);)p+=1;u=p;}a.add(u),String(u)!==c.id&&d.set(u,c.id),s.push({id:u,author:c.author,...c.date?{date:c.date}:{},content:kt(c.body)});}return {comments:s,sessionIds:d,changed:i}}function Dr(e,r){let n=new Map(r.paragraphs.flatMap(s=>s.session?[[s.session.paraId,s]]:[])),o=[],i=s=>{for(let a of s)if(a.type==="table")for(let d of a.rows)for(let p of d.cells)i(p.content);else if(a.type==="blockSdt")i(a.content);else if(a.type==="paragraph"&&a.paraId){let d=f(a),p=d===void 0?void 0:n.get(d);if(!p?.session||!p.persisted)continue;o.push({session:p.session,persisted:{...p.persisted,paraId:a.paraId}});}};for(let s of Tr(e))i(s);return o}function Fe(e,r){let n=[],o=false;for(let i of e){let s=i;if(i.type==="paragraph"){let a=f(i);i.content.length===0&&a!==void 0&&r.has(a)&&(s=null);}else if(i.type==="table"){let a=i.rows.map(d=>{let p=d.cells.map(c=>{let u=Fe(c.content,r);return u===c.content?c:{...c,content:u}});return p.every((c,u)=>c===d.cells[u])?d:{...d,cells:p}});a.some((d,p)=>d!==i.rows[p])&&(s={...i,rows:a});}else if(i.type==="blockSdt"){let a=Fe(i.content,r);a!==i.content&&(s={...i,content:a});}o||(o=s!==i),s&&n.push(s);}return o?n:e}function Yr(e,r){let n=new Set(r.paragraphs.flatMap(({origin:a,session:d})=>a==="synthetic"&&d?[d.paraId]:[]));if(n.size===0)return e;let o=a=>{let d=Fe(a.content,n);return d===a.content?a:{...a,content:d}},i=e.package,s=a=>a&&new Map([...a].map(([d,p])=>[d,o(p)]));return {...e,package:{...i,document:o(i.document),headers:s(i.headers),footers:s(i.footers),footnotes:i.footnotes?.map(o),endnotes:i.endnotes?.map(o)}}}function xt(e){return {identities:e.paragraphIdentities(),plan:e.paragraphSavePlan()}}async function Pt(e,r,n,o,i={},s=()=>true,a=false){let d={...n.plan,patchedParts:n.plan.patchedParts.filter(({part:h})=>s(h))},p=Yr(r,n.identities),c=Dr(p,n.identities),{buffer:u}=await d$1(p,o,i,void 0,void 0,d,a),g=new Uint8Array(u),b=e.writtenParagraphIds(g),R=(h,P)=>b[h]?.includes(P.toUpperCase())??false,S=c.filter(({persisted:h})=>R(h.story.partUri,h.paraId)),f=new Set(e.recordSavedParagraphIds([...S.map(({session:h,persisted:P})=>[h.paraId,P.paraId]),...d.assignments.filter(({part:h,paraId:P})=>R(`/${h}`,P)).map(({part:h,ordinal:P,paraId:_})=>[`/${h}#${P}`,_])]).map(([h,P])=>`${h}\0${P}`)),k=({session:h,persisted:P})=>f.has(`${h.paraId}\0${P.paraId}`);return {bytes:g,paragraphs:S.filter(h=>!k(h)),conflicts:S.filter(k)}}async function Ar(e,r={}){let n=e.materializeDocx();if(!n?.originalBuffer)throw new Error("saveYrsDocx requires a session opened from DOCX bytes");let o=xt(e),i=_r(e,n),s=h(e,i.changed?{...n,package:{...n.package,document:{...n.package.document,comments:i.comments}}}:n,{commentIds:i.sessionIds});return Pt(e,s,o,n.originalBuffer,r,a=>!i.changed||a!==Ir)}var Me=new WeakMap;async function On(e){let r=new Uint8Array(e),n=globalThis.crypto?.subtle;if(!n)return r;try{let o=new Uint8Array(await n.digest("SHA-256",r));Me.set(r,Array.from(o,i=>i.toString(16).padStart(2,"0")).join(""));}catch{}return r}function En(e){return Me.get(e)}function Mn(e,r){return !e||!r?e===r:e.anchor.story===r.anchor.story&&e.anchor.paraId===r.anchor.paraId&&e.anchor.offset===r.anchor.offset&&e.head.story===r.head.story&&e.head.paraId===r.head.paraId&&e.head.offset===r.head.offset}function Fr(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}function wt(e){return JSON.stringify("revisionId"in e?{revisionId:e.revisionId}:{story:e.story,startPara:e.start.paraId,startOffset:e.start.offset,endPara:e.end.paraId,endOffset:e.end.offset})}function vt(e){return JSON.stringify(e.map(r=>({story:r.story,startPara:r.start.paraId,startOffset:r.start.offset,endPara:r.end.paraId,endOffset:r.end.offset})))}function Ct(e){return e.kind==="search"?e.within.story:e.story}function Oe(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function Nn(e,r){return Ee(e,r)}function Ee(e,r){let n=JSON.parse(e);if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError("DOCX host metadata must be an object");let o=n;if(!Array.isArray(o.referencedFonts)||!o.referencedFonts.every(a=>typeof a=="string"))throw new TypeError("DOCX host referencedFonts must be a string array");let i=o.unusedScriptFonts??[];if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))throw new TypeError("DOCX host unusedScriptFonts must be a string array");let s=c(o.envelope,Oe(r));return {document:s.document,referencedFonts:o.referencedFonts,unusedScriptFonts:i,embeddedFonts:s.embeddedFonts,...s.fontTableRelationshipsXml===void 0?{}:{fontTableRelationshipsXml:s.fontTableRelationshipsXml}}}var Or=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;function Er(e,r){let n=new Map,o=[],i=false,s=false,a$1=0,d=0,p=false,c=false,u,g$1=null,b=[],R=new Map,S=new Map,f=null,k=false,h=0,P=false,_=null,Y=t=>(t.layoutJson!==void 0&&_!==null&&(f=_,k=true,h+=1,P=false,_=null),t),C=0,E=null,ne=null,Tt=()=>{u=void 0,g$1=null;},Ne=()=>{if(!(s||p||d!==0)){p=true;try{for(;!s&&o.length>0;){let t=o.shift();if(!t)break;for(let[l,m]of [...n]){if(s)return;if(n.get(l)===m)try{m(t.update.slice(),t.origin);}catch{}}}}finally{p=false,s&&(o.length=0);}}},ge=false,oe=false,y=t=>{if(ge)throw new Error("A document preview is display-only");Tt(),d+=1;try{return t()}finally{d-=1,d===0&&Ne();}},Je=t=>t?{anchor:{...t.anchor},head:{...t.head}}:null,x=t=>{c||(e.track_undo(),c=true),t!==void 0&&(e.select_story(t),w(t));},w=t=>{g(J,t);},A=t=>(w(t.createdStoryIds),w(t.deletedStoryIds),w(t.changedStoryIds),t),se=()=>(u!==void 0?u:JSON.parse(e.selection()))?.head.story??"all",It=()=>{i||(e.set_update_observer((t,l)=>{l!==0&&l!==1||(o.push({update:t.slice(),origin:l===0?"local":"remote"}),Ne());}),i=true);},_t=()=>{!i||n.size>0||s||(o.length=0,e.clear_update_observer(),i=false);},ye=new Map,Be=0,he=()=>{ye.clear(),Be+=1;},We=(t,l,m={})=>{let v=t.slice();w("all"),he();let B=y(()=>{e.set_media_tokens(m.mediaTokens===!0);let L=e.open_docx(v,l,m.generation,Me.get(t));return M.reset(),L}),z=Ue(Ee(B,v));return E=v,ne=ke(z.document),oe=false,z},Le=t=>{if(s||!t.startsWith("media:"))return null;let l=ye.get(t);return l===void 0&&(l=e.media_data_url(t)??null,ye.set(t,l)),l},Ue=t=>(a(t.document.package.document.comments,Le),t),ie=null,M=d$3({version:()=>e.version(),resolveParagraphAnchor:t=>J.resolveParagraphAnchor(t),findText:t=>J.findText(t),readParagraphs:t=>J.readParagraphs(t),applyEdits:t=>J.applyEdits(t),listRevisions:()=>J.listRevisions(),revisionStamps:t=>JSON.parse(e.revision_stamps_json(JSON.stringify(t))),settleRevisions:(t,l)=>{let m=J.storiesChangedSince(Number.MAX_SAFE_INTEGER).revision;e.settle_revisions_json(JSON.stringify({accept:t,reject:l})),w(J.storiesChangedSince(m).stories);},...typeof e.begin_shared_reads=="function"&&typeof e.end_shared_reads=="function"?{sharedReads:t=>{e.begin_shared_reads();try{return t()}finally{e.end_shared_reads();}}}:{}}),J={clientId:r,openDocxPreview:(t,l)=>{w("all"),he();let m=y(()=>e.open_docx_preview(t,l));return m===void 0?null:(ge=true,oe=true,Ue(Ee(m,t)))},isDisplayOnly:()=>ge,setPartialDocument:t=>{oe=t,e.set_partial_document(t);},layoutDocumentWithRegionsPrefixRetainedJson:(t,l)=>{let m=e.layout_document_with_regions_prefix_retained_json(t,l);return f=t,k=true,h+=1,P=false,m},registerFont:t=>{let l=e.register_measure_font(t);return b.push(t.slice()),C+=1,l},registerSubstituteFont:(t,l)=>{let m=e.register_substitute_measure_font(t,l);return m===t||(b.push({substituteOf:t,family:l}),C+=1),m},clearFonts:()=>{e.clear_measure_fonts(),b.length=0,S.clear(),C+=1;},measureParagraphJson:t=>{let l=e.measure_paragraph_json(t);return S.set(t,t),l},layoutDocumentJson:t=>{let l=e.layout_document_json(t);return f=t,k=false,h+=1,P=false,l},layoutFontRequirementsJson:t=>e.layout_font_requirements_json(t),layoutDocumentWithRegionsJson:t=>{let l=e.layout_document_with_regions_json(t);return f=t,k=true,h+=1,P=false,l},layoutDocumentWithRegionsRetainedJson:t=>{let l=e.layout_document_with_regions_retained_json(t);return f=t,k=true,h+=1,P=false,l},beginRegionLayout:t=>(_=t,Y(JSON.parse(e.begin_region_layout(t)))),resumeRegionLayout:t=>Y(JSON.parse(e.resume_region_layout(t))),adoptResidentWorkerLayout:t=>(f=t,k=true,h+=1,P=true,h),residentLayoutInWorker:()=>P,retainedKernelInputsJson:t=>{if(P)throw new Error("the retained layout was computed in the resident worker");if(t!==h)throw new Error(`retained layout revision mismatch: expected ${t}, current ${h}`);return e.retained_kernel_inputs_json()},buildDisplayListJson:t=>e.build_display_list_json(t),resetFrameBase:()=>{s||e.reset_frame_base();},buildDisplayListFrame:(t,l)=>e.build_display_list_frame(t,l),setDisplayWindow:(t,l)=>e.set_display_window(t,l),setDisplayRetainBuiltPages:t=>e.set_display_retain_built_pages(t),buildDisplayPagesFrame:(t,l)=>e.build_display_pages_frame(Uint32Array.from(t),l),residentCaretSnapshot:()=>JSON.parse(e.resident_caret_snapshot_json()),applyInput:(t,l)=>(x(),w(se()),y(()=>e.apply_input(t,l))),applyDelete:(t,l,m=1)=>(x(),w(se()),y(()=>e.apply_delete(t,l,m))),residentDeletedUnits:()=>e.resident_deleted_units(),applyInputProfiled:(t,l)=>{x(),w(se());let m=y(()=>e.apply_input_profiled(t,l)),v=JSON.parse(e.apply_input_profile_json());return {frame:m,profile:v}},applyDeleteProfiled:(t,l,m=1)=>{x(),w(se());let v=y(()=>e.apply_delete_profiled(t,l,m)),B=JSON.parse(e.apply_input_profile_json());return {frame:v,profile:B}},residentWorkerSnapshot:t=>{if(!f||!k&&R.size===0)return null;let l=ie!==null,m=l?"null":e.selection(),v=l?void 0:e.media_sources_json(),B=t?.knownFontsRevision===C,z=null;if(!l&&t?.knownStateVector)try{z=e.encode_diff(t.knownStateVector.slice());}catch{z=null;}return {clientId:r,...l?{workerAuthoritative:true}:{},state:l?new Uint8Array(0):z??e.encode_state(),selection:JSON.parse(m),fonts:B?[]:b.map(L=>L instanceof Uint8Array?L.slice():{...L}),fontsRevision:C,renderInputs:[...R].map(([L,Dt])=>({story:L,env:structuredClone(Dt)})),measureInputs:[...S.values()],layoutInput:f,layoutWithRegions:k,layoutRevision:h,...oe?{partialDocument:true}:{},...v?{mediaSources:v}:{}}},residentWorkerProbe:()=>!f||!k&&R.size===0?null:{layoutRevision:h},displayHitTestRegionsJson:(t,l,m)=>e.display_hit_test_regions_json(t,l,m),displayVerticalMoveJson:(t,l,m)=>e.display_vertical_move_json(t,l,m),displayRangeRectsJson:(t,l)=>e.display_range_rects_json(t,l),displayRangeRectsRegionJson:(t,l,m,v)=>e.display_range_rects_region_json(t,l,m,v),outlineGlyphJson:(t,l)=>e.outline_glyph_json(t,l),loadState:t=>{w("all"),y(()=>{e.load(t),M.reset();});},seedFromDocx:(t,l)=>We(t,true,l),openDocx:We,beginOpening:t=>{y(()=>{e.begin_opening(t),M.reset();});},seedOpaqueSequences:t=>{w("all"),y(()=>e.seed_opaque_sequences(JSON.stringify(t)));},mediaSource:t=>{if(s||!t.startsWith("media:"))return null;let l=e.media_bytes(t),m=l&&e.media_type(t);return l&&m?{bytes:l,mimeType:m}:null},loadMediaSources:t=>e.load_media_sources(t),mediaDataUrl:Le,mediaScope:()=>Be,materializeDocx:()=>{let t=E,l=e.materialize_docx();return !t||l===void 0?null:b$1(l,Oe(t)).document},loadStories:t=>(w(t.map(l=>l.storyId)),y(()=>JSON.parse(e.load_json(JSON.stringify(t))))),encodeState:()=>e.encode_state(),encodeStateVector:()=>e.encode_state_vector(),encodeStateAsUpdate:t=>t===void 0?e.encode_state():e.encode_diff(t.slice()),applyUpdate:t=>(w("all"),y(()=>JSON.parse(e.apply_update_with_inference(t)))),applyLocalUpdate:t=>{x(),w("all"),y(()=>e.apply_local_update(t));},applyHostUpdate:(t,l)=>{w(l??"all"),y(()=>e.apply_host_update(t));},onUpdate:t=>{if(s)throw new Error("yrs session is destroyed");if(typeof t!="function")throw new TypeError("update listener must be a function");let l=a$1++;n.set(l,t),It();let m=true;return ()=>{m&&(m=false,n.delete(l),_t());}},encodeStickyPosition:t=>({story:t.story,encoded:e.encode_sticky_position(t.story,t.paraId,t.offset)}),resolveStickyPosition:t=>{try{return JSON.parse(e.resolve_sticky_position(t.story,t.encoded))}catch{return null}},setSelection:(t,l=t)=>{if(t.story!==l.story)throw new Error("yrs selection must stay inside one story");e.set_selection(t.story,t.paraId,t.offset,l.paraId,l.offset),u={anchor:{...t},head:{...l}};},selection:()=>(u!==void 0||(u=JSON.parse(e.selection())),Je(u)),encodeSelection:()=>{let t=JSON.parse(e.encoded_selection());return t?{story:t.story,anchor:Uint8Array.from(t.anchor),head:Uint8Array.from(t.head)}:null},resolveSelection:t=>{try{return JSON.parse(e.resolve_encoded_selection(t.story,t.anchor,t.head))}catch{return null}},setCellSelection:t=>e.set_cell_selection(JSON.stringify(t)),cellSelection:()=>JSON.parse(e.cell_selection()),beginUndoCapture:x,addUndoBoundary:()=>e.add_undo_boundary(),setUndoCaptureMode:t=>e.set_undo_capture_mode(t),undoCaptureMode:()=>e.undo_capture_mode(),historyStories:()=>e.history_stories(),undo:()=>y(()=>{let t=e.undo();return t&&w(e.history_stories()),t}),redo:()=>y(()=>{let t=e.redo();return t&&w(e.history_stories()),t}),canUndo:()=>e.can_undo(),canRedo:()=>e.can_redo(),createStory:(t,l,m="Normal",v="left")=>(w(t),y(()=>JSON.parse(e.create_story(t,l,m,v)))),deleteStory:t=>(w(t),y(()=>e.delete_story(t))),insertTable:(t,l,m,v)=>(x(t.story),y(()=>A(JSON.parse(e.insert_table(t.story,t.paraId,t.offset,l,m,v?.name,v?.date))))),insertRow:(t,l,m)=>(x(t.story),y(()=>A(JSON.parse(e.insert_row(JSON.stringify(t),l==="below",m?.name,m?.date))))),insertColumn:(t,l)=>(x(t.story),y(()=>A(JSON.parse(e.insert_column(JSON.stringify(t),l==="right"))))),deleteRow:(t,l)=>(x(t.anchor.story),y(()=>A(JSON.parse(e.delete_row(JSON.stringify(t),l?.name,l?.date))))),deleteColumn:t=>(x(t.anchor.story),y(()=>A(JSON.parse(e.delete_column(JSON.stringify(t)))))),deleteTable:t=>(x(t.story),y(()=>A(JSON.parse(e.delete_table(JSON.stringify(t)))))),mergeCells:t=>(x(t.anchor.story),y(()=>A(JSON.parse(e.merge_cells(JSON.stringify(t)))))),splitCell:(t,l,m)=>(x(t.story),y(()=>A(JSON.parse(e.split_cell(JSON.stringify(t),l,m))))),setCellShading:(t,l)=>(x(t.anchor.story),y(()=>A(JSON.parse(e.set_cell_shading(JSON.stringify(t),l??void 0))))),setCellTextFormat:(t,l)=>(x(t.anchor.story),y(()=>A(JSON.parse(e.set_cell_text_format(JSON.stringify(t),JSON.stringify(l)))))),setCellBorders:(t,l)=>(x(t.anchor.story),y(()=>A(JSON.parse(e.set_cell_borders(JSON.stringify(t),JSON.stringify(l)))))),setColumnWidth:(t,l)=>(x(t.story),y(()=>A(JSON.parse(e.set_column_width(JSON.stringify(t),l))))),setTableWidth:(t,l)=>(x(t.story),y(()=>A(JSON.parse(e.set_table_width(JSON.stringify(t),l))))),insertText:(t,l,m)=>(x(t.story),y(()=>JSON.parse(e.insert_text(t.story,t.paraId,t.offset,l,m?.name,m?.date)))),deleteRange:(t,l)=>(x(t.story),y(()=>JSON.parse(e.delete_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l?.name,l?.date)))),replaceRange:(t,l,m)=>(x(t.story),y(()=>JSON.parse(e.replace_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l,m?.name,m?.date)))),splitParagraph:(t,l)=>(x(t.story),y(()=>JSON.parse(e.split_paragraph(t.story,t.paraId,t.offset,l?.name,l?.date)))),mergeParagraphs:(t,l,m)=>(x(t),y(()=>JSON.parse(e.merge_paragraphs(t,l,m?.name,m?.date)))),toggleMark:(t,l)=>{x(t.story),y(()=>e.toggle_mark(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},formatRange:(t,l)=>{x(t.story),y(()=>e.format_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},setHyperlink:(t,l)=>{x(t.story),y(()=>e.set_hyperlink(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},clearFormatting:t=>{x(t.story),y(()=>e.clear_formatting(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset));},applyParagraphStyle:(t,l,m)=>{x(t.story),y(()=>e.apply_paragraph_style(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l,m?.name,m?.date));},setParagraphAttrs:(t,l,m)=>{x(t.story),y(()=>e.set_paragraph_attrs(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l),m?.name,m?.date));},insertImage:(t,l,m)=>(x(t.story),y(()=>JSON.parse(e.insert_image(t.story,t.paraId,t.offset,JSON.stringify(l),m?.name,m?.date)))),setContentControlValue:(t,l)=>{x(),w("all"),y(()=>e.set_content_control_value(t,JSON.stringify(l)));},setContentControlValueAt:(t,l)=>{x(t.story),typeof l=="string"&&w("all"),y(()=>e.set_content_control_value_at(t.story,t.paraId,t.offset,JSON.stringify(l)));},clearContentControlValue:t=>{x(),w("all"),y(()=>e.clear_content_control_value(t));},setImageGeometry:(t,l)=>{x(),w("all"),y(()=>e.set_image_geometry(t,JSON.stringify(l)));},setImageGeometryAt:(t,l)=>{x(t.story),y(()=>e.set_image_geometry_at(t.story,t.paraId,t.offset,JSON.stringify(l)));},insertPageBreak:t=>{x(t.story),y(()=>e.insert_page_break(t.story,t.paraId,t.offset));},insertSectionBreak:(t,l)=>{x(t.story),y(()=>e.insert_section_break(t.story,t.paraId,t.offset,l));},insertWatermark:(t,l)=>{x(t.story),y(()=>e.insert_watermark(t.story,t.paraId,t.offset,JSON.stringify(l)));},applyRawOps:(t,l)=>{let m=l.some(v=>v.op==="insertEmbed"&&v.kind==="pilcrow"||v.op==="setEmbedAttr"&&v.key==="paraId");w(m?"all":t),y(()=>e.apply_raw_ops(t,JSON.stringify(l)));},applySeedRawOps:(t,l)=>{w(t),y(()=>e.apply_seed_raw_ops(t,JSON.stringify(l)));},setParagraphAttr:(t,l,m)=>{w("all"),y(()=>e.set_paragraph_attr(t,l,JSON.stringify(m??null)));},addComment:(t,l,m,v)=>(w(t.map(B=>B.story)),y(()=>JSON.parse(e.add_comment(vt(t),l,m,JSON.stringify(v??null))))),setCommentRanges:(t,l)=>{x(),y(()=>{e.set_comment_ranges(t,vt(l)),w("all");});},acceptChange:t=>(w("all"),y(()=>JSON.parse(e.accept_change(wt(t))))),rejectChange:t=>(w("all"),y(()=>JSON.parse(e.reject_change(wt(t))))),selectionContext:t=>{let l=JSON.stringify(t);if(g$1?.key===l)return JSON.parse(g$1.json);let m=e.selection_context(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset),v=JSON.parse(m);return g$1={key:l,json:m},v},listRevisions:()=>JSON.parse(e.list_revisions()),resolveComment:t=>JSON.parse(e.resolve_comment(t)),listComments:()=>JSON.parse(e.list_comments()),storyIds:()=>e.story_ids(),hasStory:t=>!Or.test(t)&&e.has_story(t),storyLength:t=>e.story_len(t),storyChecksum:t=>BigInt(e.story_checksum(t)),yrsBlocksForStory:(t,l={})=>{let m=e.yrs_blocks_for_story(t,JSON.stringify(l)),v=JSON.parse(m);return R.set(t,structuredClone(l)),v},paragraphs:t=>JSON.parse(e.paragraphs(t)),searchText:(t,l={})=>{if(!t)return [];let m=l.limit??Number.POSITIVE_INFINITY;if(!Number.isSafeInteger(m)&&m!==Number.POSITIVE_INFINITY||m<0)throw new RangeError("search limit must be a non-negative safe integer");return JSON.parse(e.search_text(t,l.caseSensitive??false,Number.isFinite(m)?Math.min(m,4294967295):void 0))},paragraphSpans:t=>JSON.parse(e.paragraph_spans(t)),storySegments:t=>JSON.parse(e.story_segments(t)),storiesChangedSince:t=>JSON.parse(e.stories_changed_since(t)),storySegmentUnitDigests:t=>JSON.parse(e.story_segment_unit_digests(t)),storySegmentUnits:(t,l)=>JSON.parse(e.story_segment_units(t,Uint32Array.from(l))),tablePayload:(t,l)=>{if(!Number.isInteger(l)||l<0||l>4294967295)return e.story_len(t),null;let m=e.table_payload(t,l);return m===void 0?null:JSON.parse(m)},locateParagraph:(t,l)=>JSON.parse(e.locate_paragraph(t,l)),paragraphIdCount:(t,l)=>e.paragraph_id_count(t,l),paragraphIdentities:()=>JSON.parse(e.paragraph_identities()),persistParagraphIds:()=>(w("all"),y(()=>JSON.parse(e.persist_paragraph_ids()))),resolveParagraphAnchor:t=>JSON.parse(e.resolve_paragraph_anchor(JSON.stringify(t))),storyParagraphIds:t=>JSON.parse(e.story_paragraph_ids(t)),paragraphSavePlan:()=>JSON.parse(e.paragraph_save_plan()),recordSavedParagraphIds:t=>y(()=>JSON.parse(e.record_saved_paragraph_ids(JSON.stringify(t)))),writtenParagraphIds:t=>JSON.parse(e.written_paragraph_ids(t)),exportStructured:t=>JSON.parse(e.export_structured_json(JSON.stringify(t))),exportMarkdown:t=>JSON.parse(e.export_markdown_json(JSON.stringify(t))),exportStructuredWithPages:t=>JSON.parse(e.export_structured_with_pages_json(JSON.stringify(t),void 0)),exportStructuredWithPagesFor:(t,l)=>JSON.parse(e.export_structured_with_pages_json(JSON.stringify(t),l)),exportSnapshotWithPrivateFonts:(t,l,m,v)=>JSON.parse(e.export_snapshot_with_private_fonts_json(t,l,m,JSON.stringify(v))),headings:t=>JSON.parse(e.headings_json(t)),listContentControls:(t={})=>JSON.parse(e.list_content_controls_json(JSON.stringify(t))),findContentControls:(t,l={})=>JSON.parse(e.find_content_controls_json(JSON.stringify(t),JSON.stringify(l))),version:()=>ie??e.version(),readParagraphs:t=>JSON.parse(e.read_paragraphs_json(JSON.stringify(t))),findText:t=>JSON.parse(e.find_text_json(JSON.stringify(t))),validateEdits:t=>JSON.parse(e.validate_edits_json(JSON.stringify(t))),applyEdits:t=>y(()=>{let l=JSON.parse(e.apply_edits_json(JSON.stringify(t)));return l.ok&&l.applied&&w(l.changedStories),l}),proposeChanges:t=>y(()=>M.propose(t)),setProposalStates:t=>M.setStates(t),withdrawProposals:t=>y(()=>M.withdraw(t)),getProposals:()=>M.snapshot(),mirrorWorkerDocument:t=>{ie=t?.version??null,M.mirror(t);},workerDocumentMirrored:()=>ie!==null,onProposalChange:t=>{if(s)throw new Error("yrs session is destroyed");return M.subscribe(t)},formatTextTarget:(t,l)=>(x(Ct(t)),y(()=>JSON.parse(e.format_text_target_json(JSON.stringify(t),JSON.stringify(l))))),commentTextTarget:(t,l)=>(w(Ct(t)),y(()=>JSON.parse(e.comment_text_target_json(JSON.stringify(t),JSON.stringify({...l,body:l.body??null}))))),selectionText:t=>JSON.parse(e.selection_text_json(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset)),destroy:()=>{s||(s=true,he(),n.clear(),M.destroy(),o.length=0,i&&e.clear_update_observer(),e.free());}};return b$2(J,{sourcePackage:()=>E&&ne?{buffer:Oe(E),keys:ne}:null,compareDocx:(t,l,m)=>{w("all");let v=y(()=>{let B=e.compare_docx_json(t,l,m);return M.reset(),B});return E=t.slice(),ne=null,v},finishComparedDocx:t=>e.finish_compared_docx_json(t),failComparedDocx:t=>e.fail_compared_docx_json(t)}),J}async function Jn(e){let r=e?.clientId??Fr(),n=await import('../wasm-6WSIEYWC.mjs');return await n.preloadEditWasm(),Er(n.createEditSession(r),r)}export{le as ResidentEngineWorkerClient,I as ResidentWorkerFailureError,Q as ResidentWorkerOutOfMemoryError,Pe as canUseResidentEngineWorker,xt as captureSessionSave,Jn as createYrsSession,Nn as decodeDocxHostJson,Cr as documentToYrs,ke as editorSaveKeys,Ut as preloadDocxEngine,we as preloadResidentEngineWorker,On as prepareDocxBytes,En as preparedDocxDigest,Wt as retainPreloadedResidentEngineWorker,Mn as sameYrsSelection,Ar as saveYrsDocx,Lt as takePreloadedResidentEngineWorker,Pt as writeSessionSave};
|
|
1
|
+
import {h,i,d as d$2,b as b$3,e,f}from'../chunk-ML6E23W2.mjs';export{g as ownProjectedParagraphs,a as sessionSourcePackage,i as yrsToDocument}from'../chunk-ML6E23W2.mjs';import {d as d$3,a}from'../chunk-5Z22FORG.mjs';export{n as YrsPositionProjection,p as anchorFailure,h as compareYrsLocs,v as computeProposalGeometryMirror,e as createYrsInputPositionMap,k as createYrsLocProjectionFromOutline,l as createYrsPositionProjection,g as displayPositionToYrsLoc,s as hiddenRanges,q as isBodyStory,m as projectYrsDisplayPosition,c as proposalRevisionPreview,u as proposalSetIdentity,i as residentCaretDeviceRect,j as residentCaretSnapshotForFrame,t as resolveAnchorTarget,w as resolveMirroredNavigationTarget,x as resolveNavigationTarget,r as textRangeToRaw,f as yrsLocToDisplayPosition,o as yrsLocToProjectedDisplayPosition}from'../chunk-5Z22FORG.mjs';import'../chunk-EUUIJVM6.mjs';import {b as b$1}from'../chunk-SHVHVJUB.mjs';import'../chunk-LIOWZSE7.mjs';import {d as d$1}from'../chunk-QBMNRD5V.mjs';import {b as b$8}from'../chunk-OBQGPMPQ.mjs';import {d,a as a$1,b as b$6}from'../chunk-47Q2FMFF.mjs';import {b as b$5,p}from'../chunk-LTVVQMHB.mjs';import {b as b$7}from'../chunk-CTBUQRYQ.mjs';import {c,b as b$2}from'../chunk-EBYC3CX7.mjs';import {b as b$4}from'../chunk-UBUTIWXN.mjs';import'../chunk-LT2GCWZ3.mjs';import'../chunk-HPZFJGGM.mjs';import'../chunk-AXFMDV66.mjs';import'../chunk-GKWXOZZH.mjs';export{a as WASM32_MEMORY_LIMIT_BYTES,b as wasmModuleMemories}from'../chunk-HGKSOBXK.mjs';import {b}from'../chunk-TTRUPDAB.mjs';function ve(e,r){let n=c=>{let{content:u,...m}=c;return m},o=c=>[...c??[]].map(([u,m])=>[u,n(m)]),i=c=>(c??[]).map(u=>{let{verbatimXml:m,sourceOrdinal:h,...R}=n(u);return R}),{package:s}=e,a={finalSectionProperties:s.document.finalSectionProperties,sections:s.document.sections?.map(n),headers:o(s.headers),footers:o(s.footers),footnotes:i(s.footnotes),endnotes:i(s.endnotes),relationships:[...s.relationships??[]]},d=c=>JSON.stringify(c,(u,m)=>m instanceof Map?[...m]:m),p=r??s.document.comments??[];return {metadata:d(a),comments:d(p),commentIds:p.map(c=>c.id)}}var jt=new Set(["bootstrap","sync","buildFrame","releasePages","applyInput","applyDelete","proposal","documentRead"]),Ce=6e4;function Ht(){return new Worker(new URL("./residentEngineWorker.mjs",import.meta.url),{type:"module",name:"openooxml-resident-engine"})}var fe=class{constructor(r=Ht()){b(this,"worker",r);b(this,"pending",new Map);b(this,"watchdog",null);b(this,"nextId",1);b(this,"terminalError",null);b(this,"ready",false);b(this,"revision",0);b(this,"remoteVector",null);b(this,"appliedFontsRevision",null);b(this,"bootstrapped",false);b(this,"openedHeapLimit",null);b(this,"bootstraps",0);b(this,"fontRead",null);b(this,"lastSnapshotId",0);b(this,"keepSurfaces",false);b(this,"bootstrapWaiters",[]);b(this,"lastMemory",null);b(this,"answeredFrameEpoch",0);b(this,"retainBuiltPages",false);b(this,"failureListener",null);this.worker.onmessage=n=>{let o=n.data;if(o.memory&&(this.lastMemory=o.memory),o.ok&&o.caret&&(this.answeredFrameEpoch=Math.max(this.answeredFrameEpoch,o.caret.frameEpoch)),o.ok&&o.id>=this.lastSnapshotId){let s=o.proposal?.stateVector??o.stateVector;s&&(this.remoteVector=new Uint8Array(s));}if(!o.ok&&o.terminal){this.fail(o.outOfMemory?new re(o.error,o.memory??[]):new K(o.error));return}this.pending.size>0&&this.armWatchdog();let i=this.pending.get(o.id);i&&(this.pending.delete(o.id),this.pending.size===0&&this.disarmWatchdog(),o.ok?i.resolve(o):i.reject(qt(o.error,o.residentUnavailable)));},this.worker.onerror=n=>{this.fail(new _(`Resident engine worker failed: ${n.message}`));},this.worker.onmessageerror=()=>{this.fail(new _("Resident engine worker returned an unreadable message"));};}isReady(){return this.ready}hasFailed(){return this.terminalError!==null}memory(){return this.lastMemory}layoutRevision(){return this.revision}answeredFrame(){return this.answeredFrameEpoch}setRetainBuiltPages(r){this.retainBuiltPages=r;}onFailure(r){this.failureListener=r;}frameRequestPending(){for(let{type:r}of this.pending.values())if(jt.has(r))return true;return false}remoteStateVector(){return this.remoteVector}syncedFontsRevision(){return this.appliedFontsRevision}bootstrapSent(){return this.bootstrapped}whenBootstrapSent(){return this.bootstrapped?Promise.resolve():new Promise(r=>this.bootstrapWaiters.push(r))}rebootstrap(){this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null,this.lastSnapshotId=0,this.revision=0,this.keepSurfaces=true,this.openedHeapLimit=null;}async open(r,n={}){if(this.openedHeapLimit||this.bootstrapped)throw new _("Resident engine worker already holds a document");let o={bytes:n.heapLimitBytes};this.openedHeapLimit=o;let i;try{let s=new Uint8Array(r);i=await this.request({type:"open",bytes:s.buffer,...n.digest!==void 0?{digest:n.digest}:{},...n.generation!==void 0?{generation:n.generation}:{},...n.heapLimitBytes!==void 0?{heapLimitBytes:n.heapLimitBytes}:{}},[s.buffer]);}catch(s){throw this.openedHeapLimit===o&&(this.openedHeapLimit=null),s}if(i.hostJson===void 0||!i.stateVector)throw new _("Resident engine worker omitted the opened document");return {hostJson:i.hostJson,stateVector:new Uint8Array(i.stateVector)}}async openPreview(r,n,o={}){if(this.openedHeapLimit||this.bootstrapped)throw new _("Resident engine worker already holds a document");let i={bytes:o.heapLimitBytes};this.openedHeapLimit=i;let s;try{let a=new Uint8Array(r);s=await this.request({type:"open",bytes:a.buffer,previewBlocks:n,...o.heapLimitBytes!==void 0?{heapLimitBytes:o.heapLimitBytes}:{}},[a.buffer]);}catch(a){throw this.openedHeapLimit===i&&(this.openedHeapLimit=null),a}if(s.previewRefused)return this.openedHeapLimit===i&&(this.openedHeapLimit=null),null;if(s.hostJson===void 0||!s.stateVector)throw new _("Resident engine worker omitted the opened preview");return {hostJson:s.hostJson,stateVector:new Uint8Array(s.stateVector)}}fontRequirements(r){let n=this.fontRead;if(n&&n.layoutInput===r&&n.id===this.nextId-1)return n.reply;let o=this.request({type:"fontRequirements",layoutInput:r}).then(a=>{if(a.requirementsJson===void 0)throw new _("Resident engine worker omitted the font requirements");return a.requirementsJson}),i={layoutInput:r,id:this.nextId-1,reply:o};this.fontRead=i;let s=()=>{this.fontRead===i&&(this.fontRead=null);};return o.then(s,s),o}async proposal(r){if(!this.bootstrapped)throw new _("Resident engine worker has not laid out its document");let n=await this.request({type:"proposal",operation:r});if(!n.proposal)throw new _("Resident engine worker omitted the proposal result");return {...n.proposal,updates:n.proposal.updates.map(o=>new Uint8Array(o)),stateVector:new Uint8Array(n.proposal.stateVector)}}async documentRead(r){let n=await this.request({type:"documentRead",read:r});if(!n.read)throw new _("Resident engine worker omitted the document read");return n.read}async handOver(){let r=await this.request({type:"encodeState"});if(!r.state||r.version===void 0||!r.proposals)throw new _("Resident engine worker omitted its document handoff");return {state:new Uint8Array(r.state),version:r.version,proposals:r.proposals}}async encodeState(){let r=await this.request({type:"encodeState"});if(!r.state)throw new _("Resident engine worker omitted its state");return new Uint8Array(r.state)}async revisionCount(){let r=await this.request({type:"revisionCount"});if(typeof r.revisionCount!="number"||!Number.isInteger(r.revisionCount)||r.revisionCount<0)throw new _("Resident engine worker omitted a valid revision count");return r.revisionCount}async warm(){let r=this.request({type:"warm",hostModule:true}),n=o=>{if(!this.terminalError)try{this.worker.postMessage({type:"editModule",module:o});}catch{try{this.worker.postMessage({type:"editModule",module:null});}catch{}}};b$1().then(n,()=>n(null)),await r;}async bootstrap(r,n,o={}){if(o.opened&&!this.openedHeapLimit)throw new _("Resident engine worker has no opened document");if(o.opened&&o.heapLimitBytes!==void 0&&o.heapLimitBytes!==this.openedHeapLimit?.bytes)throw new _("Resident engine worker opened its document under another heap limit");let i=r.fontsRevision;this.bootstrapped=true;for(let u of this.bootstrapWaiters.splice(0))u();let s=this.keepSurfaces;this.keepSurfaces=false;let a=++this.bootstraps,d=this.request({type:"bootstrap",snapshot:r,extras:n,expectedFrameEpoch:o.frameEpoch??0,...o.layoutExtras!==void 0?{layoutExtras:o.layoutExtras}:{},...o.displayWindow?{displayWindow:o.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{},...o.provisionalPages!==void 0?{provisionalPages:o.provisionalPages}:{},...s?{keepSurfaces:true}:{},...o.opened?{opened:true}:{},...o.heapLimitBytes!==void 0?{heapLimitBytes:o.heapLimitBytes}:{}},lt(r));this.recordSent(o.stateVector,i);let p;try{p=await d;}catch(u){throw o.opened&&!this.openedHeapLimit&&a===this.bootstraps&&(this.bootstrapped=false,this.remoteVector=null,this.appliedFontsRevision=null),u}let c=U(p);return this.recordSync(p,i),this.ready=true,this.revision=c.layoutRevision,c}async sync(r,n,o,i=false,s={}){let a=r.fontsRevision,d=this.request({type:"sync",snapshot:r,extras:n,expectedFrameEpoch:o,paintCaret:i,...s.layoutExtras!==void 0?{layoutExtras:s.layoutExtras}:{},...s.provisionalPages!==void 0?{provisionalPages:s.provisionalPages}:{},...s.displayWindow?{displayWindow:s.displayWindow,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}},lt(r));this.recordSent(s.stateVector,a);let p=await d,c=U(p);return this.recordSync(p,a),this.ready=true,this.revision=c.layoutRevision,c}async completeLayout(r,n=false,o){let i=await this.request({type:"completeLayout",expectedFrameEpoch:r,paintCaret:n,...o?{sliceBlocks:o}:{}});return i.frame?U(i):null}async buildFrame(r,n,o=false,i){return U(await this.request({type:"buildFrame",extras:r,expectedFrameEpoch:n,paintCaret:o,...i?{displayWindow:i,...this.retainBuiltPages?{retainBuiltPages:true}:{}}:{}}))}async buildPages(r,n,o=false,i=false){let s=await this.request({type:"buildPages",pages:r,expectedFrameEpoch:n,paintCaret:o,...i?{background:true}:{}});return i&&s.pageBuildSuperseded?null:U(s)}async releasePages(r,n,o=false){let i=await this.request({type:"releasePages",pages:r,expectedFrameEpoch:n,paintCaret:o});return i.superseded?{superseded:true}:U(i)}async applyInput(r,n,o,i=false,s=false,a){if(!this.ready)return {applied:false};try{return {applied:!0,...U(await this.request({type:"applyInput",text:r,selection:n,expectedFrameEpoch:o,profile:i,paintCaret:s,...a?{displayWindow:a,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(d){if(at(d))return {applied:false};throw d}}async applyDelete(r,n,o,i=false,s=false,a=1,d){if(!this.ready)return {applied:false};try{return {applied:!0,...U(await this.request({type:"applyDelete",direction:r,count:a,selection:n,expectedFrameEpoch:o,profile:i,paintCaret:s,...d?{displayWindow:d,...this.retainBuiltPages?{retainBuiltPages:!0}:{}}:{}}))}}catch(p){if(at(p))return {applied:false};throw p}}eraseCaret(){if(this.terminalError)return;let n={id:this.nextId++,type:"eraseCaret"};this.worker.postMessage(n);}invalidate(r,n){if(this.terminalError)return;this.ready=false;let o=r.slice(),s={id:this.nextId++,type:"applyUpdate",update:o,selection:n};this.worker.postMessage(s,[o.buffer]);}async attachCanvases(r,n,o,i,s){let a=r.map(d=>d.canvas);await this.request({type:"attachCanvases",pages:r,activePageIds:n,devicePixelRatio:o,zoom:i,caretStyle:s},a);}destroy(){if(this.terminalError)return;let n={id:this.nextId++,type:"destroy"};this.worker.postMessage(n),this.fail(new _("Resident engine worker was destroyed"),false);}request(r,n=[]){if(this.terminalError)return Promise.reject(this.terminalError);let o=this.nextId++;return new Promise((i,s)=>{this.pending.size===0&&this.armWatchdog(),this.pending.set(o,{type:r.type,resolve:i,reject:s}),this.worker.postMessage({...r,id:o},n);})}recordSent(r,n){this.terminalError||(this.lastSnapshotId=this.nextId-1,r&&(this.remoteVector=r.slice()),this.appliedFontsRevision=n);}armWatchdog(){this.disarmWatchdog(),this.watchdog=setTimeout(()=>{this.watchdog=null;let r=this.pending.values().next().value?.type??"a request";this.fail(new _(`Resident engine worker did not answer ${r} within ${Ce}ms`));},Ce);}disarmWatchdog(){this.watchdog!==null&&(clearTimeout(this.watchdog),this.watchdog=null);}recordSync(r,n){r.id>=this.lastSnapshotId&&(this.appliedFontsRevision=n);}fail(r,n=true){let o=this.terminalError===null;this.terminalError=r,this.ready=false,this.disarmWatchdog(),this.worker.terminate();for(let i of this.pending.values())i.reject(r);this.pending.clear();for(let i of this.bootstrapWaiters.splice(0))i();n&&o&&this.failureListener?.(r);}},K=class extends Error{},_=class extends Error{},re=class extends K{constructor(n,o){super(n);b(this,"memory",o);}};function at(e){return e instanceof K&&!(e instanceof re)}function qt(e,r=false){return r?new K(e):new Error(e)}function lt(e){return [e.state.buffer,...e.fonts.flatMap(r=>r instanceof Uint8Array?[r.buffer]:[])]}function U(e){if(!e.frame)throw new _("Resident engine worker response omitted its FrameDelta");if(!e.caret)throw new _("Resident engine worker response omitted its caret snapshot");if(e.selection===void 0)throw new _("Resident engine worker response omitted its selection");return {frame:new Uint8Array(e.frame),...e.pageFrames?{pageFrames:e.pageFrames.map(r=>new Uint8Array(r))}:{},updates:(e.updates??[]).map(r=>new Uint8Array(r)),engineMs:e.engineMs??0,workerTotalMs:e.workerTotalMs??0,engineProfile:e.engineProfile,caret:e.caret,selection:e.selection,caretPainted:e.caretPainted??false,replayMs:e.replayMs??0,replayedPages:e.replayedPages??0,layoutRevision:e.layoutRevision??0,deletedUnits:e.deletedUnits??0,...e.layoutJson!==void 0?{layoutJson:e.layoutJson}:{},...e.layoutProvisional?{layoutProvisional:true}:{}}}function Te(){return typeof Worker<"u"}var E=null;function me(e){e.idleTimer!==null&&clearTimeout(e.idleTimer),e.releaseTimer!==null&&clearTimeout(e.releaseTimer),e.idleTimer=null,e.releaseTimer=null;}function te(e){E===e&&(E=null,me(e),e.client.destroy());}function Ie(){if(!Te())return Promise.resolve();E&&(E.factory!==Worker||E.client.hasFailed())&&te(E),E||(E={client:new fe,factory:Worker,ready:null,owners:0,idleTimer:null,releaseTimer:null});let e=E;return e.ready||(e.ready=e.client.warm().catch(r=>{throw e.client.hasFailed()?te(e):e.ready=null,r})),me(e),e.owners===0&&(e.idleTimer=setTimeout(()=>te(e),Ce)),e.ready}function Vt(){let e=E;if(!e)return ()=>{};me(e),e.owners+=1;let r=false;return ()=>{r||(r=true,e.owners-=1,e.owners===0&&E===e&&(e.releaseTimer=setTimeout(()=>te(e),0)));}}function zt(){let e=E;return e?!Te()||e.factory!==Worker||e.client.hasFailed()?(te(e),null):(E=null,me(e),e.client):null}async function $t(){let e=[import('../wasm-KSZTTO3B.mjs').then(n=>n.preloadEditWasm()),import('../wasm-QI7MWC5D.mjs').then(n=>n.preloadOpcWasm()),import('../parseWasm-BESKFFA3.mjs').then(n=>n.preloadParseWasm()),import('../wasm-JPDPN2B2.mjs').then(n=>n.preloadLayoutWasm())],r;try{r=Ie();}catch(n){r=Promise.reject(n);}await Promise.all([...e,r]);}function De(e,r,n,o,i,s){let a=r?.pPr;if(!r?.tblStylePr?.some(C=>C.pPr))return a;let d=e.formatting?.look??r.tblPr?.look,p=(C,A)=>d?.[C]??(Number.parseInt(d?.value??(d?"0":"04A0"),16)&A)!==0,c=p("firstRow",32),u=p("lastRow",64),m=p("firstColumn",128),h=p("lastColumn",256),R=e.rows[n].formatting?.gridBefore??0;o+=R,i+=R;let b=!!c&&n===0,g=!!u&&n===e.rows.length-1,S=!!m&&o===0,k=!!h&&i===s,I=e.formatting?.styleRowBandSize??r.tblPr?.styleRowBandSize??1,x=e.formatting?.styleColBandSize??r.tblPr?.styleColBandSize??1,v=[];!p("noHBand",512)&&!b&&!g&&I>0&&v.push(Math.floor((n-+!!c)/I)%2===0?"band1Horz":"band2Horz"),!p("noVBand",1024)&&!S&&!k&&x>0&&v.push(Math.floor((o-+!!m)/x)%2===0?"band1Vert":"band2Vert");for(let[C,A]of [["firstCol",S],["lastCol",k],["firstRow",b],["lastRow",g],["nwCell",b&&S],["neCell",b&&k],["swCell",g&&S],["seCell",g&&k]])A&&v.push(C);for(let C of v)a=b$6(a,r.tblStylePr.find(A=>A.type===C)?.pPr);return a}function dt(e){return Math.max(e.columnWidths?.length??0,...e.rows.map(r=>r.cells.reduce((n,o)=>n+(o.formatting?.gridSpan??1),(r.formatting?.gridBefore??0)+(r.formatting?.gridAfter??0))))}function N(e){if(Array.isArray(e))return e.map(N);if(e!==null&&typeof e=="object"){let r={};for(let[n,o]of Object.entries(e))o!=null&&(r[n]=N(o));return r}return e}var Kt={styleId:"pStyle",_sectionProperties:"sectPr"},Gt=new Set(["paraId","textId","renderedPageBreakBefore","numPrFromStyle"]);function ut(e){let r={};for(let[n,o]of Object.entries(e))Gt.has(n)||o===null||o===void 0||(r[Kt[n]??n]=N(o));return r}var Xt=new Set(["columnWidths"]);function ge(e,r=new Set){let n={};for(let[o,i]of Object.entries(e))r.has(o)||i===null||i===void 0||(n[o]=N(i));return n}function pt(e){return ge(e,Xt)}function ct(e){let r=e.columnWidths;return Array.isArray(r)?r.map(N):[]}function ft(e){return ge(e)}function mt(e,r){let n=ge(e);return r&&(n.header=true),n}function _e(e,r,n,o){return `${e}:t${r}:r${n}c${o}`}function gt(e,r){return `${e}:sdt${r}`}function yt(e){return ge(e)}function ye(e){return `hf:${e}`}function ht(e){return `fn:${e}`}function bt(e){return `en:${e}`}function Qt(e){let r=e.package.settings?.compatibilityFlags?.compatibilityMode;return typeof r=="number"&&Number.isFinite(r)?Math.trunc(r):12}var Zt=new Set(["bold","italic","superscript","subscript","allCaps","smallCaps","emboss","imprint","textShadow","textOutline","hidden","rtl"]);function X(e){if(e==null)return "null";if(Array.isArray(e))return `[${e.map(X).join(",")}]`;if(typeof e=="object"){let r=e;return `{${Object.keys(r).sort().map(n=>`${JSON.stringify(n)}:${X(r[n])}`).join(",")}}`}return JSON.stringify(e)}function er(e,r){if(!e||!r)return e;let n=r.resolveRunStyle(e.styleId);return n?a$1(n,e):e}function xt(e){if(!e)return [];let r=[],n=(a,d={})=>r.push({name:a,attrs:d});e.bold&&n("bold"),e.italic&&n("italic"),e.underline&&e.underline.style!=="none"&&n("underline",{style:e.underline.style,color:e.underline.color??null}),(e.strike||e.doubleStrike)&&n("strike",{double:e.doubleStrike||false}),e.color&&!e.color.auto&&n("textColor",{rgb:e.color.rgb??null,themeColor:e.color.themeColor??null,themeTint:e.color.themeTint??null,themeShade:e.color.themeShade??null});let o=e.shading?.fill,i=(!e.shading?.pattern||e.shading.pattern==="clear")&&o?.rgb&&!o.auto?p(o.rgb):void 0,s=e.highlight&&e.highlight!=="none"?e.highlight:i;return s&&n("highlight",{color:s}),(e.fontSize!=null||e.fontSizeCs!=null)&&n("fontSize",{size:e.fontSize??null,sizeCs:e.fontSizeCs??null}),e.fontFamily&&n("fontFamily",{ascii:e.fontFamily.ascii??null,hAnsi:e.fontFamily.hAnsi??null,eastAsia:e.fontFamily.eastAsia??null,cs:e.fontFamily.cs??null,asciiTheme:e.fontFamily.asciiTheme??null,hAnsiTheme:e.fontFamily.hAnsiTheme??null,eastAsiaTheme:e.fontFamily.eastAsiaTheme??null,csTheme:e.fontFamily.csTheme??null}),e.vertAlign==="superscript"?n("superscript"):e.vertAlign==="subscript"&&n("subscript"),e.allCaps&&n("allCaps"),e.smallCaps&&n("smallCaps"),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&n("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null}),e.emboss&&n("emboss"),e.imprint&&n("imprint"),e.shadow&&n("textShadow"),e.emphasisMark&&e.emphasisMark!=="none"&&n("emphasisMark",{type:e.emphasisMark}),e.outline&&n("textOutline"),e.hidden&&n("hidden"),e.rtl&&n("rtl"),e.snapToGrid===false&&r.push({name:"snapToGrid",attrs:{}}),e.effect&&e.effect!=="none"&&n("textEffect",{effect:e.effect}),e.modernEffects&&n("modernTextEffects",{effects:e.modernEffects}),e.styleId&&n("runStyle",{styleId:e.styleId}),r}function Fe(e){let r={};for(let n of e)n.name==="comment"||n.name==="footnoteRef"||(Zt.has(n.name)?r[n.name]=true:n.name==="snapToGrid"?r.snapToGrid=false:n.name==="highlight"?r.highlight=n.attrs.color:n.name==="insertion"||n.name==="deletion"?r[n.name==="insertion"?"ins":"del"]=N({id:n.attrs.revisionId,author:n.attrs.author,date:n.attrs.date}):r[n.name]=N(n.attrs));return r}function tr(e){return e.filter(r=>r.name!=="hyperlink"&&r.name!=="comment").map(r=>`${r.name}:${JSON.stringify(r.attrs)}`).sort().join("|")}function rr(e,r){return [...e.filter(n=>n.name!==r.name),r]}function ne(e,r){return {kind:"text",text:e,attrs:Fe(r),pmSize:e.length,marks:[...r]}}function D(e,r,n=[],o=1){return {kind:"embed",embedKind:e,payload:r,attrs:Fe(n),pmSize:o,marks:[...n]}}function Pt(e,r,n){let o=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=xt(a$1(a$1(r,o),e.formatting)),s=e.formatting?.styleId,a=s?n?.getStyle(s)?.name:void 0;if([s,a].some(d=>/^(?:Followed)?Hyperlink$/i.test(d??""))){for(let[d,p]of [["color","textColor"],["underline","underline"]])if(e.formatting?.[d]===void 0&&o?.[d]!==void 0){let c=i.find(u=>u.name===p);c&&(c.attrs.inheritedHyperlink=true);}}return i}function nr(e){let r=e.size?.width?b$7(e.size.width):void 0,n=e.size?.height?b$7(e.size.height):void 0,o=e.wrap.type,i=e.wrap.wrapText,s=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?i==="left"?a="right":i==="right"?a="left":s==="left"||s==="right"?a=s:a="none":a="none";let d=o==="inline"?"inline":o==="topAndBottom"?"block":b$8(o)||a&&a!=="none"?"float":"block",p=[];e.transform?.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform?.flipH&&p.push("scaleX(-1)"),e.transform?.flipV&&p.push("scaleY(-1)");let c,u,m;if(e.outline?.width){c=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`);let h={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};m=e.outline.style&&h[e.outline.style]||"solid";}return N({src:e.src||"",alt:e.alt??null,title:e.title??null,width:r??null,height:n??null,rId:e.rId??null,wrapType:o,displayMode:d,cssFloat:a??null,transform:p.length>0?p.join(" "):null,distTop:e.wrap.distT!=null?b$7(e.wrap.distT):null,distBottom:e.wrap.distB!=null?b$7(e.wrap.distB):null,distLeft:e.wrap.distL!=null?b$7(e.wrap.distL):null,distRight:e.wrap.distR!=null?b$7(e.wrap.distR):null,position:e.position?{relativeHeight:e.position.relativeHeight,behindDoc:e.position.behindDoc,horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0}:null,borderWidth:c??null,borderColor:u??null,borderColorValue:e.outline?.color??null,borderStyle:m??null,wrapText:i??null,hlinkHref:e.hlinkHref??null,cropTop:e.crop?.top??null,cropRight:e.crop?.right??null,cropBottom:e.crop?.bottom??null,cropLeft:e.crop?.left??null,shapeType:e.shapeType??null,opacity:e.opacity??null,effectExtentTop:e.padding?.top!=null?b$7(e.padding.top):null,effectExtentBottom:e.padding?.bottom!=null?b$7(e.padding.bottom):null,effectExtentLeft:e.padding?.left!=null?b$7(e.padding.left):null,effectExtentRight:e.padding?.right!=null?b$7(e.padding.right):null,layoutInCell:e.layoutInCell??null,allowOverlap:e.allowOverlap??null})}function or(e){return {shapeJson:JSON.stringify(e)}}function sr(e){return N({chartJson:JSON.stringify(e),chartType:e.chartType??null,title:e.title??null,width:e.size?.width?b$7(e.size.width):320,height:e.size?.height?b$7(e.size.height):220,rId:e.rId??null,path:e.path??null})}function G(e,r){let n="",o,i=e.type==="simpleField"?e.content:e.fieldResult;for(let d of i)if(d.type==="run"){for(let p of d.content)p.type==="text"&&(n+=p.text);!o&&d.formatting&&(o=d.formatting);}let s=o??(e.type==="complexField"?e.formatting:void 0),a=e.fieldTree?.displayMode??"result";return {payload:{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false,displayMode:a,hasCachedResult:n.length>0,fieldData:JSON.stringify(e),modelKind:"field"},marks:xt(a$1(r,s))}}function z(e){let r=new Set,n=[[e,false]];for(;n.length>0;){let[o,i]=n.pop();if(Array.isArray(o))for(let s=o.length-1;s>=0;s--)n.push([o[s],i]);else if(o!==null&&typeof o=="object"){let s=o;if(o!==e&&(s.type==="complexField"||s.type==="simpleField")&&typeof s.instruction=="string"){let d=he(s.instruction);d!==void 0&&r.add(d);}if(s.type==="hyperlink"&&!i)for(let d of Q(o))r.add(d);let a=i||s.type==="hyperlink";for(let d of Object.keys(s).sort().reverse())n.push([s[d],a]);}}return [...r]}function Q(e){let r=[e],n=[],o=[],i=s=>{if(Array.isArray(s))for(let a=s.length-1;a>=0;a--)r.push(s[a]);};for(;r.length>0;){let s=r.pop();if(s){if((s.type==="simpleField"||s.type==="complexField")&&typeof s.instruction=="string"){let a=he(s.instruction);a!==void 0&&o.push(a);}switch(s.type){case "hyperlink":i(s.structuredChildren??s.children);break;case "inlineSdt":case "insertion":case "deletion":case "moveFrom":case "moveTo":i(s.content);break;case "simpleField":i(s.structuredResult?.inline??s.fieldTree?.result?.inline??s.content);break;case "complexField":i(s.structuredResult?.inline??s.fieldTree?.result?.inline??s.fieldResult),i(s.structuredCode?.inline??s.fieldTree?.code?.inline??s.fieldCode);break;case "run":if(!Array.isArray(s.content))break;for(let a of s.content){if(!a)continue;let d;if(a.type==="fieldChar")a.charType==="begin"?n.push(""):a.charType==="separate"&&n.length>0?(d=n[n.length-1],n[n.length-1]=void 0):a.charType==="end"&&(d=n.pop());else if(a.type==="instrText"){let c=n.length-1;n[c]!==void 0&&(n[c]+=typeof a.text=="string"?a.text:"");}let p=d===void 0?void 0:he(d);p!==void 0&&o.push(p);}break}}}return o}function he(e){let r=e.matchAll(/"([^"]*)(?:"|$)|([^\p{White_Space}]+)/gu),n=r.next().value,o=r.next().value,i=n?.[1]??n?.[2],s=o?.[1]??o?.[2];if(!(!i||!/^[sS][eE][qQ]$/.test(i)||s===void 0||s.startsWith("\\")))return s.toLowerCase()}function be(e){return {display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""}}function ir(e){return {name:"hyperlink",attrs:{href:e.href||(e.anchor?`#${e.anchor}`:""),tooltip:e.tooltip??null,rId:e.rId??null}}}function ar(e,r,n,o,i){let s=e.structuredResult?.inline??[],d=[...(e.type==="complexField"?e.structuredCode?.inline??[]:[]).map((h,R)=>({child:h,index:-R-1})),...s.map((h,R)=>({child:h,index:R}))];if(e.type!=="complexField"||!d.some(({child:h})=>h.type==="hyperlink"||h.type==="simpleField")){i.push(...z(e));let h=G(e,r);return [D("field",h.payload,h.marks)]}let p=[],c=[];d.forEach(({child:h,index:R})=>{if(h.type!=="hyperlink"&&h.type!=="simpleField")return;i.push(...h.type==="hyperlink"?Q(h):z(h));let b=h.type==="simpleField"?G(h,r):null,g=h.type==="hyperlink"?ie(h,r,n,i):[D("field",b.payload,b.marks)];c.push({index:R,items:g.map(S=>S.kind==="text"?{kind:"text",text:S.text,attributes:S.attrs}:{kind:"embed",embedKind:S.embedKind,payload:S.payload,attributes:S.attrs})});for(let S of g)S.attrs={...S.attrs,fieldResult:{id:o,index:R}};p.push(...g);});let u={...e,fieldResult:s.filter(h=>h.type==="run")},m=G(u,r);return i.push(...z(he(e.instruction??"")===void 0?u:e)),m.payload.fieldData=JSON.stringify(e),m.payload.resultProjection={id:o,children:c},p.push(D("field",m.payload,m.marks)),p}function St(e,r,n){let o={name:"footnoteRef",attrs:{id:String(e),noteType:r}},i=[...n,o];return D("noteRef",r==="endnote"?{endnoteRefId:e}:{footnoteRefId:e},i)}function Ye(e){return e.filter(r=>r.name==="insertion"||r.name==="deletion")}function Oe(e,r,n){if((e.type==="drawing"||e.type==="shape"||e.type==="chart")&&r.some(o=>o.name==="hidden")){let o=e.type==="drawing"?e.image:e.type==="shape"?e.shape:e.chart;n.push(...z(o));}switch(e.type){case "text":return e.text?[ne(e.text,r)]:[];case "tab":return [ne(" ",r)];case "break":return e.breakType===void 0||e.breakType==="textWrapping"?[D("break",{},r)]:[];case "softHyphen":return [ne("\xAD",r)];case "noBreakHyphen":return [ne("\u2011",r)];case "symbol":{let o=Number.parseInt(e.char,16);if(!Number.isInteger(o)||o<0||o>1114111)return [];let i={name:"fontFamily",attrs:{ascii:e.font||null,hAnsi:e.font||null,eastAsia:e.font||null,cs:e.font||null,asciiTheme:null,hAnsiTheme:null,eastAsiaTheme:null,csTheme:null}};return [ne(String.fromCodePoint(o),rr(r,i))]}case "commentReference":return [D("field",{fieldType:"COMMENT",instruction:"",displayText:"",fieldKind:"simple",fldLock:false,dirty:false,displayMode:"result",hasCachedResult:false,modelKind:"commentReference",...e.id!==void 0?{commentId:e.id}:{}})];case "drawing":return [D("image",nr(e.image),Ye(r))];case "horizontalRule":return [D("horizontalRule",{rule:e.rule},r)];case "shape":return [D("shape",or(e.shape),Ye(r))];case "chart":return [D("chart",sr(e.chart),Ye(r))];case "footnoteRef":return [St(e.id,"footnote",r)];case "endnoteRef":return [St(e.id,"endnote",r)];default:return []}}function se(e,r,n,o,i=[]){let s=[...Pt(e,r,n),...i];return e.content.flatMap(a=>Oe(a,s,o))}function ie(e,r,n,o,i=[]){let s=[],a=ir(e);for(let d of e.structuredChildren??e.children)if(d.type==="run"){let p=[...Pt(d,r,n),...i,a];for(let c of d.content)s.push(...Oe(c,p,o));}else if(d.type==="simpleField"||d.type==="complexField"){o.push(...z(d));let p=G(d,r);s.push(D("field",p.payload,[...p.marks,...i,a]));}else d.type==="mathEquation"?s.push(D("math",be(d),[...i,a])):d.type==="inlineSdt"&&(i.some(p=>p.name==="insertion"||p.name==="deletion")||b$4(d))&&s.push(D("sdt",Se(d,r,n,o),[...i,a],2));return s}function lr(e,r,n){return {name:r,attrs:{revisionId:e.id,author:e.author,date:e.date??null,isMovePair:n}}}function Ee(e,r,n,o,i=false){let s=e.type==="insertion"||e.type==="moveTo"?"insertion":"deletion",a=lr(e.info,s,e.type==="moveFrom"||e.type==="moveTo"),d=[];for(let p of e.content)if(p.type==="run")d.push(...se(p,r,n,o,[a]));else if(p.type==="hyperlink"){o.push(...Q(p));let c=ie(p,r,n,o,[a]);d.push(...c);}else if(i||p.type==="inlineSdt"||b$4(p)){let c=dr(p,r,n,o,i),u=Fe([a]);d.push(...c.map(m=>({...m,attrs:{...u,...m.attrs},marks:m.marks.some(h=>h.name===a.name)?m.marks:[...m.marks,a]})));}return d}function dr(e,r,n,o,i){if(e.type==="run")return se(e,r,n,o);if(e.type==="hyperlink")return o.push(...Q(e)),ie(e,r,n,o);if(e.type==="simpleField"||e.type==="complexField"){o.push(...z(e));let s=G(e,r);return [D("field",s.payload,s.marks)]}return e.type==="inlineSdt"?[D("sdt",Se(e,r,n,o),[],2)]:e.type==="mathEquation"?[D("math",be(e))]:Ee(e,r,n,o,i)}function Se(e$1,r,n,o){let i=[],s=a=>{if(a.kind==="text"){if((a.text===" "?"tab":"text")==="tab"){i.push({kind:"tab",attrs:a.attrs});return}let p=i[i.length-1];p&&"text"in p&&X(p.attrs)===X(a.attrs)?p.text+=a.text:i.push({kind:"text",text:a.text,attrs:a.attrs});return}i.push({kind:a.embedKind,payload:a.payload,attrs:a.attrs});};for(let a of e$1.content)if(a.type==="run")se(a,r,n,o).forEach(s);else if(a.type==="hyperlink")o.push(...Q(a)),ie(a,r,n,o).forEach(s);else if(a.type==="simpleField"||a.type==="complexField"){o.push(...z(a));let d=G(a,r);s(D("field",d.payload,d.marks));}else a.type==="inlineSdt"?s(D("sdt",Se(a,r,n,o))):a.type==="mathEquation"?s(D("math",be(a))):Ee(a,r,n,o,true).forEach(s);return N({...e(e$1.properties),propertiesJson:JSON.stringify(e$1.properties),content:i})}function ur(e,r,n){let o=r?r.resolveParagraphStyle(e.formatting?.styleId).runFormatting:void 0;return a$1(o,n)}function pr(e){let r=[];for(let n of e.content)n.type==="footnoteRefMark"?r.push("footnote"):n.type==="endnoteRefMark"&&r.push("endnote");return r}function wt(e){return e.map(r=>{if(r.kind==="text")return r.text;let n=r.payload.footnoteRefId??r.payload.endnoteRefId;return String(n??"")}).join("")}function Rt(e){return e.type!=="break"?null:e.breakType==="page"||e.breakType==="column"?e.breakType:null}function cr(e){if(!e.content.some(o=>Rt(o)!==null))return [];let r=[],n=0;for(let o of e.content){let i=Rt(o);if(i!==null){r.push({offset:n,type:i});continue}n+=wt(Oe(o,[],[])).length;}return r}function fr(e,r,n){let o=se(e,r,n,[]);if(o.some(p=>p.kind!=="text"&&p.embedKind!=="noteRef"))return null;let i=o.map(p=>tr(p.marks));if(i.some(p=>p!==i[0]))return null;let s=pr(e),a=cr(e),d=i[0];return {text:wt(o),...s.length>0?{noteMarks:s}:{},...a.length>0?{breaks:a}:{},...d!==void 0?{marksKey:d}:{},...e.formatting?{formatting:e.formatting}:{},...e.propertyChanges?{propertyChanges:e.propertyChanges}:{}}}function mr(e,r,n,o,i){let s=e.formatting,a=s?.styleId,d=s?.indentFirstLine===0?void 0:s?.indentFirstLine,p=d??e.listRendering?.indentFirstLine??s?.indentFirstLine,c=d===void 0&&e.listRendering?.indentFirstLine!==void 0?e.listRendering.hangingIndent:s?.hangingIndent??e.listRendering?.hangingIndent,u={paraId:e.paraId??null,textId:e.textId??null,styleId:a??null,numPr:s?.numPr??null,numPrFromStyle:s?.numPrFromStyle??null,listNumFmt:e.listRendering?.numFmt??null,listIsBullet:e.listRendering?.isBullet??null,listMarker:e.listRendering?.marker??null,listMarkerHidden:e.listRendering?.markerHidden||null,listMarkerFontFamily:e.listRendering?.markerFontFamily||null,listMarkerFontSize:e.listRendering?.markerFontSize||null,listMarkerBold:e.listRendering?.markerBold??null,listMarkerItalic:e.listRendering?.markerItalic??null,listMarkerColor:e.listRendering?.markerColor??null,listMarkerSuffix:e.listRendering?.markerSuffix||null,listLevelNumFmts:e.listRendering?.levelNumFmts||null,listAbstractNumId:e.listRendering?.abstractNumId??null,listStartOverride:e.listRendering?.startOverride??null,_originalFormatting:s??null};if(r){let b=r.resolveParagraphStyle(a,i),g=b.paragraphFormatting;u.alignment=s?.alignment??g?.alignment??null,u.spaceBefore=s?.spaceBefore??g?.spaceBefore??null,u.spaceAfter=s?.spaceAfter??g?.spaceAfter??null,u.spaceBeforeLines=s?.spaceBeforeLines??g?.spaceBeforeLines??null,u.spaceAfterLines=s?.spaceAfterLines??g?.spaceAfterLines??null,u.beforeAutospacing=s?.beforeAutospacing??g?.beforeAutospacing??null,u.afterAutospacing=s?.afterAutospacing??g?.afterAutospacing??null,u.lineSpacing=s?.lineSpacing??g?.lineSpacing??null,u.lineSpacingRule=s?.lineSpacingRule??g?.lineSpacingRule??null,u.spacingExplicit=s?.spacingExplicit||null,u.indentLeft=s?.indentLeft??e.listRendering?.indentLeft??g?.indentLeft??null,u.indentRight=s?.indentRight??g?.indentRight??null;let k=s?.numPr?.numId===0&&g?.numPr&&g.numPr.numId!==0?void 0:g;u.indentFirstLine=p??k?.indentFirstLine??null,u.hangingIndent=c??k?.hangingIndent??false,u.borders=s?.borders??g?.borders??null,u.shading=s?.shading??g?.shading??null,u.tabs=s?.tabs??g?.tabs??null,u.pageBreakBefore=s?.pageBreakBefore??g?.pageBreakBefore??null,u.keepNext=s?.keepNext??g?.keepNext??null,u.keepLines=s?.keepLines??g?.keepLines??null,u.widowControl=s?.widowControl??g?.widowControl??null,u.contextualSpacing=s?.contextualSpacing??g?.contextualSpacing??null,u.snapToGrid=s?.snapToGrid??g?.snapToGrid??null,u.autoSpaceDE=s?.autoSpaceDE??g?.autoSpaceDE??null,u.autoSpaceDN=s?.autoSpaceDN??g?.autoSpaceDN??null,u.outlineLevel=s?.outlineLevel??g?.outlineLevel??null,u.bidi=s?.bidi??g?.bidi??null;let I=r.getDefaultCharacterStyle()?.rPr,x=I?a$1(b.runFormatting,I):b.runFormatting;u.defaultTextFormatting=a$1(x,er(s?.runProperties,r))??null,!s?.numPr&&g?.numPr&&g.numPr.numId!==0&&(u.numPr=g.numPr,u.numPrFromStyle=g.numPr);}else u.alignment=s?.alignment??null,u.spaceBefore=s?.spaceBefore??null,u.spaceAfter=s?.spaceAfter??null,u.spaceBeforeLines=s?.spaceBeforeLines??null,u.spaceAfterLines=s?.spaceAfterLines??null,u.beforeAutospacing=s?.beforeAutospacing??null,u.afterAutospacing=s?.afterAutospacing??null,u.lineSpacing=s?.lineSpacing??null,u.lineSpacingRule=s?.lineSpacingRule??null,u.spacingExplicit=s?.spacingExplicit||null,u.indentLeft=s?.indentLeft??e.listRendering?.indentLeft??null,u.indentRight=s?.indentRight??null,u.indentFirstLine=p??null,u.hangingIndent=c??false,u.borders=s?.borders??null,u.shading=s?.shading??null,u.tabs=s?.tabs??null,u.pageBreakBefore=s?.pageBreakBefore??null,u.keepNext=s?.keepNext??null,u.keepLines=s?.keepLines??null,u.widowControl=s?.widowControl??null,u.snapToGrid=s?.snapToGrid??null,u.autoSpaceDE=s?.autoSpaceDE??null,u.autoSpaceDN=s?.autoSpaceDN??null,u.outlineLevel=s?.outlineLevel??null,u.bidi=s?.bidi??null,u.defaultTextFormatting=s?.runProperties??null;if(e.sectionProperties){u._sectionProperties=e.sectionProperties;let b=e.sectionProperties.sectionStart;(b==="nextPage"||b==="continuous"||b==="oddPage"||b==="evenPage"||b==="nextColumn")&&(u.sectionBreakType=b);}e.renderedPageBreakBefore&&(u.renderedPageBreakBefore=true),hr(e)&&(u.pageBreakBeforeRun=true),e.pPrIns&&(u.pPrIns={revisionId:e.pPrIns.id,author:e.pPrIns.author,date:e.pPrIns.date??null}),e.pPrDel&&(u.pPrDel={revisionId:e.pPrDel.id,author:e.pPrDel.author,date:e.pPrDel.date??null}),e.propertyChanges?.length&&(u.pPrChange=e.propertyChanges);let m=[],h=0,R=0;for(let b of e.content)if(b.type==="bookmarkStart")m.push({id:b.id,name:b.name,kind:"start",offset:R,...b.colFirst!==void 0?{colFirst:b.colFirst}:{},...b.colLast!==void 0?{colLast:b.colLast}:{}});else if(b.type==="bookmarkEnd")m.push({id:b.id,kind:"end",offset:R});else {let g=gr(b);for(let S=0;S<g;S+=1)R+=n[h]?.pmSize??0,h+=1;}return m.length>0&&(u.bookmarks=m),o?.length&&(u._originalRunBoundaries=o),u}var vt=new WeakMap;function gr(e){return vt.get(e)??0}function yr(e,r,n,o){let i=[],s=[],a=[],d=[],p=ur(e,r,n);for(let[u,m]of e.content.entries()){let h=i.length;if(m.type==="commentRangeStart"||m.type==="commentRangeEnd")a.push({unit:h,start:m.type==="commentRangeStart",id:m.id});else if(m.type==="run"){let R=fr(m,p,r);R&&d?d.push(R):d=void 0,i.push(...se(m,p,r,s));}else if(m.type==="hyperlink"){d=void 0,s.push(...Q(m));let R=ie(m,p,r,s);i.push(...R);}else m.type==="simpleField"||m.type==="complexField"?(d=void 0,i.push(...ar(m,p,r,u,s))):m.type==="inlineSdt"?(d=void 0,i.push(D("sdt",Se(m,p,r,s),[],2))):m.type==="insertion"||m.type==="deletion"||m.type==="moveFrom"||m.type==="moveTo"?(d=void 0,i.push(...Ee(m,p,r,s))):m.type==="mathEquation"?(d=void 0,i.push(D("math",be(m)))):m.type!=="bookmarkStart"&&m.type!=="bookmarkEnd"&&m.type!=="rawXml"&&(d=void 0);vt.set(m,i.length-h);}let c=mr(e,r,i,d,o);return {units:i,commentMarks:a,ppr:ut(c),opaqueSequences:s}}function oe(e,r){for(let n of e.content)n.type==="break"&&n.breakType==="page"?r.push("pageBreak"):(n.type!=="text"||n.text.length>0)&&r.push("visible");}function Me(e,r){for(let n of e)if(n.type==="run")oe(n,r);else if(n.type==="hyperlink")for(let o of n.children)o.type==="run"&&oe(o,r);else if(n.type==="simpleField")for(let o of n.content)o.type==="run"&&oe(o,r);else if(n.type==="complexField")for(let o of [...n.fieldCode,...n.fieldResult])oe(o,r);else if(n.type==="inlineSdt")Me(n.content,r);else if(n.type==="insertion"||n.type==="deletion"||n.type==="moveFrom"||n.type==="moveTo")for(let o of n.content)o.type==="run"&&oe(o,r);else n.type==="mathEquation"&&r.push("visible");}function hr(e){let r=[];return Me(e.content,r),r[0]==="pageBreak"}function br(e){let r=[];Me(e.content,r);let n=false,o=false;for(let i of r)if(i==="pageBreak"){if(o||n)return true;n=true;}else o=true;return false}function Sr(e){let r=new Map,n=new Map;return e.rows.forEach((o,i)=>{let s=0,a=o.cells.map(p=>{let c=s;return s+=p.formatting?.gridSpan??1,{column:c,vMerge:p.formatting?.vMerge,key:`${i}-${c}`}});if(a.length>0&&a.every(p=>p.vMerge==="continue"&&n.has(p.column))){for(let p of a)n.delete(p.column),r.set(p.key,{rowSpan:1,skip:false});return}for(let p of a)if(p.vMerge==="restart")n.set(p.column,i),r.set(p.key,{rowSpan:1,skip:false});else if(p.vMerge==="continue"){let c=n.get(p.column);if(c===void 0)r.set(p.key,{rowSpan:1,skip:false});else {let u=r.get(`${c}-${p.column}`);u&&(u.rowSpan+=1),r.set(p.key,{rowSpan:1,skip:true});}}else n.delete(p.column),r.set(p.key,{rowSpan:1,skip:false});}),r}function Ae(e){return {revisionId:e.id,author:e.author,date:e.date??null}}function Rr(e,r,n,o,i,s){let a=r?{top:n?r.top:r.insideH,bottom:o?r.bottom:r.insideH,left:i?r.left:r.insideV,right:s?r.right:r.insideV}:void 0;return a||e?.borders?{...a??{},...e?.borders??{}}:void 0}function kt(e,r){let n=e.formatting,o=b$5(n?.shading?.fill,r.theme),i=n?.width?.value??r.gridWidth,s=n?.width?.type??(r.gridWidth!==void 0?"pct":null),a={colspan:n?.gridSpan??1,rowspan:r.rowspan,width:i??null,widthType:s,verticalAlign:n?.verticalAlign??null,backgroundColor:o??null,borders:Rr(n,r.tableBorders,r.firstRow,r.lastRow,r.firstColumn,r.lastColumn)??null,margins:n?.margins?{top:n.margins.top?.value,bottom:n.margins.bottom?.value,left:n.margins.left?.value??(r.tableBidi?n.margins.end?.value:n.margins.start?.value),right:n.margins.right?.value??(r.tableBidi?n.margins.start?.value:n.margins.end?.value)}:r.defaultMargins??null,textDirection:n?.textDirection??null,noWrap:n?.noWrap??false,_originalFormatting:n??null,_originalResolvedFill:o??null};if(e.structuralChange){let d=e.structuralChange,p=Ae(d.info);d.type==="tableCellInsertion"?a.cellMarker={kind:"ins",info:p}:d.type==="tableCellDeletion"?a.cellMarker={kind:"del",info:p}:d.type==="tableCellMerge"&&(a.cellMarker={kind:"merge",info:p,vMerge:d.vMerge??"cont",...d.vMergeOrig?{vMergeOrig:d.vMergeOrig}:{}});}return e.propertyChanges?.length&&(a.tcPrChange=e.propertyChanges),{attrs:mt(a,r.isHeader),content:e.content.length>0?e.content:[{type:"paragraph",content:[]}]}}function kr(e,r,n,o,i,s,a,d,p){let c={height:e.formatting?.height?.value??null,heightRule:e.formatting?.heightRule??null,isHeader:!!e.formatting?.header,_originalFormatting:e.formatting??null};e.structuralChange&&(e.structuralChange.type==="tableRowInsertion"?c.trIns=Ae(e.structuralChange.info):e.structuralChange.type==="tableRowDeletion"&&(c.trDel=Ae(e.structuralChange.info))),e.propertyChanges?.length&&(c.trPrChange=e.propertyChanges);let u=r.columnWidths,m=u?.reduce((g,S)=>g+S,0)??0,h=u?.length??Math.max(0,...r.rows.map(g=>g.cells.reduce((S,k)=>S+(k.formatting?.gridSpan??1),0))),R=0,b=[];return e.cells.forEach(g=>{let S=g.formatting?.gridSpan??1,k=R,I=o.get(`${n}-${k}`),x;if(u&&m>0){let v=0;for(let C=0;C<S&&k+C<u.length;C+=1)v+=u[k+C];x=Math.round(v/m*100);}R+=S,!I?.skip&&b.push({paragraphFormatting:De(r,d,n,k,R,p),...kt(g,{isHeader:n===0&&!!r.formatting?.look?.firstRow,rowspan:I?.rowSpan??1,gridWidth:x,firstRow:n===0,lastRow:n===r.rows.length-1,firstColumn:k===0,lastColumn:R===h,tableBorders:i,defaultMargins:s,theme:a,tableBidi:!!r.formatting?.bidi})});}),b.length===0&&b.push({paragraphFormatting:De(r,d,n,0,h,p),...kt({formatting:h>1?{gridSpan:h}:void 0,content:[{type:"paragraph",content:[]}]},{isHeader:n===0&&!!r.formatting?.look?.firstRow,rowspan:1,gridWidth:m>0?100:void 0,firstRow:n===0,lastRow:n===r.rows.length-1,firstColumn:true,lastColumn:true,tableBorders:i,defaultMargins:s,theme:a,tableBidi:!!r.formatting?.bidi})}),{attrs:ft(c),cells:b}}function xr(e,r,n,o){let i=r?.getDefaultTableStyle(),s=e.formatting?.styleId,a=s??i?.styleId,d=a?r?.getStyle(a):void 0,p=e.formatting?.borders??d?.tblPr?.borders??i?.tblPr?.borders,c=[e.formatting?.cellMargins,d?.tblPr?.cellMargins??i?.tblPr?.cellMargins].filter(C=>C!=null),u=(...C)=>{for(let A of c)for(let J of C){let ae=A[J]?.value;if(ae!=null)return ae}},[m,h]=e.formatting?.bidi?["end","start"]:["start","end"],R=c.length>0?{top:u("top"),bottom:u("bottom"),left:u("left",m),right:u("right",h)}:void 0,b=[],g=new Set,S=d;for(;S?.basedOn&&b.length<32&&!g.has(S.basedOn);)g.add(S.basedOn),b.unshift(S.basedOn),S=r?.getStyle(S.basedOn);let k={...e.formatting??{},styleCascade:{...s?{selectedStyleId:s}:{},...i?.styleId?{defaultStyleId:i.styleId}:{},...b.length>0?{basedOnStyleIds:b}:{}}},I={styleId:s??null,width:e.formatting?.width?.value??null,widthType:e.formatting?.width?.type??null,justification:e.formatting?.justification??null,columnWidths:e.columnWidths??null,tableLayout:e.formatting?.layout??null,floating:e.formatting?.floating??null,cellMargins:R??null,look:e.formatting?.look??null,bidi:e.formatting?.bidi||null,compatibilityMode:o===12?null:o,_originalFormatting:k};e.propertyChanges?.length&&(I.tblPrChange=e.propertyChanges);let x=Sr(e),v=dt(e);return {attrs:I,rows:e.rows.map((C,A)=>kr(C,e,A,x,p,R,n,d??i,v))}}function Pr(e$1){return yt(e(e$1))}function wr(e){let r=(s,a,d)=>{if(d<=a)return;let p=e.commentCoverage.get(s),c=p[p.length-1];c&&c[1]===a?c[1]=d:p.push([a,d]);},n=[],o=0,i=0;for(let s=0;s<=e.units.length;s+=1){for(;e.commentMarks[i]?.unit===s;){let d=e.commentMarks[i++];if(d.start){if(n.some(p=>p.id===d.id))continue;e.commentCoverage.has(d.id)||e.commentCoverage.set(d.id,[]),n.push({id:d.id,start:o});}else {let p=n.findIndex(c=>c.id===d.id);if(p!==-1){let[c]=n.splice(p,1);r(c.id,c.start,o);}}}let a=e.units[s];if(a){if(a.kind==="embed"&&a.embedKind==="pilcrow")for(let d of n)d.paragraphEnd??(d.paragraphEnd=o);o+=a.kind==="text"?a.text.length:1;}}for(let s of n)r(s.id,s.start,s.paragraphEnd??o);for(let[s,a]of e.commentCoverage)a.length===0&&e.commentCoverage.delete(s);}function Ne(e,r,n){if(d$2(n))return null;if(n.type==="paragraph"){let o=e.paragraph++;return !n.repeatedParaId&&n.paraId||`${r}:p${o}`}return n.type==="table"?`${r}:t${e.table++}`:gt(r,e.sdt++)}function vr(e){return /^\d+$/.test(e.trim())}function Cr(e){let r=e.structuredResult?.blocks??[],n=r[r.length-1];return !n||n.type!=="paragraph"||(n.content?.length??0)>0?null:r.length}function Tr(e,r,n,o,i,s){for(let a of e){if(a.kind!=="embed"||a.embedKind!=="field")continue;let d=a.payload.instruction;if(typeof d!="string"||!vr(d))continue;let p=a.payload.fieldData;if(typeof p!="string")continue;let c;try{c=JSON.parse(p);}catch{continue}let u=Cr(c);if(u===null||o+1+u>n.length)continue;let m={...i},h=[];for(let R=0;R<u;R+=1){let b=n[o+1+R],g=Ne(m,r,b);g!==null&&(b.type==="table"&&s.set(o+1+R,g),h.push(g));}h.length>0&&(a.payload.fieldResultBlocks=h);}}function Ir(e){return !d$2(e)&&e.type==="paragraph"&&(e.content?.some(r=>r.type==="run"&&r.content.some(n=>n.type==="fieldChar"&&n.charType==="separate"))??false)}function Dr(e,r,n,o,i){for(let s of e){if(s.kind!=="embed"||s.embedKind!=="field")continue;let a=s.payload.fieldData;if(typeof a!="string"||!a.includes('"blocks"'))continue;let d;try{d=JSON.parse(a);}catch{continue}if(!d||typeof d!="object")continue;let p=d.structuredCode?.blocks,c=d.structuredResult?.blocks,u=Array.isArray(p)?p.length:0,m=Array.isArray(c)&&c.length>0,h;if(u===0){let k=n[o+1];if(!m||!k||!Ir(k))continue;h=0;}else h=m?u:u-1;if(o+1+h+1>n.length)continue;let R=n.slice(o+1,o+1+h+1);if(R.some(k=>d$2(k)||k.type!=="paragraph"))continue;let b={...i},g=[];for(let k of R){let I=Ne(b,r,k);I!==null&&g.push(I);}let S=g.pop();S!==void 0&&(s.payload.fieldCodeMarks=g,s.payload.fieldCodeTarget=S);}}function V(e,r,n,o){let i={storyId:r,units:[],commentMarks:[],commentCoverage:new Map};e.plans.push(i);let s=n.length>0,a=s?[...n]:[{type:"paragraph",content:[]}],d={paragraph:0,table:0,sdt:0},p=new Map,c=null;for(let[u,m]of a.entries()){if(d$2(m))continue;let h=d.table,R=Ne(d,r,m);if(R===null)continue;if(m.type==="paragraph"){let g=yr(m,e.styleResolver,o.extraRunFormatting,o.tableParagraphFormatting);e.opaqueSequences.push(...g.opaqueSequences),Tr(g.units,r,a,u,d,p),Dr(g.units,r,a,u,d);let S=i.units.length;i.commentMarks.push(...g.commentMarks.map(k=>({...k,unit:S+k.unit}))),i.units.push(...g.units),i.units.push(D("pilcrow",{...g.ppr,...s&&m.paraId?{sourceParaId:m.paraId}:{},...s?{}:{paraOrigin:"synthetic"},paraId:R})),o.includePageBreaks&&br(m)&&i.units.push(D("pageBreak",{})),c="paragraph";continue}if(m.type==="table"){let g=xr(m,e.styleResolver,e.theme,e.compatibilityMode),S=g.rows.map((I,x)=>({trPr:I.attrs,cells:I.cells.map((v,C)=>({tcPr:v.attrs,story:_e(r,h,x,C)}))})),k=p.get(u);i.units.push(D("table",{tblPr:pt(g.attrs),grid:ct(g.attrs),rows:S,...k===void 0?{}:{blockId:k}})),g.rows.forEach((I,x)=>{I.cells.forEach((v,C)=>{V(e,_e(r,h,x,C),v.content,{includePageBreaks:false,appendBodyTail:false,seedComments:o.seedComments,extraRunFormatting:v.extraRunFormatting,tableParagraphFormatting:v.paragraphFormatting});});}),c="table";continue}let b=R;i.units.push(D("blockSdt",{...Pr(m.properties),story:b})),V(e,b,m.content,{includePageBreaks:o.includePageBreaks,appendBodyTail:false,seedComments:o.seedComments,tableParagraphFormatting:o.tableParagraphFormatting}),c="blockSdt";}o.appendBodyTail&&(c==="table"||c==="blockSdt")&&i.units.push(D("pilcrow",{hangingIndent:false,paraId:`${r}:p${d.paragraph}`,paraOrigin:"synthetic"})),o.seedComments&&wr(i);}function _r(e){let r=[{op:"delete",index:0,len:1}],n=0,o="",i={},s=X(i),a=()=>{o&&(r.push({op:"insert",index:n,text:o,attrs:i}),n+=o.length,o="");};for(let d of e)if(d.kind==="text"){let p=X(d.attrs);o&&p!==s&&a(),i=d.attrs,s=p,o+=d.text;}else a(),r.push({op:"insertEmbed",index:n,kind:d.embedKind,payload:d.payload,attrs:d.attrs}),n+=1;return a(),r}function Yr(e,r){let n=_r(r.units);for(let[o,i]of r.commentCoverage)n.push({op:"setComment",id:String(o),ranges:i,author:"",date:"",body:null});e.applySeedRawOps(r.storyId,n);}function Ar(e,r,n={}){h(e,"all");let o={styleResolver:r.package.styles?d(r.package.styles):null,theme:r.package.theme??null,plans:[],compatibilityMode:Qt(r),opaqueSequences:[]};V(o,"body",r.package.document.content,{includePageBreaks:true,appendBodyTail:true,seedComments:true});for(let[i,s]of r.package.headers??[])V(o,ye(i),s.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let[i,s]of r.package.footers??[])o.plans.some(a=>a.storyId===ye(i))||V(o,ye(i),s.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of r.package.footnotes??[])V(o,ht(i.id),i.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of r.package.endnotes??[])V(o,bt(i.id),i.content,{includePageBreaks:false,appendBodyTail:false,seedComments:true});for(let i of o.plans)e.createStory(i.storyId,"","Normal","left");for(let i of o.plans)Yr(e,i);e.seedOpaqueSequences(o.opaqueSequences),e.beginOpening(n.generation);}function Fr(e){let r=e.package;return [r.document.content,...[...r.headers?.values()??[]].map(n=>n.content),...[...r.footers?.values()??[]].map(n=>n.content),...(r.footnotes??[]).map(n=>n.content),...(r.endnotes??[]).map(n=>n.content)]}var Or="word/comments.xml";function Ct(e){if(Array.isArray(e)&&e.length>0&&e.every(n=>n?.type==="paragraph"))return e;let r=typeof e=="string"?e:"";return [{type:"paragraph",formatting:{},content:r?[{type:"run",formatting:{},content:[{type:"text",text:r}]}]:[]}]}function Er(e,r){let n=r.package.document.comments??[],o=new Map(e.listComments().map(c=>[c.id,c])),i=false,s=n.map(c=>{let u=o.get(String(c.id));return o.delete(String(c.id)),!u||!u.author&&!u.date&&u.body==null?c:(i=true,{...c,...u.author?{author:u.author}:{},...u.date?{date:u.date}:{},...u.body==null?{}:{content:Ct(u.body)}})}),a=new Set(n.map(c=>c.id)),d=new Map,p=Math.max(0,...a)+1;for(let c of o.values()){i=true;let u=/^\d+$/.test(c.id)?Number(c.id):Number.NaN;if(!Number.isSafeInteger(u)||a.has(u)){for(;a.has(p);)p+=1;u=p;}a.add(u),String(u)!==c.id&&d.set(u,c.id),s.push({id:u,author:c.author,...c.date?{date:c.date}:{},content:Ct(c.body)});}return {comments:s,sessionIds:d,changed:i}}function Mr(e,r){let n=new Map(r.paragraphs.flatMap(s=>s.session?[[s.session.paraId,s]]:[])),o=[],i=s=>{for(let a of s)if(a.type==="table")for(let d of a.rows)for(let p of d.cells)i(p.content);else if(a.type==="blockSdt")i(a.content);else if(a.type==="paragraph"&&a.paraId){let d=f(a),p=d===void 0?void 0:n.get(d);if(!p?.session||!p.persisted)continue;o.push({session:p.session,persisted:{...p.persisted,paraId:a.paraId}});}};for(let s of Fr(e))i(s);return o}function Be(e,r){let n=[],o=false;for(let i of e){let s=i;if(i.type==="paragraph")s=r(i);else if(i.type==="table"){let a=i.rows.map(d=>{let p=d.cells.map(c=>{let u=Be(c.content,r);return u===c.content?c:{...c,content:u}});return p.every((c,u)=>c===d.cells[u])?d:{...d,cells:p}});a.some((d,p)=>d!==i.rows[p])&&(s={...i,rows:a});}else if(i.type==="blockSdt"){let a=Be(i.content,r);a!==i.content&&(s={...i,content:a});}o||(o=s!==i),s&&n.push(s);}return o?n:e}function Tt(e,r){let n=s=>{let a=Be(s.content,r);return a===s.content?s:{...s,content:a}},o=e.package,i=s=>s&&new Map([...s].map(([a,d])=>[a,n(d)]));return {...e,package:{...o,document:n(o.document),headers:i(o.headers),footers:i(o.footers),footnotes:o.footnotes?.map(n),endnotes:o.endnotes?.map(n)}}}function Nr(e,r){let n=new Set(r.paragraphs.flatMap(({origin:o,session:i})=>o==="synthetic"&&i?[i.paraId]:[]));return n.size===0?e:Tt(e,o=>{let i=f(o);return o.content.length===0&&i!==void 0&&n.has(i)?null:o})}function Br(e,r){let n=new Map(r.flatMap(({paragraphs:o})=>o.map(([i,s])=>[s,i])));return n.size===0?e:Tt(e,o=>{let i=f(o),s=i===void 0?void 0:n.get(i);return s===void 0||o.sourceOrdinal===s?o:{...o,sourceOrdinal:s}})}function It(e){return {identities:e.paragraphIdentities(),plan:e.paragraphSavePlan()}}async function Dt(e,r,n,o,i={},s=()=>true,a=false,d=s){let p=(n.plan.splicedParts??[]).filter(({part:x})=>d(x)),c={assignments:n.plan.assignments,patchedParts:n.plan.patchedParts.filter(({part:x})=>s(x)),...p.length===0?{}:{splicedParts:p.map(({part:x,sha256:v,paragraphs:C,changed:A})=>({part:x,sha256:v,paragraphs:C.map(([J])=>J),changed:A}))}},u=Nr(r,n.identities),m=Mr(u,n.identities),{buffer:h}=await d$1(Br(u,p),o,i,void 0,void 0,c,a),R=new Uint8Array(h),b=e.writtenParagraphIds(R),g=(x,v)=>b[x]?.includes(v.toUpperCase())??false,S=m.filter(({persisted:x})=>g(x.story.partUri,x.paraId)),k=new Set(e.recordSavedParagraphIds([...S.map(({session:x,persisted:v})=>[x.paraId,v.paraId]),...c.assignments.filter(({part:x,paraId:v})=>g(`/${x}`,v)).map(({part:x,ordinal:v,paraId:C})=>[`/${x}#${v}`,C])]).map(([x,v])=>`${x}\0${v}`)),I=({session:x,persisted:v})=>k.has(`${x.paraId}\0${v.paraId}`);return {bytes:R,paragraphs:S.filter(x=>!I(x)),conflicts:S.filter(I)}}async function Wr(e,r={}){let n=e.materializeDocx();if(!n?.originalBuffer)throw new Error("saveYrsDocx requires a session opened from DOCX bytes");let o=It(e),i$1=Er(e,n),s=i(e,i$1.changed?{...n,package:{...n.package,document:{...n.package.document,comments:i$1.comments}}}:n,{commentIds:i$1.sessionIds});return Dt(e,s,o,n.originalBuffer,r,a=>!i$1.changed||a!==Or)}var Le=new WeakMap;async function qn(e){let r=new Uint8Array(e),n=globalThis.crypto?.subtle;if(!n)return r;try{let o=new Uint8Array(await n.digest("SHA-256",r));Le.set(r,Array.from(o,i=>i.toString(16).padStart(2,"0")).join(""));}catch{}return r}function Vn(e){return Le.get(e)}function zn(e,r){return !e||!r?e===r:e.anchor.story===r.anchor.story&&e.anchor.paraId===r.anchor.paraId&&e.anchor.offset===r.anchor.offset&&e.head.story===r.head.story&&e.head.paraId===r.head.paraId&&e.head.offset===r.head.offset}function Jr(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}function _t(e){return JSON.stringify("revisionId"in e?{revisionId:e.revisionId}:{story:e.story,startPara:e.start.paraId,startOffset:e.start.offset,endPara:e.end.paraId,endOffset:e.end.offset})}function Yt(e){return JSON.stringify(e.map(r=>({story:r.story,startPara:r.start.paraId,startOffset:r.start.offset,endPara:r.end.paraId,endOffset:r.end.offset})))}function At(e){return e.kind==="search"?e.within.story:e.story}function We(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function $n(e,r){return Je(e,r)}function Je(e,r){let n=JSON.parse(e);if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError("DOCX host metadata must be an object");let o=n;if(!Array.isArray(o.referencedFonts)||!o.referencedFonts.every(a=>typeof a=="string"))throw new TypeError("DOCX host referencedFonts must be a string array");let i=o.unusedScriptFonts??[];if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))throw new TypeError("DOCX host unusedScriptFonts must be a string array");let s=c(o.envelope,We(r));return {document:s.document,referencedFonts:o.referencedFonts,unusedScriptFonts:i,...o.wholeBody===true?{wholeBody:true}:{},embeddedFonts:s.embeddedFonts,...s.fontTableRelationshipsXml===void 0?{}:{fontTableRelationshipsXml:s.fontTableRelationshipsXml}}}var Lr=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;function Ur(e,r){let n=new Map,o=[],i=false,s=false,a$1=0,d=0,p=false,c=false,u,m=null,h$1=[],R=new Map,b=new Map,g=null,S=false,k=0,I=false,x=null,v=t=>(t.layoutJson!==void 0&&x!==null&&(g=x,S=true,k+=1,I=false,x=null),t),C=0,A=null,J=null,ae=()=>{u=void 0,m=null;},Ue=()=>{if(!(s||p||d!==0)){p=true;try{for(;!s&&o.length>0;){let t=o.shift();if(!t)break;for(let[l,f]of [...n]){if(s)return;if(n.get(l)===f)try{f(t.update.slice(),t.origin);}catch{}}}}finally{p=false,s&&(o.length=0);}}},le=false,Z=false,y=t=>{if(le)throw new Error("A document preview is display-only");return je(t)},je=t=>{ae(),d+=1;try{return t()}finally{d-=1,d===0&&Ue();}},He=t=>t?{anchor:{...t.anchor},head:{...t.head}}:null,P=t=>{c||(e.track_undo(),c=true),t!==void 0&&(e.select_story(t),w(t));},w=t=>{h(B,t);},F=t=>(w(t.createdStoryIds),w(t.deletedStoryIds),w(t.changedStoryIds),t),de=()=>(u!==void 0?u:JSON.parse(e.selection()))?.head.story??"all",Ft=()=>{i||(e.set_update_observer((t,l)=>{l!==0&&l!==1||(o.push({update:t.slice(),origin:l===0?"local":"remote"}),Ue());}),i=true);},Ot=()=>{!i||n.size>0||s||(o.length=0,e.clear_update_observer(),i=false);},Re=new Map,qe=0,ke=()=>{Re.clear(),qe+=1;},Ve=(t,l,f={})=>{let T=t.slice();w("all"),ke();let W=y(()=>{e.set_media_tokens(f.mediaTokens===true);let j=e.open_docx(T,l,f.generation,Le.get(t));return M.reset(),j}),$=$e(Je(W,T));return A=T,J=ve($.document),Z=false,$},ze=t=>{if(s||!t.startsWith("media:"))return null;let l=Re.get(t);return l===void 0&&(l=e.media_data_url(t)??null,Re.set(t,l)),l},$e=t=>(a(t.document.package.document.comments,ze),t),ue=null,M=d$3({version:()=>e.version(),resolveParagraphAnchor:t=>B.resolveParagraphAnchor(t),findText:t=>B.findText(t),readParagraphs:t=>B.readParagraphs(t),applyEdits:t=>B.applyEdits(t),listRevisions:()=>B.listRevisions(),revisionStamps:t=>JSON.parse(e.revision_stamps_json(JSON.stringify(t))),settleRevisions:(t,l)=>{let f=B.storiesChangedSince(Number.MAX_SAFE_INTEGER).revision;e.settle_revisions_json(JSON.stringify({accept:t,reject:l})),w(B.storiesChangedSince(f).stories);},...typeof e.begin_shared_reads=="function"&&typeof e.end_shared_reads=="function"?{sharedReads:t=>{e.begin_shared_reads();try{return t()}finally{e.end_shared_reads();}}}:{}}),B={clientId:r,openDocxPreview:(t,l)=>{w("all"),ke();let f=je(()=>e.open_docx_preview(t,l));return f===void 0?null:(le=true,Z=true,$e(Je(f,t)))},isDisplayOnly:()=>le,markDisplayOnly:()=>{le=true,Z=true;},setPartialDocument:t=>{Z=t,e.set_partial_document(t);},layoutDocumentWithRegionsPrefixRetainedJson:(t,l)=>{let f=e.layout_document_with_regions_prefix_retained_json(t,l);return g=t,S=true,k+=1,I=false,f},registerFont:t=>{let l=e.register_measure_font(t);return h$1.push(t.slice()),C+=1,l},registerSubstituteFont:(t,l)=>{let f=e.register_substitute_measure_font(t,l);return f===t||(h$1.push({substituteOf:t,family:l}),C+=1),f},clearFonts:()=>{e.clear_measure_fonts(),h$1.length=0,b.clear(),C+=1;},measureParagraphJson:t=>{let l=e.measure_paragraph_json(t);return b.set(t,t),l},layoutDocumentJson:t=>{let l=e.layout_document_json(t);return g=t,S=false,k+=1,I=false,l},layoutFontRequirementsJson:t=>e.layout_font_requirements_json(t),layoutDocumentWithRegionsJson:t=>{let l=e.layout_document_with_regions_json(t);return g=t,S=true,k+=1,I=false,l},layoutDocumentWithRegionsRetainedJson:t=>{let l=e.layout_document_with_regions_retained_json(t);return g=t,S=true,k+=1,I=false,l},beginRegionLayout:t=>(x=t,v(JSON.parse(e.begin_region_layout(t)))),resumeRegionLayout:t=>v(JSON.parse(e.resume_region_layout(t))),adoptResidentWorkerLayout:t=>(g=t,S=true,k+=1,I=true,k),residentLayoutInWorker:()=>I,retainedKernelInputsJson:t=>{if(I)throw new Error("the retained layout was computed in the resident worker");if(t!==k)throw new Error(`retained layout revision mismatch: expected ${t}, current ${k}`);return e.retained_kernel_inputs_json()},buildDisplayListJson:t=>e.build_display_list_json(t),resetFrameBase:()=>{s||e.reset_frame_base();},buildDisplayListFrame:(t,l)=>e.build_display_list_frame(t,l),setDisplayWindow:(t,l)=>e.set_display_window(t,l),setDisplayRetainBuiltPages:t=>e.set_display_retain_built_pages(t),setWindowedIncrementalBuilds:t=>e.set_windowed_incremental_builds(t),buildDisplayPagesFrame:(t,l)=>e.build_display_pages_frame(Uint32Array.from(t),l),releaseDisplayPagesFrame:(t,l)=>{let f=e.release_display_pages_frame(Uint32Array.from(t),l);return f.length===0?null:f},residentCaretSnapshot:()=>JSON.parse(e.resident_caret_snapshot_json()),applyInput:(t,l)=>(P(),w(de()),y(()=>e.apply_input(t,l))),applyDelete:(t,l,f=1)=>(P(),w(de()),y(()=>e.apply_delete(t,l,f))),residentDeletedUnits:()=>e.resident_deleted_units(),applyInputProfiled:(t,l)=>{P(),w(de());let f=y(()=>e.apply_input_profiled(t,l)),T=JSON.parse(e.apply_input_profile_json());return {frame:f,profile:T}},applyDeleteProfiled:(t,l,f=1)=>{P(),w(de());let T=y(()=>e.apply_delete_profiled(t,l,f)),W=JSON.parse(e.apply_input_profile_json());return {frame:T,profile:W}},residentWorkerSnapshot:t=>{if(!g||!S&&R.size===0)return null;let l=ue!==null,f=l?"null":e.selection(),T=l?void 0:e.media_sources_json(),W=t?.knownFontsRevision===C,$=null;if(!l&&t?.knownStateVector)try{$=e.encode_diff(t.knownStateVector.slice());}catch{$=null;}return {clientId:r,...l?{workerAuthoritative:true}:{},state:l?new Uint8Array(0):$??e.encode_state(),selection:JSON.parse(f),fonts:W?[]:h$1.map(j=>j instanceof Uint8Array?j.slice():{...j}),fontsRevision:C,renderInputs:[...R].map(([j,Et])=>({story:j,env:structuredClone(Et)})),measureInputs:[...b.values()],layoutInput:g,layoutWithRegions:S,layoutRevision:k,...Z?{partialDocument:true}:{},...T?{mediaSources:T}:{}}},residentWorkerProbe:()=>!g||!S&&R.size===0?null:{layoutRevision:k},displayHitTestRegionsJson:(t,l,f)=>e.display_hit_test_regions_json(t,l,f),displayVerticalMoveJson:(t,l,f)=>e.display_vertical_move_json(t,l,f),displayRangeRectsJson:(t,l)=>e.display_range_rects_json(t,l),displayRangeRectsRegionJson:(t,l,f,T)=>e.display_range_rects_region_json(t,l,f,T),outlineGlyphJson:(t,l)=>e.outline_glyph_json(t,l),loadState:t=>{w("all"),y(()=>{e.load(t),M.reset();});},seedFromDocx:(t,l)=>Ve(t,true,l),openDocx:Ve,beginOpening:t=>{y(()=>{e.begin_opening(t),M.reset();});},seedOpaqueSequences:t=>{w("all"),y(()=>e.seed_opaque_sequences(JSON.stringify(t)));},mediaSource:t=>{if(s||!t.startsWith("media:"))return null;let l=e.media_bytes(t),f=l&&e.media_type(t);return l&&f?{bytes:l,mimeType:f}:null},loadMediaSources:t=>e.load_media_sources(t),mediaDataUrl:ze,mediaScope:()=>qe,materializeDocx:()=>{let t=A,l=e.materialize_docx();return !t||l===void 0?null:b$2(l,We(t)).document},loadStories:t=>(w(t.map(l=>l.storyId)),y(()=>JSON.parse(e.load_json(JSON.stringify(t))))),encodeState:()=>e.encode_state(),encodeStateVector:()=>e.encode_state_vector(),encodeStateAsUpdate:t=>t===void 0?e.encode_state():e.encode_diff(t.slice()),applyUpdate:t=>(w("all"),y(()=>JSON.parse(e.apply_update_with_inference(t)))),applyLocalUpdate:t=>{P(),w("all"),y(()=>e.apply_local_update(t));},applyHostUpdate:(t,l)=>{w(l??"all"),y(()=>e.apply_host_update(t));},onUpdate:t=>{if(s)throw new Error("yrs session is destroyed");if(typeof t!="function")throw new TypeError("update listener must be a function");let l=a$1++;n.set(l,t),Ft();let f=true;return ()=>{f&&(f=false,n.delete(l),Ot());}},encodeStickyPosition:t=>({story:t.story,encoded:e.encode_sticky_position(t.story,t.paraId,t.offset)}),resolveStickyPosition:t=>{try{return JSON.parse(e.resolve_sticky_position(t.story,t.encoded))}catch{return null}},setSelection:(t,l=t)=>{if(t.story!==l.story)throw new Error("yrs selection must stay inside one story");e.set_selection(t.story,t.paraId,t.offset,l.paraId,l.offset),u={anchor:{...t},head:{...l}};},selection:()=>(u!==void 0||(u=JSON.parse(e.selection())),He(u)),encodeSelection:()=>{let t=JSON.parse(e.encoded_selection());return t?{story:t.story,anchor:Uint8Array.from(t.anchor),head:Uint8Array.from(t.head)}:null},resolveSelection:t=>{try{return JSON.parse(e.resolve_encoded_selection(t.story,t.anchor,t.head))}catch{return null}},setCellSelection:t=>e.set_cell_selection(JSON.stringify(t)),cellSelection:()=>JSON.parse(e.cell_selection()),beginUndoCapture:P,addUndoBoundary:()=>e.add_undo_boundary(),setUndoCaptureMode:t=>e.set_undo_capture_mode(t),undoCaptureMode:()=>e.undo_capture_mode(),historyStories:()=>e.history_stories(),undo:()=>y(()=>{let t=e.undo();return t&&w(e.history_stories()),t}),redo:()=>y(()=>{let t=e.redo();return t&&w(e.history_stories()),t}),canUndo:()=>e.can_undo(),canRedo:()=>e.can_redo(),createStory:(t,l,f="Normal",T="left")=>(w(t),y(()=>JSON.parse(e.create_story(t,l,f,T)))),deleteStory:t=>(w(t),y(()=>e.delete_story(t))),insertTable:(t,l,f,T)=>(P(t.story),y(()=>F(JSON.parse(e.insert_table(t.story,t.paraId,t.offset,l,f,T?.name,T?.date))))),insertRow:(t,l,f)=>(P(t.story),y(()=>F(JSON.parse(e.insert_row(JSON.stringify(t),l==="below",f?.name,f?.date))))),insertColumn:(t,l)=>(P(t.story),y(()=>F(JSON.parse(e.insert_column(JSON.stringify(t),l==="right"))))),deleteRow:(t,l)=>(P(t.anchor.story),y(()=>F(JSON.parse(e.delete_row(JSON.stringify(t),l?.name,l?.date))))),deleteColumn:t=>(P(t.anchor.story),y(()=>F(JSON.parse(e.delete_column(JSON.stringify(t)))))),deleteTable:t=>(P(t.story),y(()=>F(JSON.parse(e.delete_table(JSON.stringify(t)))))),mergeCells:t=>(P(t.anchor.story),y(()=>F(JSON.parse(e.merge_cells(JSON.stringify(t)))))),splitCell:(t,l,f)=>(P(t.story),y(()=>F(JSON.parse(e.split_cell(JSON.stringify(t),l,f))))),setCellShading:(t,l)=>(P(t.anchor.story),y(()=>F(JSON.parse(e.set_cell_shading(JSON.stringify(t),l??void 0))))),setCellTextFormat:(t,l)=>(P(t.anchor.story),y(()=>F(JSON.parse(e.set_cell_text_format(JSON.stringify(t),JSON.stringify(l)))))),setCellBorders:(t,l)=>(P(t.anchor.story),y(()=>F(JSON.parse(e.set_cell_borders(JSON.stringify(t),JSON.stringify(l)))))),setColumnWidth:(t,l)=>(P(t.story),y(()=>F(JSON.parse(e.set_column_width(JSON.stringify(t),l))))),setTableWidth:(t,l)=>(P(t.story),y(()=>F(JSON.parse(e.set_table_width(JSON.stringify(t),l))))),insertText:(t,l,f)=>(P(t.story),y(()=>JSON.parse(e.insert_text(t.story,t.paraId,t.offset,l,f?.name,f?.date)))),deleteRange:(t,l)=>(P(t.story),y(()=>JSON.parse(e.delete_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l?.name,l?.date)))),replaceRange:(t,l,f)=>(P(t.story),y(()=>JSON.parse(e.replace_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l,f?.name,f?.date)))),splitParagraph:(t,l)=>(P(t.story),y(()=>JSON.parse(e.split_paragraph(t.story,t.paraId,t.offset,l?.name,l?.date)))),mergeParagraphs:(t,l,f)=>(P(t),y(()=>JSON.parse(e.merge_paragraphs(t,l,f?.name,f?.date)))),toggleMark:(t,l)=>{P(t.story),y(()=>e.toggle_mark(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},formatRange:(t,l)=>{P(t.story),y(()=>e.format_range(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},setHyperlink:(t,l)=>{P(t.story),y(()=>e.set_hyperlink(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l)));},clearFormatting:t=>{P(t.story),y(()=>e.clear_formatting(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset));},applyParagraphStyle:(t,l,f)=>{P(t.story),y(()=>e.apply_paragraph_style(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,l,f?.name,f?.date));},setParagraphAttrs:(t,l,f)=>{P(t.story),y(()=>e.set_paragraph_attrs(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset,JSON.stringify(l),f?.name,f?.date));},insertImage:(t,l,f)=>(P(t.story),y(()=>JSON.parse(e.insert_image(t.story,t.paraId,t.offset,JSON.stringify(l),f?.name,f?.date)))),setContentControlValue:(t,l)=>{P(),w("all"),y(()=>e.set_content_control_value(t,JSON.stringify(l)));},setContentControlValueAt:(t,l)=>{P(t.story),typeof l=="string"&&w("all"),y(()=>e.set_content_control_value_at(t.story,t.paraId,t.offset,JSON.stringify(l)));},clearContentControlValue:t=>{P(),w("all"),y(()=>e.clear_content_control_value(t));},setImageGeometry:(t,l)=>{P(),w("all"),y(()=>e.set_image_geometry(t,JSON.stringify(l)));},setImageGeometryAt:(t,l)=>{P(t.story),y(()=>e.set_image_geometry_at(t.story,t.paraId,t.offset,JSON.stringify(l)));},insertPageBreak:t=>{P(t.story),y(()=>e.insert_page_break(t.story,t.paraId,t.offset));},insertSectionBreak:(t,l)=>{P(t.story),y(()=>e.insert_section_break(t.story,t.paraId,t.offset,l));},insertWatermark:(t,l)=>{P(t.story),y(()=>e.insert_watermark(t.story,t.paraId,t.offset,JSON.stringify(l)));},applyRawOps:(t,l)=>{let f=l.some(T=>T.op==="insertEmbed"&&T.kind==="pilcrow"||T.op==="setEmbedAttr"&&T.key==="paraId");w(f?"all":t),y(()=>e.apply_raw_ops(t,JSON.stringify(l)));},applySeedRawOps:(t,l)=>{w(t),y(()=>e.apply_seed_raw_ops(t,JSON.stringify(l)));},setParagraphAttr:(t,l,f)=>{w("all"),y(()=>e.set_paragraph_attr(t,l,JSON.stringify(f??null)));},addComment:(t,l,f,T)=>(w(t.map(W=>W.story)),y(()=>JSON.parse(e.add_comment(Yt(t),l,f,JSON.stringify(T??null))))),setCommentRanges:(t,l)=>{P(),y(()=>{e.set_comment_ranges(t,Yt(l)),w("all");});},acceptChange:t=>(w("all"),y(()=>JSON.parse(e.accept_change(_t(t))))),rejectChange:t=>(w("all"),y(()=>JSON.parse(e.reject_change(_t(t))))),selectionContext:t=>{let l=JSON.stringify(t);if(m?.key===l)return JSON.parse(m.json);let f=e.selection_context(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset),T=JSON.parse(f);return m={key:l,json:f},T},listRevisions:()=>JSON.parse(e.list_revisions()),resolveComment:t=>JSON.parse(e.resolve_comment(t)),listComments:()=>JSON.parse(e.list_comments()),storyIds:()=>e.story_ids(),hasStory:t=>!Lr.test(t)&&e.has_story(t),storyLength:t=>e.story_len(t),storyChecksum:t=>BigInt(e.story_checksum(t)),yrsBlocksForStory:(t,l={})=>{let f=e.yrs_blocks_for_story(t,JSON.stringify(l)),T=JSON.parse(f);return R.set(t,structuredClone(l)),T},paragraphs:t=>JSON.parse(e.paragraphs(t)),searchText:(t,l={})=>{if(!t)return [];let f=l.limit??Number.POSITIVE_INFINITY;if(!Number.isSafeInteger(f)&&f!==Number.POSITIVE_INFINITY||f<0)throw new RangeError("search limit must be a non-negative safe integer");return JSON.parse(e.search_text(t,l.caseSensitive??false,Number.isFinite(f)?Math.min(f,4294967295):void 0))},paragraphSpans:t=>JSON.parse(e.paragraph_spans(t)),storySegments:t=>JSON.parse(e.story_segments(t)),storiesChangedSince:t=>JSON.parse(e.stories_changed_since(t)),storySegmentUnitDigests:t=>JSON.parse(e.story_segment_unit_digests(t)),storySegmentUnits:(t,l)=>JSON.parse(e.story_segment_units(t,Uint32Array.from(l))),tablePayload:(t,l)=>{if(!Number.isInteger(l)||l<0||l>4294967295)return e.story_len(t),null;let f=e.table_payload(t,l);return f===void 0?null:JSON.parse(f)},locateParagraph:(t,l)=>JSON.parse(e.locate_paragraph(t,l)),paragraphIdCount:(t,l)=>e.paragraph_id_count(t,l),paragraphIdentities:()=>JSON.parse(e.paragraph_identities()),persistParagraphIds:()=>(w("all"),y(()=>JSON.parse(e.persist_paragraph_ids()))),resolveParagraphAnchor:t=>JSON.parse(e.resolve_paragraph_anchor(JSON.stringify(t))),storyParagraphIds:t=>JSON.parse(e.story_paragraph_ids(t)),paragraphSavePlan:()=>JSON.parse(e.paragraph_save_plan()),recordSavedParagraphIds:t=>y(()=>JSON.parse(e.record_saved_paragraph_ids(JSON.stringify(t)))),writtenParagraphIds:t=>JSON.parse(e.written_paragraph_ids(t)),exportStructured:t=>JSON.parse(e.export_structured_json(JSON.stringify(t))),exportMarkdown:t=>JSON.parse(e.export_markdown_json(JSON.stringify(t))),exportStructuredWithPages:t=>JSON.parse(e.export_structured_with_pages_json(JSON.stringify(t),void 0)),exportStructuredWithPagesFor:(t,l)=>JSON.parse(e.export_structured_with_pages_json(JSON.stringify(t),l)),exportSnapshotWithPrivateFonts:(t,l,f,T)=>JSON.parse(e.export_snapshot_with_private_fonts_json(t,l,f,JSON.stringify(T))),headings:t=>JSON.parse(e.headings_json(t)),listContentControls:(t={})=>JSON.parse(e.list_content_controls_json(JSON.stringify(t))),findContentControls:(t,l={})=>JSON.parse(e.find_content_controls_json(JSON.stringify(t),JSON.stringify(l))),version:()=>ue??e.version(),readParagraphs:t=>JSON.parse(e.read_paragraphs_json(JSON.stringify(t))),findText:t=>JSON.parse(e.find_text_json(JSON.stringify(t))),validateEdits:t=>JSON.parse(e.validate_edits_json(JSON.stringify(t))),applyEdits:t=>y(()=>{let l=JSON.parse(e.apply_edits_json(JSON.stringify(t)));return l.ok&&l.applied&&w(l.changedStories),l}),proposeChanges:t=>y(()=>M.propose(t)),setProposalStates:t=>M.setStates(t),withdrawProposals:t=>y(()=>M.withdraw(t)),getProposals:()=>M.snapshot(),mirrorWorkerDocument:t=>{ue=t?.version??null,M.mirror(t);},workerDocumentMirrored:()=>ue!==null,onProposalChange:t=>{if(s)throw new Error("yrs session is destroyed");return M.subscribe(t)},formatTextTarget:(t,l)=>(P(At(t)),y(()=>JSON.parse(e.format_text_target_json(JSON.stringify(t),JSON.stringify(l))))),commentTextTarget:(t,l)=>(w(At(t)),y(()=>JSON.parse(e.comment_text_target_json(JSON.stringify(t),JSON.stringify({...l,body:l.body??null}))))),selectionText:t=>JSON.parse(e.selection_text_json(t.story,t.start.paraId,t.start.offset,t.end.paraId,t.end.offset)),destroy:()=>{s||(s=true,ke(),n.clear(),M.destroy(),o.length=0,i&&e.clear_update_observer(),e.free());}};return b$3(B,{sourcePackage:()=>A&&J?{buffer:We(A),keys:J}:null,compareDocx:(t,l,f)=>{w("all");let T=y(()=>{let W=e.compare_docx_json(t,l,f);return M.reset(),W});return A=t.slice(),J=null,T},finishComparedDocx:t=>e.finish_compared_docx_json(t),failComparedDocx:t=>e.fail_compared_docx_json(t)}),B}async function Kn(e){let r=e?.clientId??Jr(),n=await import('../wasm-KSZTTO3B.mjs');return await n.preloadEditWasm(),Ur(n.createEditSession(r),r)}export{fe as ResidentEngineWorkerClient,_ as ResidentWorkerFailureError,re as ResidentWorkerOutOfMemoryError,Te as canUseResidentEngineWorker,It as captureSessionSave,Kn as createYrsSession,$n as decodeDocxHostJson,Ar as documentToYrs,ve as editorSaveKeys,$t as preloadDocxEngine,Ie as preloadResidentEngineWorker,qn as prepareDocxBytes,Vn as preparedDocxDigest,Vt as retainPreloadedResidentEngineWorker,zn as sameYrsSelection,Wr as saveYrsDocx,zt as takePreloadedResidentEngineWorker,Dt as writeSessionSave};
|