@docx-editor.dev/core 2.26.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +30 -13
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +20 -9
- package/dist/binding.js +1 -1
- package/dist/chunk-2GO5T2JU.cjs +1 -0
- package/dist/chunk-2RC2EPND.js +3 -0
- package/dist/chunk-4GBTELJV.cjs +28 -0
- package/dist/chunk-4R3TEXMN.js +18 -0
- package/dist/chunk-5CSUYANV.js +1 -0
- package/dist/chunk-6APGXLBB.cjs +3 -0
- package/dist/chunk-6AWEKBLB.cjs +1 -0
- package/dist/chunk-6EYYL7FL.js +1 -0
- package/dist/chunk-E7BQA6UP.js +2 -0
- package/dist/chunk-EO4C5QJW.cjs +2 -0
- package/dist/chunk-ETTO6GK3.js +1 -0
- package/dist/chunk-FIJZIQXA.cjs +18 -0
- package/dist/chunk-FRXAOVTB.js +28 -0
- package/dist/chunk-J6BVWIDB.js +2 -0
- package/dist/chunk-JGNVNT2A.cjs +2 -0
- package/dist/chunk-K5U2PLDP.cjs +2 -0
- package/dist/chunk-KKIJG3C6.js +2 -0
- package/dist/chunk-LWDSDCMO.js +27 -0
- package/dist/chunk-NBCVVZOM.cjs +1 -0
- package/dist/chunk-O2AL2HSJ.cjs +1 -0
- package/dist/{chunk-AJCCS53D.js → chunk-O5INAWZQ.js} +1 -1
- package/dist/chunk-QMLCVPCD.cjs +1 -0
- package/dist/chunk-RCHS4ZEH.cjs +27 -0
- package/dist/chunk-SRPILEWV.cjs +5 -0
- package/dist/chunk-TSLBZ26X.js +1 -0
- package/dist/chunk-VDNNLG6X.js +2 -0
- package/dist/chunk-VHAVHCQY.js +7 -0
- package/dist/chunk-VX43VBAX.cjs +7 -0
- package/dist/chunk-Z6WBFXJU.js +5 -0
- package/dist/chunk-ZUHOMK52.cjs +2 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +50 -5
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.cjs +1 -1
- package/dist/collaboration.d.ts +98 -6
- package/dist/collaboration.js +1 -1
- package/dist/contracts/document.d.ts +17 -2
- package/dist/contracts/editor.d.ts +19 -9
- package/dist/contracts/interaction.d.ts +29 -0
- package/dist/contracts/modules.cjs +1 -1
- package/dist/contracts/modules.d.ts +29 -16
- package/dist/contracts/modules.js +1 -1
- package/dist/contracts/types.d.ts +10 -1
- package/dist/{custom-node-writes-Cy9imOjA.d.ts → custom-node-writes-cvL5rhcD.d.ts} +2 -2
- package/dist/{document-protection-Bp19Ad4I.d.ts → document-protection-BAGVGqaP.d.ts} +1 -1
- package/dist/{editor-DYUlyKmb.d.ts → editor-Ci7IZGmG.d.ts} +410 -163
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +5 -5
- package/dist/editor.d.ts +417 -31
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +37 -15
- package/dist/export.js +2 -2
- package/dist/failure-NS2lsya4.d.ts +115 -0
- package/dist/{font-resolver-u_nE0PI1.d.ts → font-resolver-BVQB14qT.d.ts} +1 -1
- package/dist/{headless-document-view-R9bzzepb.d.ts → headless-document-view-qH331moE.d.ts} +2 -2
- package/dist/{image-resources-DfagDguq.d.ts → image-resources-BN-hUgCn.d.ts} +9 -9
- package/dist/{index-Docw8Dcb.d.ts → index-Bsg7oIKP.d.ts} +270 -115
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +46 -18
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-DWitwY73.d.ts → layout-shaping-BEyuiQOk.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +177 -249
- package/dist/layout.js +1 -1
- package/dist/{note-properties-CmfvOJsi.d.ts → note-properties-4Y9o6Gyk.d.ts} +1 -1
- package/dist/{omml-equation-CZ6IG2ja.d.ts → omml-equation-CuzBL5DD.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +18 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-DniKeDb8.d.ts → protocol-Bqk4Izjc.d.ts} +48 -7
- package/dist/review-pane-D9jm8DcY.d.ts +128 -0
- package/dist/{review-paragraph-order-Dc8Q6tfM.d.ts → review-paragraph-order-DT-n6ouC.d.ts} +5 -2
- package/dist/{revision-projection-DfWxdBqA.d.ts → revision-projection-DZ4kKVev.d.ts} +74 -3
- package/dist/{semantic-cell-selection-Dy_BmmpL.d.ts → semantic-cell-selection-D9D1KSXq.d.ts} +8 -6
- package/dist/{semantic-interaction-CvFAj0GR.d.ts → semantic-interaction-CIC-PooQ.d.ts} +25 -34
- package/dist/{semantic-paint-Bk9wIXdZ.d.ts → semantic-paint-BME37OMv.d.ts} +57 -5
- package/dist/semantic-record-queries-CBlZqZNa.d.ts +177 -0
- package/dist/{semantic-records-COqi8pjP.d.ts → semantic-records-4B3WwFAi.d.ts} +84 -42
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +165 -137
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-YPyYC1aD.d.ts → tree-package-fragment-BeeKxDw8.d.ts} +77 -57
- package/dist/{tree-session-contract-AeY2v0x9.d.ts → tree-session-contract-CVbmlMlq.d.ts} +7 -5
- package/dist/{types-barrel-BO73JqHG.d.ts → types-barrel-D3xCgQX6.d.ts} +595 -471
- package/package.json +3 -3
- package/dist/chunk-2BK4G4ZN.js +0 -2
- package/dist/chunk-2SJX44PC.cjs +0 -2
- package/dist/chunk-5BIASAN3.js +0 -1
- package/dist/chunk-6SEIXJTX.js +0 -1
- package/dist/chunk-73PG6L2X.js +0 -1
- package/dist/chunk-7RJSH72J.cjs +0 -5
- package/dist/chunk-AGKIHLWQ.cjs +0 -1
- package/dist/chunk-AN6WM4X4.js +0 -2
- package/dist/chunk-ANZ44KQT.cjs +0 -12
- package/dist/chunk-CYT3OQFZ.cjs +0 -1
- package/dist/chunk-DDGGSBAN.js +0 -12
- package/dist/chunk-EEAV3WIN.js +0 -3
- package/dist/chunk-ELQFXMJ5.cjs +0 -1
- package/dist/chunk-EYK4K2J6.js +0 -1
- package/dist/chunk-JNTETUNZ.cjs +0 -1
- package/dist/chunk-L6V3IJ3S.js +0 -5
- package/dist/chunk-LWCI65EL.js +0 -1
- package/dist/chunk-LZDI4P6I.cjs +0 -1
- package/dist/chunk-NS22DVWT.cjs +0 -2
- package/dist/chunk-QIE3YTU4.cjs +0 -2
- package/dist/chunk-QVBFPAGO.js +0 -5
- package/dist/chunk-RCCOLZEQ.js +0 -2
- package/dist/chunk-SUN62YU6.cjs +0 -5
- package/dist/chunk-TKQH7BNE.cjs +0 -1
- package/dist/chunk-TKR2MXX4.cjs +0 -3
- package/dist/chunk-UJL2GDIM.cjs +0 -25
- package/dist/chunk-WQTADNHK.cjs +0 -27
- package/dist/chunk-XSHXBJ2J.js +0 -25
- package/dist/chunk-YXZEBTDF.js +0 -27
- package/dist/failure-BIPVQbRm.d.ts +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docx-editor.dev/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"description": "Framework-agnostic core for docx-editor.dev: OOXML parse/serialize, the canonical document tree, layout and paint, and the Editor contract the adapters render.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"directory": "packages/core"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@docx-editor.dev/i18n": "^2.
|
|
108
|
+
"@docx-editor.dev/i18n": "^2.28.0",
|
|
109
109
|
"bidi-js": "1.1.0",
|
|
110
110
|
"emf-converter": "2.0.2",
|
|
111
111
|
"fast-xml-parser": "^5.10.1",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"prosemirror-keymap": "^1.2.3",
|
|
116
116
|
"prosemirror-model": "^1.25.4",
|
|
117
117
|
"prosemirror-state": "^1.4.4",
|
|
118
|
-
"prosemirror-view": "^1.
|
|
118
|
+
"prosemirror-view": "^1.42.3",
|
|
119
119
|
"utif2": "4.1.0"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
package/dist/chunk-2BK4G4ZN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {c}from'./chunk-73PG6L2X.js';import {Va,Ta,Ua,Ga}from'./chunk-L6V3IJ3S.js';import {Te,Va as Va$1,mf,Nf,Wa,Ua as Ua$1,Ta as Ta$1}from'./chunk-DDGGSBAN.js';function X(n){let r=[],s=0;for(let e of n){let o=s+e.text.length;e.resultRuns?r.push({text:e.text,rawStart:e.rawStart,rawEnd:e.rawEnd,resultRuns:e.resultRuns,...e.symbolOffsets?{symbolOffsets:e.symbolOffsets}:{},...e.symbolDisplays?{symbolDisplays:e.symbolDisplays}:{},projectedStart:s,projectedEnd:o,expansion:e.text.length!==e.rawEnd-e.rawStart}):e.floatingObject?r.push({text:e.text,rawStart:e.rawStart,rawEnd:e.rawEnd,floatingObject:true,projectedStart:s,projectedEnd:o,expansion:e.text.length!==e.rawEnd-e.rawStart}):r.push({text:e.text,rawStart:e.rawStart,rawEnd:e.rawEnd,...e.symbol?{symbol:true}:{},...e.symbolOffsets?{symbolOffsets:e.symbolOffsets}:{},...e.symbolDisplays?{symbolDisplays:e.symbolDisplays}:{},projectedStart:s,projectedEnd:o,expansion:e.text.length!==e.rawEnd-e.rawStart}),s=o;}return r}function v(n,r){return r<=n.rawStart?n.projectedStart:r>=n.rawEnd?n.projectedEnd:n.expansion?n.projectedStart:n.projectedStart+r-n.rawStart}function F(n,r){return n.expansion?n.rawStart:n.rawStart+r-n.projectedStart}function B(n,r){return n.expansion?n.rawEnd:n.rawStart+r-n.projectedStart}var z=new Set([Ta$1,"\u2011"]),G=/[\u001e\u001f\u2011]/,L="\uFFFF";function I(n,r){if(!G.test(n)&&!r?.size)return {text:n,at:null};let s="",e=[];for(let o=0;o<n.length;o+=1){let l=n[o];if(r?.has(o))s+=L;else {if(l===Ua$1)continue;s+=z.has(l)?"-":l;}e.push(o);}return {text:s,at:e}}function K(n){let r;for(let s of n){if(s.symbol){r??=new Set;for(let e=s.projectedStart;e<s.projectedEnd;e+=1)r.add(e);}for(let e of s.symbolOffsets??[])(r??=new Set).add(s.projectedStart+e);}return r}function O(n){let r=X(n),s="";for(let o of n)s+=o.text;let e=null;return {text:s,projectedOffset(o){let l=0;for(let i of r){if(o<=i.rawEnd)return v(i,o);l=i.projectedEnd;}return l},rawRange(o,l){if(o<0||o>=l||l>s.length)return null;let i=r.find(d=>o>=d.projectedStart&&o<d.projectedEnd),t=r.find(d=>l>d.projectedStart&&l<=d.projectedEnd);return !i||!t?null:{start:F(i,o),end:B(t,l)}},sliceRaw(o,l){if(o>=l)return "";let i="";for(let t of r){if(t.expansion){o<=t.rawStart&&l>=t.rawEnd&&(i+=t.text);continue}let d=Math.max(o,t.rawStart),a=Math.min(l,t.rawEnd);d<a&&(i+=t.text.slice(d-t.rawStart,a-t.rawStart));}return i},displaySlice(o,l){let i="";for(let t of r){if(t.projectedEnd<=o||t.projectedStart>=l)continue;let d=Math.max(o,t.projectedStart)-t.projectedStart,a=Math.min(l,t.projectedEnd)-t.projectedStart;if(t.symbol){i+=t.symbolDisplays?.[0]??"";continue}let u=new Map;t.symbolOffsets?.forEach((f,c)=>u.set(f,t.symbolDisplays?.[c]??""));for(let f=d;f<a;f+=1)i+=u.get(f)??t.text[f];}return i},resultRunAddressAt(o){let l=r.find(t=>t.resultRuns!==void 0&&o>=t.projectedStart&&o<t.projectedEnd);if(!l?.resultRuns)return null;let i=o-l.projectedStart;for(let t of l.resultRuns)if(i>=t.start&&i<t.end)return {runId:t.runId,offset:i-t.start};return null},findOccurrences(o,l,i={}){let t=[];if(l<=0||!Va(o)||s.length===0)return {matches:t,truncated:false};let d=i.matchCase===true,a=i.wholeWord===true;e??=I(s,K(r));let u=e,f=I(o).text;if(f.length===0||f.includes(L))return {matches:t,truncated:false};let c=d?f:Ta(f),j=d?u.text:Ta(u.text),R=p=>u.at?.[p]??p,W=p=>{if(!u.at)return p;let m=0;for(;m<u.at.length&&u.at[m]<p;)m+=1;return m},Y=Math.min(s.length,i.to??s.length),D=new Set,b=j.indexOf(c,W(Math.max(0,i.from??0)));for(;b>=0;){let p=b+c.length,m=R(b),x=R(p-1)+1;if(x>Y)return {matches:t,truncated:false};if(r.some(y=>y.floatingObject===true&&y.projectedStart>m&&y.projectedStart<x)){b=j.indexOf(c,b+1);continue}if(!a||Ua(u.text,b,p)){let y=r.find(h=>m>=h.projectedStart&&m<h.projectedEnd),E=r.find(h=>x>h.projectedStart&&x<=h.projectedEnd);if(!y||!E)return {matches:t,truncated:false};let S=y===E&&y.expansion?y:null;if(!S||!D.has(S)){if(t.length>=l)return {matches:t,truncated:true};t.push({start:m,length:x-m,rawStart:F(y,m),rawEnd:B(E,x)}),S&&D.add(S);}}b=j.indexOf(c,p);}return {matches:t,truncated:false}}}}function Q(n){return n.length===0?O([]):O([{text:n,rawStart:0,rawEnd:n.length}])}var U="http://schemas.openxmlformats.org/markup-compatibility/2006";function q(n){if(n.kind==="textValue")return false;let r=s=>s.kind!=="textValue"&&s.children.some(e=>e.kind==="anchoredDrawing"||e.kind!=="textValue"&&e.localName==="anchor");if(n.kind==="drawing")return r(n);if(n.namespaceUri!==U||n.localName!=="AlternateContent")return false;for(let s of n.children){if(s.kind==="textValue"||s.localName!=="Choice")continue;let e=s.children.find(o=>o.kind==="drawing"||o.kind!=="textValue"&&o.localName==="drawing");if(e)return r(e)}return false}function J(n,r,s="allMarkup"){if(!r.includes(Te)&&!r.includes(Va$1))return r.length===0?[]:[{text:r,rawStart:0,rawEnd:r.length}];let e=mf(n),o=Nf(n,e),l=c(n,e,s),i=new Map;for(let a of e)i.set(a.node.id,a);let t=[],d=0;for(let a of o){let u=i.get(a.node.id),f=!u&&Wa(a.node);if(!u&&!f){q(a.node)&&(d<a.start&&t.push({text:r.slice(d,a.start),rawStart:d,rawEnd:a.start}),t.push({text:"",rawStart:a.start,rawEnd:a.end,floatingObject:true}),d=a.end);continue}if(d<a.start&&t.push({text:r.slice(d,a.start),rawStart:d,rawEnd:a.start}),!u){t.push({text:Va$1,rawStart:a.start,rawEnd:a.end,symbol:true,symbolDisplays:[Ga(a.node)]}),d=a.end;continue}let c=l.get(u.node.id);u.kind==="simple"&&c?t.push({text:c.text,rawStart:a.start,rawEnd:a.end,resultRuns:c.runs,...c.symbols?{symbolOffsets:c.symbols}:{},...c.symbolDisplays?{symbolDisplays:c.symbolDisplays}:{}}):t.push({text:c?.text??Te,rawStart:a.start,rawEnd:a.end,...c?.symbols?{symbolOffsets:c.symbols}:{},...c?.symbolDisplays?{symbolDisplays:c.symbolDisplays}:{}}),d=a.end;}return d<r.length&&t.push({text:r.slice(d),rawStart:d,rawEnd:r.length}),t}function se(n,r,s="allMarkup"){return !r.includes(Te)&&!r.includes(Va$1)?Q(r):O(J(n,r,s))}
|
|
2
|
-
export{O as a,Q as b,J as c,se as d};
|
package/dist/chunk-2SJX44PC.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkJNTETUNZ_cjs=require('./chunk-JNTETUNZ.cjs'),chunkUJL2GDIM_cjs=require('./chunk-UJL2GDIM.cjs'),chunkQIE3YTU4_cjs=require('./chunk-QIE3YTU4.cjs'),chunkSUN62YU6_cjs=require('./chunk-SUN62YU6.cjs'),chunkANZ44KQT_cjs=require('./chunk-ANZ44KQT.cjs');function Fi(t){let e=[];for(let o of t.pages){let n=o.pageFieldSource?.pageNumber??o.index+1,r=chunkUJL2GDIM_cjs._c(n,o.pageFieldSource?.format),i=l=>{for(let u of l)if(u.kind==="paragraph")for(let d of u.lines)e.push({...d.range,pageNumber:n,pageNumberText:r});else for(let d of u.rows)for(let c of d.cells)i(c.blocks);};i(o.fragments),o.header&&i(o.header.fragments),o.footer&&i(o.footer.fragments);for(let l of o.footnotes?.notes??[])i(l.fragments);for(let l of o.endnotes?.notes??[])i(l.fragments);}return {pageCount:t.pages.length,ranges:e}}function pl(t,e,o,n){if(!t||!Number.isInteger(t.pageCount)||t.pageCount<1)return null;let r=chunkANZ44KQT_cjs.Ka(e,o);if(!r||r.kind!=="paragraph")return null;let i=chunkANZ44KQT_cjs.Mf(r).find(u=>u.node.id===n);if(!i)return null;let l=t.ranges.find(u=>u.paragraphId===o&&u.start<=i.start&&u.end>i.start);return !l||!Number.isInteger(l.pageNumber)||l.pageNumber<1?null:{pageNumber:l.pageNumber,pageNumberText:l.pageNumberText,pageCount:t.pageCount}}function cl(t){return async e=>{let o=chunkJNTETUNZ_cjs.e(e,{measurer:t.measurer,producer:t.producer,displayMode:"proposed"});if(!o.ok)throw new Error("field pagination could not open the document");try{return Fi(await o.session.layout())}finally{o.session.dispose();}}}var Ye=Object.freeze(["default","first","even"]);function Hn(t){return t.kind==="body"||t.kind==="header"||t.kind==="footer"}var Ot=Object.freeze({kind:"body"});function z(t){switch(t.kind){case "body":return "body";case "note":return `note:${t.noteKind}:${String(t.noteId)}`;case "textbox":return `textbox:${z(t.owner)}:${String(t.shapeId)}`;default:return `${t.kind}:${String(t.sectionIndex)}:${t.variant}`}}function Dn(t){if(typeof t!="object"||t===null)return false;let e=t;return e.kind==="body"?true:e.kind==="textbox"?Dn(e.owner)&&Hn(e.owner)&&Number.isInteger(e.shapeId)&&e.shapeId>=0:e.kind==="note"?(e.noteKind==="footnote"||e.noteKind==="endnote")&&Number.isInteger(e.noteId):e.kind!=="header"&&e.kind!=="footer"?false:Number.isInteger(e.sectionIndex)&&e.sectionIndex>=0&&Ye.includes(e.variant)}function Gt(t){return t.kind==="note"||t.kind==="textbox"}var Hi=["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","getFields","getField","getInlinePictures","getInlinePicture","getShapes","getShape","getShapeBody","getChangeTrackingMode","getDocument","getDocumentProperty","getBody","getParagraphs","getRange","getSpanParagraphs","getText","getSpanText","getParagraphId","search","getFont","getParagraphFormat","getStyle","getSections","getPageSetup","getFurniture","getNotes","getNoteBody","getNoteText","getNoteKind","getLists","getListId","getListById","getListParagraphs","getParagraphList","getListLevel","getHyperlink","getBookmarks","getBookmarkName","getBookmarkRange","getComments","getCommentReplies","getCommentId","getCommentAuthor","getCommentDate","getCommentText","getCommentRange","getCommentResolved","getRevisions","getRevisionType","getRevisionAuthor","getRevisionDate","getRevisionRange","getContentControls","getContentControlById","getContentControlsByTag","getContentControlsByTitle","getContentControlTag","getContentControlTitle","getContentControlFileId","getContentControlSubtype","getContentControlLock","getContentControlIsBound","getContentControlPlaceholderShown","getContentControlTemporary","getContentControlText","getContentControlParagraphs","getContentControlRange"],Nr=["removeDocumentInformation","setDocumentProperties","insertTableRows","insertTable","updateTable","updateTableCell","setInlinePicture","deleteInlinePicture","insertField","setFieldCode","deleteField","updateFieldResult","insertInlinePicture","insertBreak","setChangeTrackingMode","proposeInsertion","proposeDeletion","proposeReplacement","insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","startNewList","attachToList","detachFromList","setListLevelFormat","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","resolveRevisionBatch","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],Er=["removeDocumentInformation","insertTableRows","resolveRevisionBatch","insertTable","insertInlinePicture","insertBreak","startNewList","deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],Di=new Set(Er);function Je(t){return Di.has(t.op)||t.op==="updateTable"&&["addRows","addColumns","deleteRows","deleteColumns","delete"].includes(t.mutation.kind)}var ji=new Set(Nr);function Vt(t){return ji.has(t.op)}var Bi="http://schemas.openxmlformats.org/drawingml/2006/picture",_i="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",Vi="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",Ui=4096,Wi=65536;function $i(t){return t&&t.kind!=="textValue"?t:null}function Qe(t,e,o){return t.kind!=="textValue"&&t.namespaceUri===e&&t.localName===o}function Xt(t,e,o){return $i(t.children.find(n=>Qe(n,e,o)))}function Ki(t){let e=t.children.find(h=>h.kind==="anchoredDrawing"||h.kind==="inlineDrawing"||Qe(h,chunkANZ44KQT_cjs.la,"anchor")||Qe(h,chunkANZ44KQT_cjs.la,"inline"));if(!e||e.kind==="textValue")return null;let o=Xt(e,chunkANZ44KQT_cjs.la,"docPr"),n=o?chunkANZ44KQT_cjs.ea(o.attributes,"id"):void 0;if(!o||n===void 0||!/^\d{1,10}$/.test(n)||Number(n)>4294967295)return "malformed";let r=chunkANZ44KQT_cjs.ea(o.attributes,"name")??"",i=Xt(e,chunkANZ44KQT_cjs.ka,"graphic"),l=i?Xt(i,chunkANZ44KQT_cjs.ka,"graphicData"):null,u=l?chunkANZ44KQT_cjs.ea(l.attributes,"uri"):void 0,d="Unsupported",c=null;if(l&&u===chunkANZ44KQT_cjs.da){let h=Xt(l,chunkANZ44KQT_cjs.da,"wsp"),g=h?Xt(h,chunkANZ44KQT_cjs.da,"txbx"):null;c=g?Xt(g,chunkANZ44KQT_cjs.fa,"txbxContent"):null;let b=h?Xt(h,chunkANZ44KQT_cjs.da,"cNvSpPr"):null,m=b?chunkANZ44KQT_cjs.ea(b.attributes,"txBox"):void 0;d=h?m==="1"||m==="true"?"TextBox":"GeometricShape":"Unsupported";}else u===Bi?d="Picture":u===_i?d="Group":u===Vi&&(d="Canvas");return {read:{id:Number(n),name:r,type:d},root:c}}function Ze(t,e){let o=[],n=new Set;for(let r of e){if(r.kind==="textValue")continue;let i=chunkANZ44KQT_cjs.bd(chunkANZ44KQT_cjs.Hi(t,r),r),l=[];for(let d=r.children.length-1;d>=0;d-=1)l.push({node:r.children[d],scope:i});let u=0;for(;l.length>0;){if(++u>Wi)return {ok:false,reason:"truncated"};let{node:d,scope:c}=l.pop();if(d.kind==="textValue"||d.kind==="paragraph")continue;let h=chunkANZ44KQT_cjs.bd(c,d),g=chunkANZ44KQT_cjs.ad(d),b=d.kind==="drawing"||Qe(d,chunkANZ44KQT_cjs.fa,"drawing")?d:g?chunkANZ44KQT_cjs.ud(d,h).drawing:null;if(!(g&&!b)){if(b){let m=Ki(b);if(m==="malformed")return {ok:false,reason:"malformed"};if(m){if(n.has(m.read.id))return {ok:false,reason:"duplicates"};if(o.length>=Ui)return {ok:false,reason:"truncated"};n.add(m.read.id),o.push({...m.read,hostParagraphId:r.id,textboxRoot:m.root,alternate:g?d:null});}continue}for(let m=d.children.length-1;m>=0;m-=1)l.push({node:d.children[m],scope:h});}}}return {ok:true,shapes:Object.freeze(o)}}var zi=63360;function Ft(t){return Math.round(chunkANZ44KQT_cjs.Yc(chunkANZ44KQT_cjs.Wc(t))*100)/100}function Gi(t,e){if(typeof t!="number"||!Number.isFinite(t))return null;let o=chunkANZ44KQT_cjs.Zc(chunkANZ44KQT_cjs.Xc(t));return o>zi||o<0||o===0&&!e?null:o}var Xi=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function Lr(t){if(typeof t!="object"||t===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=t,o={},n=0;for(let[i,l,u]of Xi){let d=e[i];if(d===void 0)continue;let c=Gi(d,u);if(c===null)return {ok:false,reason:`that is not a value for ${i}`,detail:String(d)};o[l]=c,n+=1;}let r=e.orientation;if(r!==void 0){if(r!=="portrait"&&r!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(r)};o.orientation=r,n+=1;}return n===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:o}}function Yi(t){let e=chunkANZ44KQT_cjs.mj(t),o=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:Ft(e.widthTwips),pageHeight:Ft(e.heightTwips),orientation:o,topMargin:Ft(e.topTwips),rightMargin:Ft(e.rightTwips),bottomMargin:Ft(e.bottomTwips),leftMargin:Ft(e.leftTwips),headerDistance:Ft(e.headerTwips),footerDistance:Ft(e.footerTwips),gutter:Ft(e.gutterTwips)})}function Ji(t,e){if(!e)return null;let o=null,n=(r,i,l)=>{if(o!==null||r.kind==="textValue"||l>64)return;let u=r.kind==="paragraph"?r.id:i;if(r.id===e.id){o=u;return}for(let d of r.children)n(d,u,l+1);};return n(t.root,null,0),o}function Mr(t,e,o){let n=chunkANZ44KQT_cjs.Me(e.root);return Object.freeze(n.map((r,i)=>{let l=o[i];return Object.freeze({index:i,markParagraphId:Ji(e,r),pageSetup:Yi(r),titlePage:l?.titlePage??false,evenAndOddHeaders:l?.evenAndOddHeaders??false})}))}var Qi=255,Zi=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function Fr(t){let e=chunkANZ44KQT_cjs.Oc(t);if(!e)return Zi;let o=new Map,n=new Map,r=null;for(let i of chunkANZ44KQT_cjs.Nc(e).values())if(i.type==="paragraph"){if(o.set(i.styleId,i.name),i.name!==null){let l=i.name.trim().toLowerCase();n.has(l)||n.set(l,i.styleId);}i.isDefault&&r===null&&(r=i.styleId);}return Object.freeze({nameOf:i=>o.get(i)??null,idOf:i=>n.get(i.trim().toLowerCase())??null,defaultId:r,present:true})}function qe(t,e,o){let n=chunkANZ44KQT_cjs.Ka(t,e);if(!n||n.kind!=="paragraph")return null;let r=qi(chunkANZ44KQT_cjs.Kf(chunkANZ44KQT_cjs.If(n),"pStyle"));return r!==null?o.nameOf(r):o.defaultId===null?null:o.nameOf(o.defaultId)}function qi(t){if(!t)return null;for(let e of t.attributes)if(e.localName==="val")return e.value;return null}function tn(t,e){if(typeof t!="string"||t.trim().length===0)return {ok:false,detail:"style: not a name"};if(t.length>Qi)return {ok:false,detail:"style: name too long"};if(!chunkANZ44KQT_cjs.O(t))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let o=e.idOf(t);return o===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:o}}function Hr(t,e,o){return e>=o?null:{text:t.text.slice(e-t.rawStart,o-t.rawStart),rawStart:e,rawEnd:o,...t.symbol?{symbol:true}:{},...t.symbol&&t.symbolDisplays?{symbolDisplays:t.symbolDisplays}:{}}}function ts(t,e){let o=[],n=0;for(let r of t){for(;n<e.length&&e[n].end<=r.rawStart;)n+=1;let i=r.rawEnd-r.rawStart;if(r.text.length!==i||r.resultRuns||r.symbolOffsets){let d=e[n];(!d||d.start>=r.rawEnd)&&o.push(r);continue}let l=r.rawStart;for(;n<e.length;){let d=e[n];if(d.end<=l){n+=1;continue}if(d.start>=r.rawEnd)break;let c=Hr(r,l,Math.min(d.start,r.rawEnd));if(c&&o.push(c),l=Math.max(l,d.end),d.end<=r.rawEnd&&(n+=1),l>=r.rawEnd)break}let u=Hr(r,l,r.rawEnd);u&&o.push(u);}return o}function en(t,e,o){if(o==="model")return chunkQIE3YTU4_cjs.b(e);let n=chunkQIE3YTU4_cjs.c(t,e,o);if(o==="allMarkup")return chunkQIE3YTU4_cjs.a(n);let r=es(t);if(r.length===0)return chunkQIE3YTU4_cjs.a(n);let i=ts(n,r);return chunkQIE3YTU4_cjs.a(i)}function es(t){let e=chunkANZ44KQT_cjs.Of(t),o=[],n=(i,l)=>{if(!(l>64||i.kind==="textValue")){if(i.kind==="revisionInsert"||i.kind==="revisionMoveTo"){let u=e.spanOf(i);u&&u.end>u.start&&o.push({start:u.start,end:u.end});return}for(let u of i.children)n(u,l+1);}};n(t,0),o.sort((i,l)=>i.start-l.start||l.end-i.end);let r=[];for(let i of o){let l=r[r.length-1];l&&i.start<=l.end?l.end=Math.max(l.end,i.end):r.push({...i});}return r}var jn="\r",ns=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),os=Object.freeze([]),rs=Object.freeze([]),Dr=Object.freeze([]),jr=Object.freeze({ok:true,shapes:[]}),as=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>rs,furniture:()=>Dr,noteIds:()=>({ok:true,ids:Br}),shapes:()=>jr,styles:()=>ns});function is(t){return t.kind==="textValue"?os:Object.freeze(t.children.filter(e=>e.kind!=="textValue").map(e=>{let o=[];chunkANZ44KQT_cjs.Dc([e],o,0);let n=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",r=e.kind==="paragraph"&&chunkANZ44KQT_cjs.Kf(chunkANZ44KQT_cjs.If(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:n,paragraphIds:Object.freeze(o.map(i=>i.id)),removable:n!=="other"&&!r})}))}function Ie(t,e,o,n,r){let i=chunkANZ44KQT_cjs.Cc(n),l=Object.freeze(i.map(m=>m.id)),u=new Map,d=new Map;i.forEach((m,A)=>{u.set(m.id,A),d.set(m.id,m);});let c=new Map,h=m=>{if(!u.has(m))return null;let A=c.get(m);if(A!==void 0)return A;let I=chunkANZ44KQT_cjs.Zj(e,m)??"";return c.set(m,I),I},g=new Map,b=(m,A="allMarkup")=>{let I=d.get(m);if(!I||I.kind!=="paragraph")return null;let S=`${m}:${A}`,N=g.get(S);if(N)return N;let w=en(I,h(m)??"",A);return g.set(S,w),w};return {story:t,part:e,root:n,scope:o,paragraphIds:l,blocks:is(n),has:m=>u.has(m),indexOf:m=>u.get(m)??-1,paragraph(m){let A=d.get(m);return A?{nodeId:m,paraId:chunkANZ44KQT_cjs.ib(A),text:b(m)?.text??""}:null},node:m=>d.get(m)??null,rawText:h,paragraphText:(m,A)=>b(m,A)?.text??null,projectedText:b,text:m=>l.map(A=>b(A,m)?.text??"").join(jn),styles:r}}function nn(t,e){let o=Ie(t.story,t.part,t.scope,e,t.styles);return {...o,indexOf:n=>o.has(n)?t.indexOf(n):-1}}function Pe(t){let e=t.parts.get(t.mainDocumentPart);if(!e)return as;let o,n=()=>o??=Fr(t),r,i=()=>r??=chunkANZ44KQT_cjs.Oe(t),l,u=new Map,d=new Map,c=new Map,h=w=>{let E=z(w),L=c.get(E);if(L)return L;let T=I(w),M=T?T.paragraphIds.flatMap(j=>{let K=T.node(j);return K?[K]:[]}):[],O=T?Ze(T.part,M):jr;return c.set(E,O),O},g=w=>{let E=d.get(w);if(E)return E;let L=chunkANZ44KQT_cjs.Ig(t,w);if(!L){let B={ok:true,ids:Br};return d.set(w,B),B}let T=[],M=new Set,O=new Set,j=0,K=false;for(let B of L.root.children){if(chunkANZ44KQT_cjs.ic(B)!==w)continue;if(j+=1,B.kind!=="note"){K=true;continue}if(!chunkANZ44KQT_cjs.lc(B))continue;let Z=chunkANZ44KQT_cjs.jc(B);if(Z===null){K=true;continue}M.has(Z)?O.add(Z):(M.add(Z),T.push(Z));}let $=j>chunkANZ44KQT_cjs.sc?{ok:false,reason:"truncated"}:K?{ok:false,reason:"malformed"}:O.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...O])}:{ok:true,ids:Object.freeze(T)};return d.set(w,$),$},b=w=>{let E=i()[w.sectionIndex];return E?(w.kind==="header"?E.headers:E.footers).get(w.variant)??null:null},m=w=>{if(w.kind==="body"){let L=chunkANZ44KQT_cjs.Bc(e);return L?Ie(w,e,{kind:"body"},L,n):null}if(w.kind==="note"){let L=g(w.noteKind);if(!L.ok||!L.ids.includes(w.noteId))return null;let T=chunkANZ44KQT_cjs.Ig(t,w.noteKind);if(!T)return null;let M=chunkANZ44KQT_cjs.wc(T.root,w.noteId);return !M||!chunkANZ44KQT_cjs.lc(M)?null:Ie(w,T,{kind:"notesPart",noteKind:w.noteKind},M,n)}if(w.kind==="textbox"){let L=A(w.owner),T=h(w.owner);if(!L||!T.ok)return null;let M=T.shapes.find(O=>O.id===w.shapeId);return M?.textboxRoot?Ie(w,L.part,L.scope,M.textboxRoot,n):null}let E=b(w);return E?Ie(w,E.part,{kind:"headerFooter",rId:E.rId},E.part.root,n):null},A=w=>I(w),I=w=>{let E=z(w);if(u.has(E))return u.get(E)??null;let L=m(w);return u.set(E,L),L},S=(w,E)=>{let L=h(w);if(!L.ok)return null;for(let T of L.shapes){if(!T.textboxRoot)continue;let M={kind:"textbox",owner:w,shapeId:T.id};if(I(M)?.has(E))return M}return null};return {package:t,get body(){return I(Ot)},story:I,storyOf:w=>{if(I(Ot)?.has(w))return Ot;let L=[{kind:"body"}];for(let[T]of i().entries())for(let M of ["header","footer"])for(let O of Ye){let j={kind:M,sectionIndex:T,variant:O};if(I(j)){if(I(j).has(w))return j;L.push(j);}}for(let T of ["footnote","endnote"]){let M=g(T);if(M.ok)for(let O of M.ids){let j={kind:"note",noteKind:T,noteId:O};if(I(j)?.has(w))return j}}for(let T of L){let M=S(T,w);if(M)return M}return null},sections:()=>l??=Mr(t,e,i()),furniture(w){let E=i()[w];if(!E)return Dr;let L=[];for(let T of ["header","footer"]){let M=T==="header"?E.headers:E.footers;for(let O of Ye){let j=M.get(O);j&&L.push(Object.freeze({kind:T,variant:O,declared:!j.inherited}));}}return Object.freeze(L)},noteIds:g,shapes:h,styles:n}}var Br=Object.freeze([]);function _r(t,e,o){let n=r=>({state:o,step:{ok:false,error:{code:"unsupported-capability",message:r,detail:"changeTrackingMode"}}});return t.op==="getChangeTrackingMode"||t.op==="setChangeTrackingMode"?e?t.op==="getChangeTrackingMode"?{state:o,step:{ok:true,kind:"query",value:{kind:"text",text:o.mode}}}:t.mode!=="Off"&&t.mode!=="TrackMineOnly"?n("TrackAll requires shared tracking enforcement for every peer and is not supported"):t.mode==="TrackMineOnly"&&(typeof t.author!="string"||!t.author.trim()||!chunkANZ44KQT_cjs.O(t.author))?n("TrackMineOnly requires a non-empty XML-safe runtime author"):{state:{mode:t.mode,...t.mode==="TrackMineOnly"?{author:t.author.trim()}:{}},step:{ok:true,kind:"query",value:{kind:"applied"}}}:n("this host does not support runtime-local change tracking"):o.mode==="Off"||Bn(t)?null:n(`${t.op} does not support TrackMineOnly; no permanent edit was applied`)}function Bn(t){return !Vt(t)||t.op==="setChangeTrackingMode"||t.op==="insertText"||t.op==="insertTable"||t.op==="insertTableRows"||t.op==="updateTable"||t.op==="updateTableCell"||t.op==="replaceSpan"&&!("body"in t.span)?true:["insertContentControl","setContentControlProperties","startNewList","setListLevelFormat","attachToList","detachFromList","setListLevel","insertParagraph","setFont","setStyle","setParagraphFormat","proposeInsertion","proposeDeletion","proposeReplacement","insertComment","replyToComment","deleteComment","setCommentResolved","acceptRevision","rejectRevision","resolveRevisionBatch","acceptAllRevisions","rejectAllRevisions","selectSpan","selectBookmark"].includes(t.op)}function Vr(t,e,o){if(!o||!["setFont","setStyle","setParagraphFormat","insertParagraph","attachToList","detachFromList","setListLevel"].includes(t.op)||!e.ok||e.kind!=="command")return e;let n={author:o,date:new Date().toISOString()};return {...e,ops:e.ops.map(r=>{if(r.op==="insertText")return {...r,revision:n};if(r.op==="splitParagraph")return {op:"splitParagraphMany",paragraphId:r.paragraphId,offsets:[r.offset],revision:n};if(r.op==="setRunProperties"||r.op==="setParagraphProperties"||r.op==="setParagraphMarkProperties"||r.op==="setListNumbering"||r.op==="setListLevel")return {...r,revision:n};throw new Error("Formatting plan contains an operation without property revision support")})}}function ss(){let t=globalThis.crypto,e=t?.getRandomValues;if(typeof e!="function")throw new Error("automation: no secure random source. globalThis.crypto.getRandomValues is required to scope document handles to one host.");let o=e.call(t,new Uint8Array(16)),n="";for(let r of o)n+=r.toString(16).padStart(2,"0");return n}function ls(t){return typeof t=="object"&&t!==null&&"kind"in t&&"ref"in t}function Ur(){let t=new Map,e=new Map,o=new Map,n=new Map,r=ss(),i=null,l=(d,c)=>{let h=(n.get(d)??0)+1;n.set(d,h);let g=`${d}:${r}:${String(h)}`;return t.set(g,c),Object.freeze({kind:d,ref:g})},u=(d,c,h)=>{let g=`${d}\0${c}`,b=o.get(g);if(b)return Object.freeze({kind:d,ref:b});let m=l(d,h);return o.set(g,m.ref),m};return {document(){return i??=l("document",{kind:"document"}),i},body(d,c){return u("body",`${z(d)}:${c??""}`,{kind:"body",story:d,...c?{rootNodeId:c}:{}})},table(d,c){return u("table",`${z(c)}:${d}`,{kind:"table",nodeId:d,story:c})},tableRow(d,c){return u("tableRow",`${z(c)}:${d}`,{kind:"tableRow",nodeId:d,story:c})},tableCell(d,c){return u("tableCell",`${z(c)}:${d}`,{kind:"tableCell",nodeId:d,story:c})},field(d,c,h){return u("field",`${z(h)}:${c}`,{kind:"field",paragraphId:d,fieldNodeId:c,story:h})},inlinePicture(d,c){return u("inlinePicture",`${z(c)}:${d}`,{kind:"inlinePicture",drawingNodeId:d,story:c})},shape(d,c){return u("shape",`${z(c)}:${String(d)}`,{kind:"shape",shapeId:d,owner:c})},paragraph(d,c){let h=e.get(d);if(h)return Object.freeze({kind:"paragraph",ref:h});let g=l("paragraph",{kind:"paragraph",paragraphId:d,story:c});return e.set(d,g.ref),g},section(d){return u("section",String(d),{kind:"section",index:d})},note(d,c){return u("note",`${d}:${String(c)}`,{kind:"note",noteKind:d,noteId:c})},comment(d,c){return u("comment",`${z(c)}\0${d}`,{kind:"comment",commentId:d,story:c})},revision(d,c){return u("revision",`${z(c)}\0${d}`,{kind:"revision",revisionId:d,story:c})},bookmark(d,c){return u("bookmark",`${z(c)}\0${d}`,{kind:"bookmark",name:d,story:c})},list(d,c){return u("list",`${z(c)}\0${d}`,{kind:"list",numId:d,story:c})},contentControl(d,c){return u("contentControl",`${z(c)}\0${d}`,{kind:"contentControl",nodeId:d,story:c})},retarget(d,c){let h=e.get(d);if(!h||d===c)return;let g=t.get(h);!g||g.kind!=="paragraph"||(e.delete(d),t.set(h,{kind:"paragraph",paragraphId:c,story:g.story}),e.has(c)||e.set(c,h));},resolve(d,c){if(!ls(d)||d.kind!==c||typeof d.ref!="string")return null;let h=t.get(d.ref);return !h||h.kind!==c?null:h}}}function St(t,e){return {ok:false,code:t,detail:e}}function Rt(t){return {ok:true,value:t}}function lt(t,e,o,n){let r=o.resolve(t,e);if(!r||r.kind!=="body"&&r.kind!=="paragraph")return St("invalid-handle",`not-a-${e}-handle`);let i=n.story(r.story);if(!i)return St("invalid-handle",`no-such-story:${z(r.story)}`);if(r.kind==="body"&&r.rootNodeId){let l=chunkANZ44KQT_cjs.Ka(i.part,r.rootNodeId);return !l||l.kind!=="tableCell"?St("invalid-handle","cell no longer exists"):Rt(nn(i,l))}return Rt(i)}function yt(t,e,o){let n=e.resolve(t,"paragraph");if(!n||n.kind!=="paragraph")return St("invalid-handle","not-a-paragraph-handle");let r=o.story(n.story);if(!r)return St("invalid-handle",`no-such-story:${z(n.story)}`);let i=r.indexOf(n.paragraphId);return i<0?St("invalid-handle","paragraph-not-in-body"):Rt({story:n.story,paragraphId:n.paragraphId,index:i,offset:0})}function ds(t,e,o){let n=yt(t.paragraph,e,o);if(!n.ok)return n;let i=(o.story(n.value.story)?.rawText(n.value.paragraphId)??"").length,{offset:l}=t;return !Number.isInteger(l)||l<0||l>i?St("invalid-offset",`offset ${String(l)} outside 0..${String(i)}`):Rt({...n.value,offset:l})}function le(t,e,o){if("paragraph"in t){if(!("at"in t))return ds(t,e,o);let u=yt(t.paragraph,e,o);if(!u.ok||t.at==="start")return u;let c=(o.story(u.value.story)?.rawText(u.value.paragraphId)??"").length;return Rt({...u.value,offset:c})}let n=lt(t.body,"body",e,o);if(!n.ok)return n;let r=n.value.paragraphIds;if(r.length===0)return St("invalid-offset","empty-story");if(t.at==="start")return Rt({story:n.value.story,paragraphId:r[0],index:n.value.indexOf(r[0]),offset:0});let i=r.length-1,l=r[i];return Rt({story:n.value.story,paragraphId:l,index:n.value.indexOf(l),offset:(n.value.rawText(l)??"").length})}function us(t,e){return t.index<e.index||t.index===e.index&&t.offset<=e.offset}function ps(t){let e=t.paragraphIds;if(e.length===0)return null;let o=e.length-1,n=e[o];return {start:{story:t.story,paragraphId:e[0],index:t.indexOf(e[0]),offset:0},end:{story:t.story,paragraphId:n,index:t.indexOf(n),offset:(t.rawText(n)??"").length}}}function G(t,e,o){if("body"in t){let i=lt(t.body,"body",e,o);return i.ok?Rt(ps(i.value)):i}if("paragraph"in t){let i=yt(t.paragraph,e,o);if(!i.ok)return i;let u=(o.story(i.value.story)?.rawText(i.value.paragraphId)??"").length;return Rt({start:i.value,end:{...i.value,offset:u}})}let n=le(t.start,e,o);if(!n.ok)return n;let r=le(t.end,e,o);return r.ok?z(n.value.story)!==z(r.value.story)?St("invalid-handle","span-crosses-stories"):us(n.value,r.value)?Rt({start:n.value,end:r.value}):St("invalid-offset","span-start-after-end"):r}function nt(t,e,o){if("body"in t)return lt(t.body,"body",e,o);if("paragraph"in t)return lt(t.paragraph,"paragraph",e,o);let n=t.start;return "paragraph"in n?lt(n.paragraph,"paragraph",e,o):lt(n.body,"body",e,o)}function on(t,e,o){if("paragraph"in t)return yt(t.paragraph,e,o);let n=lt(t.body,"body",e,o);if(!n.ok)return n;let r=n.value.paragraphIds;if(r.length===0)return St("invalid-offset","empty-story");let i=t.at==="first"?0:r.length-1;return Rt({story:n.value.story,paragraphId:r[i],index:i,offset:0})}function xt(t,e){if(!t)return [];let o=e.paragraphIds,n=o[t.start.index]===t.start.paragraphId?t.start.index:o.indexOf(t.start.paragraphId),r=o[t.end.index]===t.end.paragraphId?t.end.index:o.indexOf(t.end.paragraphId);return n<0||r<n?[]:o.slice(n,r+1)}function Yt(t,e){if(!t)return [];let o=xt(t,e),n=o.length-1;return o.map((r,i)=>{let l=(e.rawText(r)??"").length,u=i===0?t.start.offset:0,d=i===n?t.end.offset:l;return {paragraphId:r,start:u,end:d,whole:u===0&&d===l}})}function Wr(t,e,o,n="allMarkup"){if(!t)return "";let r=xt(t,e);return r.length===1?e.projectedText(t.start.paragraphId,n)?.sliceRaw(t.start.offset,t.end.offset)??"":r.map((i,l)=>{let u=e.projectedText(i,n);if(!u)return "";let d=(e.rawText(i)??"").length;return l===0?u.sliceRaw(t.start.offset,d):l===r.length-1?u.sliceRaw(0,t.end.offset):u.text}).join(o)}function Ht(t,e){return {start:{paragraph:e.paragraph(t.start.paragraphId,t.start.story),offset:t.start.offset},end:{paragraph:e.paragraph(t.end.paragraphId,t.end.story),offset:t.end.offset}}}var cs=new Set(["TextBox","GeometricShape","Picture","Group","Canvas","Unsupported"]),Nt=(t,e,o)=>({ok:false,error:{code:t,message:e,...o===void 0?{}:{detail:o}}}),_n=t=>({ok:true,kind:"query",value:t});function ms(t,e,o){let n=e.resolve(t,"shape");if(!n||n.kind!=="shape")return Nt("invalid-handle","that handle does not name a shape","shape");let r=o.shapes(n.owner);if(!r.ok)return Nt("ambiguous-document","shape identities in that story are not completely and unambiguously enumerable",r.reason);let i=r.shapes.find(l=>l.id===n.shapeId);return i?{owner:n.owner,shape:i}:Nt("invalid-handle","that shape is not in this document",z(n.owner))}function $r(t,e,o){if(t.op==="getShapes"){let i=t.types;if(i!==void 0&&(!Array.isArray(i)||i.some(h=>!cs.has(h))))return Nt("unsupported-content","unknown shape type","types");if(!("body"in t.span)&&!("paragraph"in t.span))return Nt("unsupported-content","shapes are listed for a body or a paragraph only");let l=G(t.span,e,o),u=nt(t.span,e,o);if(!l.ok||!u.ok)return Nt("invalid-handle","that range no longer exists","span");let d=o.shapes(u.value.story);if(!d.ok)return Nt("ambiguous-document","shape identities in that story are not completely and unambiguously enumerable",d.reason);let c=new Set(l.value?xt(l.value,u.value):[]);return _n({kind:"handles",handles:d.shapes.filter(h=>c.has(h.hostParagraphId)&&(!i||i.includes(h.type))).map(h=>e.shape(h.id,u.value.story))})}let n=ms(t.shape,e,o);if("ok"in n)return n;if(t.op==="getShape"){let{id:i,name:l,type:u}=n.shape;return _n({kind:"shape",shape:{id:i,name:l,type:u}})}if(!n.shape.textboxRoot)return Nt("unsupported-content","that shape holds no text story of its own",n.shape.type);if(!Hn(n.owner))return Nt("unsupported-content","text boxes are reachable in the body, headers and footers only",z(n.owner));let r={kind:"textbox",owner:n.owner,shapeId:n.shape.id};return o.story(r)?_n({kind:"handle",handle:e.body(r)}):Nt("invalid-handle","that text box is not in this document",z(r))}var Vn="http://schemas.openxmlformats.org/package/2006/relationships",Kr="http://schemas.openxmlformats.org/officeDocument/2006/relationships",fs=[{type:"application/vnd.openxmlformats-package.core-properties+xml",namespace:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",root:"coreProperties",relationship:`${Vn}/metadata/core-properties`},{type:"application/vnd.openxmlformats-officedocument.extended-properties+xml",namespace:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",root:"Properties",relationship:`${Kr}/extended-properties`},{type:"application/vnd.openxmlformats-officedocument.custom-properties+xml",namespace:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",root:"Properties",relationship:`${Kr}/custom-properties`}];function Un(t){let e=new Map;for(let n of fs){let r=[...new Set([...t.parts.keys(),...t.partBytes.keys()])].filter(d=>chunkANZ44KQT_cjs.qe(t,d)===n.type);if(r.length>1)return null;let i=(t.relationships.get("/")??[]).filter(d=>d.type===n.relationship);if(i.length>1)return null;let l=i[0];if(l){if(l.targetMode!=="Internal")return null;let d=chunkANZ44KQT_cjs.w("/",l.rawTarget);if(!d.ok||r.length!==1||chunkANZ44KQT_cjs.u(d.partName)!==chunkANZ44KQT_cjs.u(r[0]))return null}if(r.length===0)continue;let u=t.parts.get(r[0]);if(!u||u.root.namespaceUri!==n.namespace||u.root.localName!==n.root||(t.relationships.get(u.name)?.length??0)>0||t.parts.has(chunkANZ44KQT_cjs.re(u.name))||t.partBytes.has(chunkANZ44KQT_cjs.re(u.name)))return null;e.set(chunkANZ44KQT_cjs.u(u.name),{part:u,relationship:n.relationship});}if(e.size===0)return t;if(!chunkANZ44KQT_cjs.Ed(t,new Set(e.keys())))return null;for(let[n,r]of t.relationships)for(let i of r){if(i.targetMode==="External")continue;let l=chunkANZ44KQT_cjs.w(n,i.rawTarget),u=l.ok&&e.get(chunkANZ44KQT_cjs.u(l.partName));if(!u)continue;if(n!=="/"||i.type!==u.relationship)return null;let d=t.parts.get(chunkANZ44KQT_cjs.re(n));if(!d||d.root.namespaceUri!==Vn||d.root.localName!=="Relationships")return null;let c=d.root.children.filter(g=>g.kind!=="textValue"&&g.attributes.some(b=>b.namespaceUri===""&&b.localName==="Id"&&b.value===i.id));if(c.length!==1)return null;let h=c[0];if(h.kind==="textValue"||h.namespaceUri!==Vn||h.localName!=="Relationship"||h.attributes.some(g=>g.namespaceUri!==""||!["Id","Type","Target","TargetMode"].includes(g.localName))||h.children.some(g=>g.kind!=="textValue"||!chunkANZ44KQT_cjs.Dd(g.value)))return null}let o=t;for(let{part:n}of e.values()){let r=chunkANZ44KQT_cjs.ue(o,n.name);if(!r.ok||r.pkg.contentTypes.overrides.has(chunkANZ44KQT_cjs.u(n.name)))return null;o=r.pkg;}return o}var de="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",rn="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",Oe="http://purl.org/dc/elements/1.1/",Wn="application/vnd.openxmlformats-package.core-properties+xml",$n={author:[Oe,"creator"],title:[Oe,"title"],subject:[Oe,"subject"],comments:[Oe,"description"],keywords:[de,"keywords"],category:[de,"category"]},zr={...$n,lastAuthor:[de,"lastModifiedBy"]},Gr=Object.keys(zr);function an(t){let e=(t.relationships.get("/")??[]).find(n=>n.type===rn);if(!e||e.targetMode!=="Internal")return null;let o=chunkANZ44KQT_cjs.w("/",e.rawTarget);return o.ok?t.parts.get(o.partName)??null:null}function Xr(t,e){let o=an(t),[n,r]=zr[e],i=o?.root.children.find(l=>l.kind!=="textValue"&&l.namespaceUri===n&&l.localName===r);return i&&i.kind!=="textValue"?i.children.map(l=>l.kind==="textValue"?l.value:"").join(""):""}function Kn(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=Object.entries(t);return e.length>0&&e.every(([o,n])=>Object.hasOwn($n,o)&&typeof n=="string"&&n.length<=4096&&chunkANZ44KQT_cjs.O(n))}function zn(t,e){if(!Kn(e)||(t.relationships.get("/")??[]).filter(u=>u.type===rn).length>1)return null;let o=an(t);if(o&&(o.contentType!==Wn||o.root.namespaceUri!==de||o.root.localName!=="coreProperties")||!o&&(t.relationships.get("/")??[]).some(u=>u.type===rn))return null;let n=o?.name??"/docProps/core.xml";if(!o&&(t.parts.has(n)||t.partBytes.has(n)))return null;let r=chunkANZ44KQT_cjs.Aa(`<cp:coreProperties xmlns:cp="${de}" xmlns:dc="${Oe}">${Object.entries(e).map(([u,d])=>{let[c,h]=$n[u],g=c===de?"cp":"dc";return `<${g}:${h}>${chunkANZ44KQT_cjs.M(d)}</${g}:${h}>`}).join("")}</cp:coreProperties>`,{name:n,contentType:Wn});if(!r.ok)return null;if(o){let u=o,d=chunkANZ44KQT_cjs.Ia(o),c=h=>h.kind==="textValue"?{...h,id:d()}:{...h,id:d(),children:h.children.map(c)};for(let h of r.part.root.children){if(h.kind==="textValue")continue;let g=u.root.children.filter(A=>A.kind!=="textValue"&&A.namespaceUri===h.namespaceUri&&A.localName===h.localName);if(g.length>1)return null;let b=g[0],m;if(b&&b.kind!=="textValue"){if(b.children.some(N=>N.kind!=="textValue"))return null;let A=b.children.length===1&&b.children[0]?.kind==="textValue"?b.children[0]:null,I=h.children.find(N=>N.kind==="textValue"),S=A&&I?.kind==="textValue"?[{...A,value:I.value}]:h.children.map(c);m=chunkANZ44KQT_cjs.Pa(u,b.id,{...b,children:S});}else {let A=Array.from(u.root.children);A.push(c(h)),m=chunkANZ44KQT_cjs.Na(u,u.root.id,A);}if(!m.ok)return null;u=m.part;}return chunkANZ44KQT_cjs.ne(t,u)}let i=chunkANZ44KQT_cjs.xe(t,n,r.part.root,Wn);if(!i.parts.has(n))return null;let l=chunkANZ44KQT_cjs.we(i,"/",rn,n.slice(1));return l.ok?l.pkg:null}function Yr(t,e,o,n=true){let r=u=>({ok:false,error:{code:"unsupported-content",message:u}});if(!e.package)return r("document unavailable");if(t.op==="getDocumentProperty")return Gr.includes(t.name)?{ok:true,kind:"query",value:{kind:"text",text:Xr(e.package,t.name)}}:r("unsupported document property");if(t.op==="removeDocumentInformation"){if(t.removeDocInfoType!=="DocumentProperties"||!n)return {ok:false,error:{code:"unsupported-capability",message:"Only direct DocumentProperties removal outside collaboration is supported."}};if(!Un(e.package))return {ok:false,error:{code:"unsupported-capability",message:"Document property parts have unsupported structure or dependencies."}};let u=o();return u||{ok:true,kind:"command",story:Ot,ops:[],packageEdits:[d=>{let c=Un(d);if(!c)throw new Error("Document property parts changed");return c}],answer:()=>({kind:"applied"})}}if(!Kn(t.values))return r("invalid document property values");if(!n&&!an(e.package))return {ok:false,error:{code:"unsupported-capability",message:"Create document properties before joining collaboration; concurrent core-part creation cannot merge safely."}};let i={...t.values};if(!zn(e.package,i))return {ok:false,error:{code:"unsupported-capability",message:"the core properties part cannot be updated safely"}};let l=o();return l||{ok:true,kind:"command",story:Ot,ops:[],packageEdits:[u=>{let d=zn(u,i);if(!d)throw new Error("Document properties package changed");return d}],answer:()=>({kind:"applied"})}}function Jr(t,e){let o=[],n=new Set,r=i=>{if(i.kind!=="textValue"){if(i.namespaceUri===chunkANZ44KQT_cjs.fa&&i.localName===`${e}Reference`){let l=chunkANZ44KQT_cjs.jc(i)??Number.NaN;n.has(l)||(o.push(l),n.add(l));}for(let l of i.children)r(l);}};return r(t),o}var Qr=new WeakMap,gs=0;function hs(t){if(!t)return;let e=Qr.get(t);return e||(e={...t,cacheKey:`formatting-${++gs}`},Qr.set(t,e)),e}function Zr(t){let e=new WeakMap;return (o,n,r,i)=>{let l=hs(i),u=chunkANZ44KQT_cjs.La(o,n.id),d;for(;u&&u.kind!=="table";){if(u.localName==="txbxContent")return;u.kind==="tableCell"&&(d=u.id),u=chunkANZ44KQT_cjs.La(o,u.id);}if(!u||!d)return;let c=e.get(u);if(!c||c.mode!==r||c.filter!==l){let h=new Map,g=chunkUJL2GDIM_cjs.Gd(u,1,0,t,r,l);for(let b of g?.rows??[])for(let m of b.cells)h.set(m.id,m.styleFormatting);c={mode:r,filter:l,cells:h},e.set(u,c);}return c.cells.get(d)}}var qr={},ta=new WeakMap;function ea(t,e=null,o="all-markup",n){let r=t??qr,i=ta.get(r);i||ta.set(r,i=new WeakMap);let l=e??qr,u=i.get(l);u||i.set(l,u=ys(t,e));let d=u;return (c,h,g,b,m=o,A=n)=>d(c,h,g,b,m,A)}function ys(t,e){let o=chunkUJL2GDIM_cjs.gc(t,void 0,e),n=Zr(o),r=new WeakMap;return (i,l,u,d,c="all-markup",h)=>{let g=n(d,i,c,h),b=r.get(i);if(!b||b.cellStyle!==g){let N=chunkUJL2GDIM_cjs.hc(o,chunkANZ44KQT_cjs.eh(i,"paragraphProperties","pPr"),g);b={cellStyle:g,inherited:N},r.set(i,b);}let{inherited:m}=b,A=u?m.markRunProperties:chunkUJL2GDIM_cjs.jc(m.runProperties,chunkUJL2GDIM_cjs.cb(l),o),I=false,S=false;for(let N of A){if(N.localName!=="rtl"&&N.localName!=="cs")continue;let w=N.attributes?.val,E=w===void 0||["1","true","on"].includes(w);N.localName==="rtl"?I=E:S=E;}return I||S}}function na(t,e=()=>null,o=()=>"all-markup",n=()=>{}){return {runPropertyEdits(...r){return chunkANZ44KQT_cjs.th(r[0],r[1],r[2],r[3],r[4],r[5],r[6],ea(t(),e(),o(),n()))},mergedParagraphMarkProperties(...r){return chunkANZ44KQT_cjs.oh(r[0],r[1],r[2],ea(t(),e(),o(),n()))}}}function ks(t){return t?.kind!=="paragraph"?false:t.children.every(e=>e.namespaceUri!==chunkANZ44KQT_cjs.fa?false:e.localName==="pPr"?true:e.kind==="run"&&e.children.every(o=>o.namespaceUri===chunkANZ44KQT_cjs.fa&&(o.localName==="rPr"||o.localName==="t"&&o.children.every(n=>n.kind==="textValue"))))}function Gn(t,e,o){return ks(chunkANZ44KQT_cjs.Ka(t,e))&&chunkANZ44KQT_cjs.Dj(t,e,o)===null}function oa(t,e,o,n){let r=chunkANZ44KQT_cjs.Dj(t,e,o);if(!r)return null;let i=o===r.offset?chunkANZ44KQT_cjs.Yj(t,{op:"insertText",paragraphId:e,offset:o,text:n}):null;return i?.ok&&chunkANZ44KQT_cjs.Zj(i.part,e)?.slice(o,o+n.length)===n?null:{ok:false,error:{code:"unsupported-capability",message:"insert at the placeholder start or replace the complete prompt",detail:"placeholder-insertion-offset"}}}function xs(t,e,o){return t.start===t.end?e<t.start&&t.start<o:e===o?t.start<e&&e<t.end:Math.max(t.start,e)<Math.min(t.end,o)}var sn=class{#t=new Map;has(e){return this.#t.has(e)}append(e,o,n,r,i=false){let l=this.#t.get(e)??[];if(l.some(g=>xs(g,o,n)))return null;let u=o,d=n;for(let g of l){let b=g.length-(g.end-g.start);g.end<=o&&!(i&&g.start===o&&g.end===o)&&(u+=b),(g.end<n||g.end===n&&g.start!==g.end)&&(d+=b);}o===n&&(d=u);let c=r-(n-o);for(let g of l)n<=g.start&&!(o===n&&g.start===g.end&&o===g.start&&!i)&&(g.result.start+=c,g.result.end+=c);let h={start:u,end:u+r};return l.push({start:o,end:n,length:r,result:h}),this.#t.set(e,l),{start:u,end:d,result:h}}};function ra(t,e,o,n,r=false){let i=e.start.paragraphId,l=t.append(i,e.start.offset,e.end.offset,o.length,r);return l?{ok:true,kind:"command",ops:aa(i,l.start,l.end,o),story:e.start.story,answer:()=>({kind:"span",span:Ht({start:{...e.start,offset:l.result.start},end:{...e.start,offset:l.result.end}},n)})}:{ok:false,error:{code:"conflicting-operations",message:"text edits overlap in the batch snapshot",detail:i}}}function aa(t,e,o,n){let r=[];return n.length&&r.push({op:"insertText",paragraphId:t,offset:e,text:n,...o>e?{bias:"right"}:{}}),o>e&&r.push({op:"deleteText",paragraphId:t,start:e+n.length,end:o+n.length}),r}function ia(t,e,o,n){let r=e.start.paragraphId,i=chunkANZ44KQT_cjs.Zj(t,r),l=chunkANZ44KQT_cjs.Dj(t,r,e.start.offset),u=l&&o.length?[{op:"insertText",paragraphId:r,offset:e.start.offset,text:o,bias:"right"}]:aa(r,e.start.offset,e.end.offset,o),d=t;for(let h of u){let g=chunkANZ44KQT_cjs.Yj(d,h);if(!g.ok)return {ok:false,error:{code:"unsupported-content",message:"that replacement cannot preserve the targeted text safely",detail:g.reason}};d=g.part;}let c=chunkANZ44KQT_cjs.Zj(d,r);return i===null||c!==i.slice(0,e.start.offset)+o+i.slice(e.end.offset)?{ok:false,error:{code:l?"unsupported-capability":"unsupported-content",message:l?"replace the complete placeholder prompt to avoid consuming unrelated text":"that replacement changes the expected text positions",detail:r}}:{ok:true,kind:"command",ops:u,story:e.start.story,answer:()=>({kind:"span",span:Ht({start:e.start,end:{...e.start,offset:e.start.offset+o.length}},n)})}}var sa=/\s/;function la(t,e){let o=[],n=0;for(;n<t.length;){let r=null;for(let i of e){let l=t.indexOf(i,n);l<0||(!r||l<r.start||l===r.start&&i.length>r.length)&&(r={start:l,length:i.length});}if(!r)break;o.push(r),n=r.start+r.length;}return o}function da(t,e,o){let n=e[o]?.markParagraphId??null;if(n!==null)return n;let r=t.paragraphIds,i=r[r.length-1];return i===void 0||new Set(e.map(u=>u.markParagraphId).filter(u=>u!==null)).has(i)?null:i}function ua(t,e){for(let o of [t.start,t.end]){let n=e.rawText(o.paragraphId);if(n===null||o.offset>n.length)return false}return true}function pa(t,e,o){let n=e,r=o;for(;n<r&&sa.test(t[n]);)n+=1;for(;r>n&&sa.test(t[r-1]);)r-=1;return [n,r]}function ue(t){let e=t.kind==="contentControl"?chunkANZ44KQT_cjs.Ib(t):t;return e?chunkANZ44KQT_cjs.Mb(e).map(o=>o.node):[]}var ca=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),ma=new Set(["whole","content","start","end","before","after"]),fa=new Set(["richText","plainText","dropDownList","comboBox","date"]),bs=4096;function ga(t,e,o){return ["richText","plainText","comboBox","untyped"].includes(t)?typeof e!="string"?{code:"unsupported-content",message:"text is required",detail:"text"}:o!=="replace"&&o!=="start"&&o!=="end"?{code:"unsupported-content",message:"that is not a place to insert at",detail:String(o)}:null:{code:"unsupported-capability",message:"this control requires a typed value rather than a text insertion",detail:t}}function ha(t){let e=(r,i)=>({ok:false,code:"unsupported-content",message:r,detail:i});if(typeof t!="object"||t===null||!("kind"in t))return e("a control value states its kind","value");let o=t,n=o.kind;if(n==="text"||n==="listItem"){let r=n==="text"?o.text:o.value;return typeof r!="string"?e("that value is not a string",String(n)):r.length>bs?e("that value is too long",String(r.length)):{ok:true,value:n==="text"?{kind:"text",text:r}:{kind:"listItem",value:r}}}if(n==="checkbox"){let r=o.checked;return typeof r!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:r}}}if(n==="date"){let r=o.iso;return typeof r!="string"?e("a date is an ISO-8601 string","iso"):r.length>64?e("that is not a date",String(r.length)):{ok:true,value:{kind:"date",iso:r}}}return e("that is not a value any control accepts",String(n))}var As=/[\r\n\v\f\u2028\u2029]/;function ln(t,e,o){return {code:t,message:e,detail:o}}function ya(t,e=false){if(typeof t.author!="string"||!t.author.trim()||!chunkANZ44KQT_cjs.O(t.author))return ln("unsupported-content","proposals need a non-empty XML-safe author","author");let o=t.op==="proposeInsertion";return !(t.op==="proposeDeletion")&&(typeof t.text!="string"||!e&&!t.text.length||As.test(t.text)||!chunkANZ44KQT_cjs.Qg(t.text))?ln("unsupported-content","proposals need non-empty inline XML-safe text","text"):o&&t.where!=="Before"&&t.where!=="After"?ln("unsupported-content","insertion needs Before or After","where"):null}function pe(t,e,o,n,r,i=false){let l=chunkSUN62YU6_cjs.Ma(t.part),u=new Set;if(l.some(c=>c.revisionKind==="structural"))for(let c=chunkANZ44KQT_cjs.La(t.part,e);c!==null&&(u.add(c.id),c.id!==t.root.id);c=chunkANZ44KQT_cjs.La(t.part,c.id));return l.some(c=>{if(r&&c.author===r&&(["insert","paragraphMark","format"].includes(c.revisionKind)||i&&["delete","replace"].includes(c.revisionKind)))return false;if(c.revisionKind==="structural"){let h=chunkSUN62YU6_cjs.sa(c),g=0;for(let b of h){let m=chunkANZ44KQT_cjs.La(t.part,b),A=m&&chunkANZ44KQT_cjs.La(t.part,m.id),I=A?.kind==="tableRow"?"trPr":A?.kind==="tableCell"?"tcPr":null;if(!(!A||!I||chunkANZ44KQT_cjs.Kf(A,I)?.id!==m?.id)){if(u.has(A.id))return true;g+=1;}}if(h.length>0&&g===h.length)return false}return c.ranges.some(h=>{let g=t.indexOf(h.start.paragraphId),b=t.indexOf(h.end.paragraphId),m=t.indexOf(e);if(g<0||b<0||m<g||m>b)return false;let A=m===g?h.start.offset:0,I=m===b?h.end.offset:1/0;return o<=I&&n>=A})})?ln("unsupported-revision","proposal touches or overlaps a pending revision","span"):null}function ka(t,e,o,n,r,i){let l=!!n,u=(A,I,S)=>({ok:false,error:{code:A,message:I,...S?{detail:S}:{}}});if(l&&r===false)return u("unsupported-capability","tracked content-control creation is unsupported in collaboration");let d=G(t.span,e,o);if(!d.ok)return u(d.code,"that span is not a place",d.detail);if(!d.value)return u("invalid-offset","that story holds nothing to wrap","empty-story");let c=nt(t.span,e,o),h=c.ok?c.value:null;if(!h)return u("invalid-handle","that story is not in this document");let g=d.value;if(g.start.paragraphId!==g.end.paragraphId)return u("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!fa.has(t.subtype))return u("unsupported-content","that control type cannot be inserted",t.subtype);if(l){if(!chunkANZ44KQT_cjs.Ej(h.part,g.start.paragraphId,g.start.offset,g.end.offset))return u("unsupported-capability","tracked controls require a nonempty ordinary text range without existing review markup");let A=pe(h,g.start.paragraphId,g.start.offset,g.end.offset);if(A)return {ok:false,error:A}}let b=new Set(ue(h.root).map(A=>A.id)),m=i(h,g.start.paragraphId);return m||{ok:true,kind:"command",story:h.story,ops:[{op:"insertContentControl",paragraphId:g.start.paragraphId,start:g.start.offset,end:g.end.offset,type:t.subtype,...l?{revision:{author:n,date:new Date().toISOString()}}:{},...t.tag===void 0?{}:{tag:t.tag},...t.title===void 0?{}:{alias:t.title}}],answer:A=>{if(!t.returnHandle)return {kind:"applied"};let I=A.story(h.story),S=I&&ue(I.root).find(N=>!b.has(N.id));if(!S)throw new Error("content control insertion did not create a control");return {kind:"handle",handle:e.contentControl(S.id,h.story)}}}}function xa(t,e,o){let n=chunkANZ44KQT_cjs.Ka(t,e);if(!n||n.kind!=="contentControl")return false;let r=l=>l.kind==="textValue"||!l.kind.startsWith("revision")&&!l.localName.endsWith("Change")&&l.children.every(r);if(!r(n))return false;let i=chunkANZ44KQT_cjs.La(t,e);return i?.kind==="revisionInsert"&&i.attributes.some(l=>l.namespaceUri===chunkANZ44KQT_cjs.fa&&l.localName==="author"&&l.value===o)}function ba(t){if(t.length>128)return null;let e=t.trim(),o=new Set,n=[];for(;e;){let r=/^\\([ohzu])(?:\s+"([1-9])-([1-9])")?(?=\s|$)/.exec(e);if(!r)return null;let[,i,l,u]=r;if(o.has(i)||(i==="o"?!l||Number(l)>Number(u):l))return null;o.add(i),n.push(r[0]),e=e.slice(r[0].length).trimStart();}return ["TOC",...n].join(" ")}function dn(t,e){let o=chunkANZ44KQT_cjs.Ka(t,e);if(!o||o.kind!=="paragraph")return [];let n=chunkANZ44KQT_cjs.Mf(o);return chunkANZ44KQT_cjs.Ai(o).flatMap(r=>{let i=n.find(u=>u.node.id===r.fieldNodeId),l=chunkANZ44KQT_cjs.Ka(t,r.fieldNodeId);return i?[{paragraphId:e,fieldNodeId:r.fieldNodeId,code:r.instruction,start:i.start,end:i.end,rewritable:r.rewritable,locked:!!l&&chunkANZ44KQT_cjs.cf(l,"fldLock")===true}]:[]})}function Aa(t){let e=chunkANZ44KQT_cjs.N(t),o=chunkANZ44KQT_cjs.Aa(`<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:fldSimple w:instr="${e}"><w:r><w:t/></w:r></w:fldSimple></w:p></w:body></w:document>`,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!o.ok)throw new Error("could not build a field");let n=o.part.root.children.find(i=>i.kind==="body"),r=n&&chunkANZ44KQT_cjs.Cc(n)[0];if(!r||r.kind!=="paragraph")throw new Error("could not build a field paragraph");return r}var mt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function va(t,e,o,n,r){if(t.op==="getFields"||t.op==="insertField"){let h=G(t.span,e,o),g=nt(t.span,e,o);if(!h.ok||!g.ok)return mt("that field range no longer exists","invalid-handle");let b=g.value;if(t.op==="getFields")return {ok:true,kind:"query",value:{kind:"handles",handles:Yt(h.value,b).flatMap(T=>dn(b.part,T.paragraphId).filter(M=>M.start>=T.start&&M.end<=T.end)).map(T=>e.field(T.paragraphId,T.fieldNodeId,b.story))}};if(!h.value)return mt("insert a paragraph before inserting a field");if(t.removeFormatting!==void 0&&t.removeFormatting!==false)return mt("removeFormatting is not supported");if(t.text!==void 0&&typeof t.text!="string")return mt("field text must be a string");if(t.fieldType!==void 0&&typeof t.fieldType!="string")return mt("field type must be a string");let m=t.fieldType??"Empty",A=null;if(m==="Page"||m==="NumPages"){if(t.text!==void 0&&t.text.trim()!=="")return mt("field switches are not supported");A=m==="Page"?"PAGE":"NUMPAGES";}else m==="TOC"?A=ba(t.text??""):m==="Empty"&&(A=chunkANZ44KQT_cjs.Fi(t.text??""));if(!A)return mt("only PAGE, NUMPAGES, and TOC with supported switches can be inserted");let{start:I,end:S}=h.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return mt("unsupported field insert location");if(t.location==="Replace"&&I.paragraphId!==S.paragraphId)return mt("field replacement requires one paragraph");let N=t.location==="After"||t.location==="End"?S:I,w=n(b,N.paragraphId);if(w)return w;let E=[];return t.location==="Replace"&&S.offset>I.offset&&E.push({op:"deleteText",paragraphId:I.paragraphId,start:I.offset,end:S.offset}),E.push({op:"insertFragment",paragraphId:N.paragraphId,offset:N.offset,blocks:[Aa(A)],lastMarkCovered:false}),{ok:true,kind:"command",story:b.story,ops:E,answer:L=>{let T=L.story(b.story)?.part,M=T&&dn(T,N.paragraphId).find(O=>O.start===N.offset);if(!M)throw new Error("inserted field was not committed");return {kind:"handle",handle:e.field(N.paragraphId,M.fieldNodeId,b.story)}}}}let i=e.resolve(t.field,"field");if(!i||i.kind!=="field")return mt("that is not a field handle","invalid-handle");let l=o.story(i.story),u=l&&dn(l.part,i.paragraphId).find(h=>h.fieldNodeId===i.fieldNodeId);if(!l||!l.has(i.paragraphId)||!u)return mt("that field no longer exists","invalid-handle");if(t.op==="getField")return {ok:true,kind:"query",value:{kind:"field",field:{code:u.code}}};if(u.locked||chunkANZ44KQT_cjs.Df(l.part,i.fieldNodeId).content||chunkANZ44KQT_cjs.Gf(l.part,i.fieldNodeId))return mt("field is protected");let d=n(l,i.paragraphId,t.op==="updateFieldResult");if(d)return d;let c=[];if(t.op==="deleteField")c.push({op:"deleteText",paragraphId:i.paragraphId,start:u.start,end:u.end});else if(t.op==="setFieldCode"){if(!chunkANZ44KQT_cjs.Fi(u.code)||!chunkANZ44KQT_cjs.Fi(t.code))return mt("only PAGE and NUMPAGES code writes are supported");c.push({op:"setFieldCode",paragraphId:i.paragraphId,fieldNodeId:i.fieldNodeId,code:t.code});}else {let h=chunkANZ44KQT_cjs.Fi(u.code);if(!h||!u.rewritable)return mt("this field result cannot be evaluated","unsupported-capability");let g=r?.(l.story,i.paragraphId,i.fieldNodeId);if(!g||!Number.isInteger(g.pageNumber)||g.pageNumber<1||!Number.isInteger(g.pageCount)||g.pageCount<1)return mt("field update requires actual semantic pagination","unsupported-capability");let b=h==="PAGE"?g.pageNumberText??String(g.pageNumber):String(g.pageCount);c.push({op:"refreshFieldResults",updates:[{paragraphId:i.paragraphId,fieldNodeId:i.fieldNodeId,text:b}]});}return {ok:true,kind:"command",story:l.story,ops:c,answer:()=>({kind:"applied"})}}var ut=(t,e)=>({ok:false,error:{code:t,message:e,detail:e}}),Jt=t=>({ok:true,kind:"query",value:t}),vs=new Set(["insertTableRows","getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","updateTable","updateTableCell","insertTable"]);function Se(t){let e=new Set,o=[t];for(;o.length;){let n=o.pop();n.kind==="paragraph"&&e.add(n.id),n.kind!=="textValue"&&o.push(...n.children);}return e}function Ia(t,e){let o=Se(t);return [...Se(e)].filter(n=>!o.has(n)).length}function Is(t,e){let o=[{node:t}];for(;o.length;){let{node:n,table:r}=o.pop();if(n.id===e)return r;if(n.kind==="textValue")continue;let i=n.kind==="table"?n:r;for(let l of n.children)o.push({node:l,table:i});}}function Pa(t){let e=t.package&&chunkANZ44KQT_cjs.Oc(t.package);return e?[...chunkANZ44KQT_cjs.Nc(e).values()].filter(o=>o.type==="table"):[]}function Oa(t,e){if(!vs.has(t.op))return null;let{handles:o,reads:n}=e;if(t.op==="getTables"||t.op==="insertTable"){let g=t.op==="getTables"?t.scope:t.span,b=nt(g,o,n);if(!b.ok)return ut(b.code,b.detail);let m=G(g,o,n);if(!m.ok)return ut(m.code,m.detail);let A=b.value;if(t.op==="getTables"){let E=m.value,L=chunkANZ44KQT_cjs._j(A.root).filter(T=>{if("body"in g)return true;if(!E)return false;let M=[...Se(T)].sort((K,$)=>A.indexOf(K)-A.indexOf($)),O=M[0],j=M[M.length-1];return !O||!j?false:A.indexOf(O)>=E.start.index&&A.indexOf(j)<=E.end.index});return Jt({kind:"handles",handles:L.map(T=>o.table(T.id,A.story))})}if(!m.value)return ut("invalid-offset","empty-table-insertion-range");if(!["Before","After"].includes(t.location))return ut("unsupported-content","table-insertion-location");let I=t.location==="Before"?m.value.start:m.value.end,S=chunkANZ44KQT_cjs.ck(A,I.paragraphId,I.offset,t.rowCount,t.columnCount,t.values,e.trackingAuthor?{author:e.trackingAuthor,date:new Date().toISOString()}:void 0);if(!S.ok)return ut("unsupported-content",S.reason);let N=e.admitWrite(A,Ia(A.part.root,S.resultPart.root),[I.paragraphId]);if(N)return N;let w=new Set(chunkANZ44KQT_cjs._j(A.root).map(E=>E.id));return {ok:true,kind:"command",story:A.story,ops:[{op:"authorTable",action:{kind:"insert",paragraphId:I.paragraphId,offset:I.offset,rowCount:t.rowCount,columnCount:t.columnCount,...t.values?{values:t.values}:{}},...e.trackingAuthor?{revision:{author:e.trackingAuthor,date:new Date().toISOString()}}:{}}],answer:E=>{let L=E.story(A.story),T=L&&chunkANZ44KQT_cjs._j(L.root).find(M=>!w.has(M.id));return T?{kind:"handle",handle:o.table(T.id,A.story)}:{kind:"applied"}}}}let r=t.op==="getTableCells"||t.op==="insertTableRows"?"tableRow":"cell"in t?"tableCell":"table",i=t.op==="getTableCells"||t.op==="insertTableRows"?t.row:"cell"in t?t.cell:"table"in t?t.table:{kind:"document",ref:""},l=o.resolve(i,r);if(!l||!("nodeId"in l)||!("story"in l))return ut("invalid-handle","unknown-table-object");let u=n.story(l.story);if(!u)return ut("invalid-handle","missing-table-story");let d=chunkANZ44KQT_cjs.Ka(u.part,l.nodeId);if(!d||d.kind!==r)return ut("invalid-handle","deleted-table-object");let c=r==="table"?d:Is(u.root,l.nodeId);if(!c)return ut("invalid-handle","missing-parent-table");let h=chunkANZ44KQT_cjs.$j(u,c.id);if(!h)return ut("unsupported-content","unsupported-table-topology");switch(t.op){case "getTable":return Jt({kind:"table",table:{values:h.values,headerRowCount:h.headerRowCount,rowCount:h.rowIds.length,columnCount:h.columnCount,style:Pa(n).find(g=>g.styleId===h.styleId)?.name??""}});case "getTableRows":return Jt({kind:"handles",handles:h.rowIds.map(g=>o.tableRow(g,u.story))});case "getTableCells":{let g=h.rowIds.indexOf(l.nodeId);return Jt({kind:"handles",handles:(h.cellIds[g]??[]).map(b=>o.tableCell(b,u.story))})}case "getTableCell":{if(!Number.isInteger(t.rowIndex)||!Number.isInteger(t.cellIndex))return ut("invalid-offset","invalid-cell-index");let g=h.cellIds[t.rowIndex]?.[t.cellIndex];return g?Jt({kind:"handle",handle:o.tableCell(g,u.story)}):ut("invalid-handle","cell-not-found")}case "getTableCellBody":return Jt({kind:"handle",handle:o.body(u.story,l.nodeId)});case "getTableCellProperties":{let g=chunkANZ44KQT_cjs.ak(u,c.id,l.nodeId);return g?Jt({kind:"tableCell",cell:{value:g.value,columnWidth:g.columnWidth,shadingColor:g.shadingColor,verticalAlignment:g.verticalAlignment}}):ut("invalid-handle","cell-not-found")}case "insertTableRows":case "updateTable":case "updateTableCell":{let g=t.op==="insertTableRows"?{kind:"insertRows",rowId:l.nodeId,location:t.location,count:t.count,...t.values?{values:t.values}:{}}:t.op==="updateTable"?t.mutation:{...t.properties,kind:"cell",cellId:l.nodeId};if(g.kind==="properties"&&g.styleId!==void 0){let S=g.styleId;if(typeof S!="string"||S.trim().length===0)return ut("unsupported-content","invalid-table-style-name");let N=Pa(n).find(w=>w.name?.trim().toLowerCase()===S.trim().toLowerCase());if(!N)return ut("unsupported-content","table-style-not-defined");g={...g,styleId:N.styleId};}let b=e.trackingAuthor?{author:e.trackingAuthor,date:new Date().toISOString()}:void 0;if(b&&e.trackedRangeReplacement===false&&(g.kind==="values"||g.kind==="cell"&&g.value!==void 0))return ut("unsupported-capability","tracked table value replacement is unsupported in collaboration");let m=chunkANZ44KQT_cjs.bk(u,c.id,g,b);if(!m.ok)return ut(m.reason==="unsupported-revision"?"unsupported-revision":m.reason==="tracked-table-deletion-unsupported"||m.reason==="unsupported-tracked-table-operation"?"unsupported-capability":"unsupported-content",m.reason);let A=e.admitWrite(u,Ia(u.part.root,m.resultPart.root),g.kind==="values"?[...Se(c)]:g.kind==="cell"&&g.value!==void 0?[...Se(d)]:[]);if(A)return A;let I=new Set(h.rowIds);return {ok:true,kind:"command",story:u.story,ops:[{op:"authorTable",action:{kind:"existing",tableId:c.id,mutation:g},...b?{revision:b}:{}}],answer:S=>{if(g.kind!=="addRows"&&g.kind!=="insertRows")return {kind:"applied"};let N=S.story(u.story);return {kind:"handles",handles:((N&&chunkANZ44KQT_cjs.$j(N,c.id))?.rowIds??[]).filter(E=>!I.has(E)).map(E=>o.tableRow(E,u.story))}}}}default:return ut("unsupported-content","unknown-table-operation")}}var Sa=t=>({ok:false,error:{code:"unsupported-content",message:t}});function Ps(t){if(t.op==="getText")return t.target;if("body"in t)return t.body;if(t.op==="insertText"&&"body"in t.at)return t.at.body;if(t.op==="replaceSpan"&&"body"in t.span)return t.span.body;if(t.op==="insertParagraph"&&"body"in t.anchor)return t.anchor.body}function Ra(t,e,o){let n=Ps(t);if(!n)return null;let r=e.handles.resolve(n,"body");if(!r||r.kind!=="body"||r.story.kind!=="header"&&r.story.kind!=="footer")return null;let i=r.story,l=e.reads.package;if(!l||e.reads.story(i))return null;if(!e.reads.sections()[i.sectionIndex])return Sa("that section no longer exists");if(t.op==="getText")return {ok:true,kind:"query",value:{kind:"text",text:""}};if(t.op==="getParagraphs"||t.op==="getLists")return {ok:true,kind:"query",value:{kind:"handles",handles:[]}};if(t.op!=="insertText"&&t.op!=="replaceSpan"&&t.op!=="insertParagraph")return null;let u=c=>{let h=chunkANZ44KQT_cjs.rg(c,{op:"createHeaderFooter",sectionIndex:i.sectionIndex,kind:i.kind,variant:i.variant,...i.variant==="first"?{titlePage:true}:{},...i.variant==="even"?{evenAndOddHeaders:true}:{}});if(!h.ok||!h.createdPartName)return null;let g=Pe(h.package),b=o(g),m=b.plan(t);if(!m.ok||m.kind!=="command"||m.relate||m.lifecycle||m.packageEdits?.length)return null;let A=h.package.parts.get(h.createdPartName);if(!A)return null;for(let S of m.ops){let N=chunkANZ44KQT_cjs.Yj(A,S);if(!N.ok)return null;A=N.part;}let I=chunkANZ44KQT_cjs.ne(h.package,A);return b.settle(Pe(I)).ok?{pkg:I,planner:b,step:m}:null},d=u(l);return d?{ok:true,kind:"command",story:{kind:"body"},ops:[],solitary:true,packageEdits:[c=>{let h=u(c);if(!h)throw new Error("header/footer creation changed during transaction");return d=h,h.pkg}],answer:c=>d.step.answer(c)}:Sa("cannot create this header or footer with that content")}var Os=20*1024*1024;function Ss(t){if(typeof t!="string"||t.length===0||t.length>Math.ceil(Os/3)*4||t.length%4!==0)return null;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-o),r=0;for(let i=0;i<t.length;i+=4){let l=i+4===t.length,u=l?4-o:4,d=[0,0,0,0];for(let h=0;h<u;h++){let g=e.indexOf(t[i+h]);if(g<0)return null;d[h]=g;}if(l&&(o===2&&(d[1]&15)!==0||o===1&&(d[2]&3)!==0))return null;let c=d[0]<<18|d[1]<<12|d[2]<<6|d[3];r<n.length&&(n[r++]=c>>>16),r<n.length&&(n[r++]=c>>>8),r<n.length&&(n[r++]=c);}return n}function wa(t,e,o,n,r){let i=Ss(r);if(!i)return {ok:false,detail:"picture: invalid or oversized base64 (20 MiB maximum)"};let l=chunkANZ44KQT_cjs.Od(i);if(l!=="image/png"&&l!=="image/jpeg")return {ok:false,detail:"picture: only PNG and JPEG are supported"};if(!Rs(i,l))return {ok:false,detail:"picture: truncated raster container"};let u=chunkANZ44KQT_cjs.Td(i,l);if(!u||u.pixelWidth*u.pixelHeight>4e7)return {ok:false,detail:"picture: invalid or oversized raster dimensions"};let d=u.pixelWidth*72/(u.dpiX??96),c=u.pixelHeight*72/(u.dpiY??96),h=chunkANZ44KQT_cjs.fe(d),g=chunkANZ44KQT_cjs.fe(c);if(h===null||g===null)return {ok:false,detail:"picture: invalid physical dimensions"};let b=chunkANZ44KQT_cjs.ce(t,e,{bytes:i,mime:l});if(!b.ok)return {ok:false,detail:`picture: ${b.reason}`};let m=chunkANZ44KQT_cjs.ge({docPrId:b.docPrId,lockAspectRatio:true,relationshipId:b.relationshipId,extentEmu:{cx:h,cy:g}});return {ok:true,docPrId:b.docPrId,ops:[{op:"insertDrawing",paragraphId:o,offset:n,drawing:m}],packageEdits:[A=>{let I=chunkANZ44KQT_cjs.ce(A,e,{bytes:i,mime:l});if(!I.ok||I.relationshipId!==b.relationshipId||I.docPrId!==b.docPrId||I.partName!==b.partName)throw new Error("picture allocation changed during the batch");return I.pkg}]}}function Ca(t,e){return chunkANZ44KQT_cjs.xd(t).find(o=>o.drawingNodeId===e&&o.kind==="inline"&&o.picture!==null)??null}function Ta(t){return {width:t.extentEmu.cx/chunkANZ44KQT_cjs.ee,height:t.extentEmu.cy/chunkANZ44KQT_cjs.ee,lockAspectRatio:t.locks.changeAspect,altTextDescription:t.description}}function Na(t,e){let o=new Set(chunkANZ44KQT_cjs.xd(t).filter(r=>r.kind==="inline"&&r.picture!==null).map(r=>r.drawingNodeId)),n=[];for(let r of e){let i=chunkANZ44KQT_cjs.Ka(t,r.paragraphId);if(!(!i||i.kind!=="paragraph"))for(let l of chunkANZ44KQT_cjs.Mf(i))l.start>=r.start&&l.end<=r.end&&o.has(l.node.id)&&n.push(l.node.id);}return n}function Ea(t,e){let o=[],n=t.drawingNodeId;if(e.lockAspectRatio!==void 0&&typeof e.lockAspectRatio!="boolean")return {ok:false,detail:"lockAspectRatio: not a boolean"};let r=e.lockAspectRatio??t.locks.changeAspect;if(e.lockAspectRatio===false&&o.push({op:"setDrawingLocks",drawingNodeId:n,locks:{changeAspect:false}}),e.width!==void 0||e.height!==void 0){let i=e.width??t.extentEmu.cx/chunkANZ44KQT_cjs.ee,l=e.height??t.extentEmu.cy/chunkANZ44KQT_cjs.ee;if(r){let c=t.extentEmu.cx/t.extentEmu.cy;if(e.width!==void 0&&e.height!==void 0&&Math.abs(i/l-c)>1e-6)return {ok:false,detail:"picture: width and height disagree with the locked aspect ratio"};e.width!==void 0&&e.height===void 0&&(l=i/c),e.height!==void 0&&e.width===void 0&&(i=l*c);}let u=chunkANZ44KQT_cjs.fe(i),d=chunkANZ44KQT_cjs.fe(l);if(u===null||d===null)return {ok:false,detail:"picture: dimensions must be finite positive points"};o.push({op:"resizeDrawing",drawingNodeId:n,extentEmu:{cx:u,cy:d}});}if(e.lockAspectRatio===true&&o.push({op:"setDrawingLocks",drawingNodeId:n,locks:{changeAspect:true}}),e.altTextDescription!==void 0){if(typeof e.altTextDescription!="string"||e.altTextDescription.length>32767||!chunkANZ44KQT_cjs.O(e.altTextDescription))return {ok:false,detail:"altTextDescription: invalid XML text or length"};o.push({op:"setDrawingMetadata",drawingNodeId:n,title:t.title,description:e.altTextDescription});}return o.length?{ok:true,ops:o}:{ok:false,detail:"picture: no properties requested"}}function Rs(t,e){if(e==="image/jpeg")return t.length>=4&&t[t.length-2]===255&&t[t.length-1]===217;let o=new DataView(t.buffer,t.byteOffset,t.byteLength),n=8,r=false;for(;n+12<=t.length;){let i=o.getUint32(n);if(i>t.length-n-12)return false;let l=String.fromCharCode(t[n+4],t[n+5],t[n+6],t[n+7]);if(l==="IDAT"&&i>0&&(r=true),n+=i+12,l==="IEND")return r&&i===0&&n===t.length}return false}var wt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function La(t,e,o,n){if(t.op==="getInlinePictures"||t.op==="insertInlinePicture"){let h=G(t.span,e,o),g=nt(t.span,e,o);if(!h.ok||!g.ok)return wt("that picture range no longer exists","invalid-handle");let b=g.value;if(t.op==="getInlinePictures")return {ok:true,kind:"query",value:{kind:"handles",handles:Na(b.part,Yt(h.value,b)).map(L=>e.inlinePicture(L,b.story))}};if(!h.value||!o.package)return wt("insert a paragraph before inserting a picture");let{start:m,end:A}=h.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return wt("unsupported picture insert location");if(t.location==="Replace"&&m.paragraphId!==A.paragraphId)return wt("picture replacement requires a single paragraph");let I=t.location==="After"||t.location==="End"?A:m;if(chunkANZ44KQT_cjs.Df(b.part,I.paragraphId).content||chunkANZ44KQT_cjs.Gf(b.part,I.paragraphId))return wt("picture insertion is inside protected content");let S=chunkANZ44KQT_cjs.Ka(b.part,I.paragraphId);if(S?.kind==="paragraph"){for(let L of chunkANZ44KQT_cjs.Mf(S))if((t.location==="Replace"?L.start<A.offset&&L.end>m.offset:L.start<I.offset&&L.end>I.offset)&&(chunkANZ44KQT_cjs.Df(b.part,L.node.id).content||chunkANZ44KQT_cjs.Gf(b.part,L.node.id)))return wt("picture insertion touches protected content")}let N=n(b,I.paragraphId);if(N)return N;let w=wa(o.package,b.part.name,I.paragraphId,I.offset,t.base64);if(!w.ok)return wt(w.detail);let E=[];return t.location==="Replace"&&A.offset>m.offset&&E.push({op:"deleteText",paragraphId:m.paragraphId,start:m.offset,end:A.offset}),E.push(...w.ops),{ok:true,kind:"command",story:b.story,ops:E,packageEdits:w.packageEdits,answer:L=>{let T=L.story(b.story)?.part,M=T&&chunkANZ44KQT_cjs.xd(T).find(O=>O.docPrId===w.docPrId&&O.kind==="inline");if(!M)throw new Error("inserted picture was not committed");return {kind:"handle",handle:e.inlinePicture(M.drawingNodeId,b.story)}}}}let r=e.resolve(t.picture,"inlinePicture");if(!r||r.kind!=="inlinePicture")return wt("that is not a picture handle","invalid-handle");let i=o.story(r.story),l=i&&Ca(i.part,r.drawingNodeId);if(!i||!l)return wt("that inline picture no longer exists","invalid-handle");if(t.op==="getInlinePicture")return {ok:true,kind:"query",value:{kind:"inlinePicture",picture:Ta(l)}};let u=chunkANZ44KQT_cjs.Ka(i.part,r.drawingNodeId);for(;u&&u.kind!=="paragraph";)u=chunkANZ44KQT_cjs.Lf(i.part,u.id);if(!u||!i.has(u.id))return wt("picture is outside this story","invalid-handle");let d=n(i,u.id);if(d)return d;let c=t.op==="deleteInlinePicture"?{ok:true,ops:[{op:"deleteDrawing",drawingNodeId:r.drawingNodeId}]}:Ea(l,t.properties);return c.ok?{ok:true,kind:"command",story:i.story,ops:c.ops,answer:()=>({kind:"applied"})}:wt(c.detail)}function Ma(t,e,o,n){let r=b=>({ok:false,error:{code:"unsupported-content",message:b}});if(t.breakType!=="Page"&&t.breakType!=="SectionNext")return r("only Page and SectionNext breaks are supported");if(!["Before","After","Start","End","Replace"].includes(t.location))return r("invalid break insertion location");let i=G(t.span,e,o);if(!i.ok)return {ok:false,error:{code:i.code,message:i.detail}};let l=i.value;if(!l)return r("empty story has no break position");let u=t.location==="After"||t.location==="End"?l.end:l.start,d=o.story(u.story);if(!d)return r("missing story");if(t.location==="Replace"&&l.start.paragraphId!==l.end.paragraphId)return r("break replacement must remain in one paragraph");let c=t.breakType==="SectionNext";if(c&&(d.story.kind!=="body"||chunkANZ44KQT_cjs.jj(d.part,u.paragraphId)))return r("section breaks require a body paragraph outside a table");let h=n(d,u.paragraphId,c?1:0);if(h)return h;let g=[];return t.location==="Replace"&&l.end.offset>l.start.offset&&g.push({op:"deleteText",paragraphId:u.paragraphId,start:l.start.offset,end:l.end.offset}),c?g.push({op:"splitParagraph",paragraphId:u.paragraphId,offset:u.offset},{op:"setSectionMark",paragraphId:u.paragraphId,breakType:"nextPage"}):g.push({op:"insertPageBreak",paragraphId:u.paragraphId,offset:u.offset}),{ok:true,kind:"command",story:d.story,ops:g,answer:()=>({kind:"applied"})}}var Et=(t,e)=>t.children.find(o=>o.kind!=="textValue"&&o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName===e),Ct=(t,e)=>t.attributes.find(o=>o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName===e)?.value,un=t=>t.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">"),Xn=t=>typeof t=="string"&&t.length<=255&&!/[\x00-\x08\x0b\x0c\x0e-\x1f\uFFFE\uFFFF]/.test(t),Fa={None:"none",Arabic:"decimal",UpperRoman:"upperRoman",LowerRoman:"lowerRoman",UpperLetter:"upperLetter",LowerLetter:"lowerLetter"},Ha={Solid:["\uF0B7","Symbol"],Hollow:["o","Courier New"],Square:["\uF0A7","Wingdings"],Diamonds:["\uF076","Wingdings"],Arrow:["\uF0D8","Wingdings"],Checkmark:["\uF0FC","Wingdings"]};function Yn(t){let e=chunkANZ44KQT_cjs.eg(t,"bullet");if(!e)return null;let o=e.pkg;for(let n=0;n<=8;n+=1)if(!Re(o,e.numId,n)){let r=pn(o,e.numId,n,{bullet:n%3===0?"Solid":n%3===1?"Hollow":"Square"});if(!r)return null;o=r;}return {pkg:o,numId:e.numId}}function Re(t,e,o){let n=t.parts.get("/word/numbering.xml")?.root;if(!n)return false;let r=n.children,i=r.find(c=>c.kind!=="textValue"&&c.namespaceUri===chunkANZ44KQT_cjs.fa&&c.localName==="num"&&Ct(c,"numId")===e);if(!i)return false;let l=i.children.find(c=>c.kind!=="textValue"&&c.namespaceUri===chunkANZ44KQT_cjs.fa&&c.localName==="lvlOverride"&&Ct(c,"ilvl")===String(o));if(l&&Et(l,"lvl"))return true;let u=Et(i,"abstractNumId"),d=u&&r.find(c=>c.kind!=="textValue"&&c.namespaceUri===chunkANZ44KQT_cjs.fa&&c.localName==="abstractNum"&&Ct(c,"abstractNumId")===Ct(u,"val"));return !!d&&!Et(d,"numStyleLink")&&d.children.some(c=>c.kind!=="textValue"&&c.namespaceUri===chunkANZ44KQT_cjs.fa&&c.localName==="lvl"&&Ct(c,"ilvl")===String(o))}function Jn(t,e){if(!Number.isInteger(t)||t<0||t>8||!e||typeof e!="object")return false;if(e.bullet!==void 0){if(e.numbering!==void 0)return false;if(e.bullet==="Custom"){if(!Number.isInteger(e.charCode)||e.charCode<1||e.charCode>65535||e.charCode>=55296&&e.charCode<=57343||!Xn(String.fromCharCode(e.charCode)))return false}else if(!Object.hasOwn(Ha,e.bullet))return false;if(e.fontName!==void 0&&(!Xn(e.fontName)||!e.fontName.trim()))return false}if(e.numbering!==void 0&&!Object.hasOwn(Fa,e.numbering)||e.formatString!==void 0&&(!Array.isArray(e.formatString)||e.formatString.length>32||e.formatString.some(n=>typeof n=="number"?!Number.isInteger(n)||n<0||n>t:!Xn(n)||/%[1-9]/.test(n)))||e.startingNumber!==void 0&&(!Number.isInteger(e.startingNumber)||e.startingNumber<0||e.startingNumber>2147483647))return false;for(let n of [e.textIndent,e.bulletNumberPictureIndent])if(n!==void 0&&(!Number.isFinite(n)||Math.abs(n)>1584))return false;let o=["bullet","charCode","fontName","numbering","formatString","startingNumber","textIndent","bulletNumberPictureIndent"];return Object.keys(e).some(n=>!o.includes(n))||e.bullet===void 0&&(e.charCode!==void 0||e.fontName!==void 0)||e.numbering===void 0&&e.formatString!==void 0?false:Object.keys(e).length>0}function pn(t,e,o,n){if(!Jn(o,n))return null;let r=t.parts.get("/word/numbering.xml");if(!r)return null;let i=r.root.children.find(O=>O.kind!=="textValue"&&O.namespaceUri===chunkANZ44KQT_cjs.fa&&O.localName==="num"&&Ct(O,"numId")===e),l=i&&Et(i,"abstractNumId");if(!i||!l)return null;let u=r.root.children.find(O=>O.kind!=="textValue"&&O.namespaceUri===chunkANZ44KQT_cjs.fa&&O.localName==="abstractNum"&&Ct(O,"abstractNumId")===Ct(l,"val"));if(!u||Et(u,"numStyleLink"))return null;let d=i.children.find(O=>O.kind!=="textValue"&&O.namespaceUri===chunkANZ44KQT_cjs.fa&&O.localName==="lvlOverride"&&Ct(O,"ilvl")===String(o)),c=(d&&Et(d,"lvl"))??u.children.find(O=>O.kind!=="textValue"&&O.namespaceUri===chunkANZ44KQT_cjs.fa&&O.localName==="lvl"&&Ct(O,"ilvl")===String(o));if(c&&Et(c,"lvlPicBulletId"))return null;let h=chunkANZ44KQT_cjs.Ia(r),g=O=>O.kind==="textValue"?{...O,id:h()}:{...O,id:h(),children:O.children.map(g)},b=O=>{let j=chunkANZ44KQT_cjs.Aa(`<w:numbering xmlns:w="${chunkANZ44KQT_cjs.fa}">${O}</w:numbering>`,{name:r.name,contentType:r.contentType}),K=j.ok?j.part.root.children[0]:void 0;return K&&K.kind!=="textValue"?g(K):null};if(c??=b(`<w:lvl w:ilvl="${o}"><w:start w:val="1"/><w:numFmt w:val="decimal"/><w:lvlText w:val="%${o+1}."/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(o+1)}" w:hanging="360"/></w:pPr></w:lvl>`)??void 0,!c)return null;let m=[...c.children],A=["start","numFmt","lvlRestart","pStyle","isLgl","suff","lvlText","lvlPicBulletId","legacy","lvlJc","pPr","rPr"],I=(O,j)=>{let K=b(j);if(!K)return false;let $=m.findIndex(B=>B.kind!=="textValue"&&B.namespaceUri===chunkANZ44KQT_cjs.fa&&B.localName===O);if($>=0){let B=m[$];m.splice($,1,{...B,attributes:[...B.attributes.filter(Z=>!K.attributes.some(et=>et.namespaceUri===Z.namespaceUri&&et.localName===Z.localName)),...K.attributes]});}else {let B=m.findIndex(Z=>Z.kind!=="textValue"&&Z.namespaceUri===chunkANZ44KQT_cjs.fa&&A.indexOf(Z.localName)>A.indexOf(O));m.splice(B<0?m.length:B,0,K);}return true};if(n.startingNumber!==void 0&&!I("start",`<w:start w:val="${n.startingNumber}"/>`))return null;if(n.numbering!==void 0){let O=n.formatString?.map(j=>typeof j=="number"?`%${j+1}`:j).join("")??(n.numbering==="None"?"":`%${o+1}.`);if(!I("numFmt",`<w:numFmt w:val="${Fa[n.numbering]}"/>`)||!I("lvlText",`<w:lvlText w:val="${un(O)}"/>`))return null}if(n.numbering!==void 0&&(m=m.map(O=>O.kind!=="textValue"&&O.namespaceUri===chunkANZ44KQT_cjs.fa&&O.localName==="rPr"?{...O,children:O.children.filter(j=>j.kind==="textValue"||j.namespaceUri!==chunkANZ44KQT_cjs.fa||j.localName!=="rFonts")}:O)),n.bullet!==void 0){let[O,j]=n.bullet==="Custom"?[String.fromCharCode(n.charCode),n.fontName??"Symbol"]:Ha[n.bullet];if(!I("numFmt",'<w:numFmt w:val="bullet"/>')||!I("lvlText",`<w:lvlText w:val="${un(O)}"/>`))return null;let K=Et(c,"rPr"),$=b(`<w:rFonts w:ascii="${un(j)}" w:hAnsi="${un(j)}"/>`);if(!$)return null;let B=K?.children.filter(rt=>rt.kind==="textValue"||rt.namespaceUri!==chunkANZ44KQT_cjs.fa||rt.localName!=="rFonts")??[],Z=K?{...K,children:[$,...B]}:b("<w:rPr/>");if(!Z)return null;let et=m.findIndex(rt=>rt.kind!=="textValue"&&rt.namespaceUri===chunkANZ44KQT_cjs.fa&&rt.localName==="rPr");et<0?m.push({...Z,children:[$,...B]}):m[et]={...Z,children:[$,...B]};}if(n.textIndent!==void 0||n.bulletNumberPictureIndent!==void 0){let O=Et(c,"pPr"),j=O&&Et(O,"ind"),K=j?.attributes.filter(X=>X.namespaceUri!==chunkANZ44KQT_cjs.fa||!["left","start","firstLine","hanging"].includes(X.localName))??[],$=n.textIndent===void 0?String(chunkANZ44KQT_cjs._c(Ct(j??c,"left"))??0):String(Math.round(n.textIndent*20)),B=n.bulletNumberPictureIndent,Z=B===void 0?j?.attributes.filter(X=>X.namespaceUri===chunkANZ44KQT_cjs.fa&&["firstLine","hanging"].includes(X.localName))??[]:[],et=b(`<w:ind w:left="${$}"${B===void 0?"":` w:${B<0?"hanging":"firstLine"}="${Math.abs(Math.round(B*20))}"`}/>`);if(!et)return null;let rt={...et,attributes:[...K,...Z,...et.attributes]},It=O?.children.filter(X=>X.kind==="textValue"||X.namespaceUri!==chunkANZ44KQT_cjs.fa||X.localName!=="ind")??[],bt=O??b("<w:pPr/>");if(!bt)return null;let it=j?O.children.indexOf(j):-1,st=[...It],U=["contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"],dt=st.findIndex(X=>X.kind!=="textValue"&&X.namespaceUri===chunkANZ44KQT_cjs.fa&&U.includes(X.localName));st.splice(it>=0?it:dt>=0?dt:st.length,0,rt);let gt={...bt,children:st},q=m.findIndex(X=>X.kind!=="textValue"&&X.namespaceUri===chunkANZ44KQT_cjs.fa&&X.localName==="pPr");if(q>=0)m[q]=gt;else {let X=m.findIndex(Ut=>Ut.kind!=="textValue"&&Ut.localName==="rPr"&&Ut.namespaceUri===chunkANZ44KQT_cjs.fa);m.splice(X<0?m.length:X,0,gt);}}let S=g({...c,children:m}),N=d?.children.filter(O=>O.kind==="textValue"||O.namespaceUri!==chunkANZ44KQT_cjs.fa||O.localName!=="lvl"&&(n.startingNumber===void 0||O.localName!=="startOverride"))??[],w=d??b(`<w:lvlOverride w:ilvl="${o}"/>`);if(!w)return null;let E={...w,children:[...N,S]},L=[...i.children],T=d?L.indexOf(d):-1;T>=0?L[T]=E:L.push(E);let M=chunkANZ44KQT_cjs.Pa(r,i.id,{...i,children:L});return M.ok?chunkANZ44KQT_cjs.ne(t,M.part):null}function Qt(t,e){return t&&"children"in t?t.children.find(o=>o.kind!=="textValue"&&o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName===e):void 0}function Qn(t,e){return t&&"attributes"in t?t.attributes.find(o=>o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName===e)?.value:void 0}function Da(t,e,o,n){return e.length>0&&e.every(r=>{let i=Qt(chunkANZ44KQT_cjs.Ka(t.part,r)??void 0,"pPr");if(Qn(Qt(Qt(i,"rPr"),"ins"),"author")===n)return true;let l=Qt(i,"pPrChange"),u=Qt(l,"pPr");return Qn(l,"author")===n&&Qn(Qt(Qt(u,"numPr"),"numId"),"val")!==o})}var ce=8;function ja(t){if(!t||t.kind==="textValue")return null;for(let e of t.attributes)if(e.namespaceUri===chunkANZ44KQT_cjs.fa&&e.localName==="val")return e.value;return null}function cn(t){let e=chunkANZ44KQT_cjs.Kf(chunkANZ44KQT_cjs.If(t),"numPr");if(!e)return null;let o=ja(chunkANZ44KQT_cjs.Kf(e,"numId"));if(o===null||!/^\d{1,10}$/.test(o)||o==="0")return null;let n=ja(chunkANZ44KQT_cjs.Kf(e,"ilvl")),r=n===null?0:Number(n);return !Number.isInteger(r)||r<0||r>ce?null:{numId:o,level:r}}function Zt(t){let e=new Map;for(let o of t.paragraphIds){let n=t.node(o);if(!n)continue;let r=cn(n);if(!r)continue;let i=e.get(r.numId);i?i.push(o):e.set(r.numId,[o]);}return Object.freeze([...e].map(([o,n])=>Object.freeze({numId:o,paragraphIds:Object.freeze(n)})))}function we(t,e){let o=t.node(e);return o?cn(o):null}var kt=t=>({ok:false,error:{code:"unsupported-content",message:t}});function ws(t,e){if(t.root.namespaceUri!==chunkANZ44KQT_cjs.fa||t.root.localName!=="styles")return false;let o=[t.root];for(;o.length;){let n=o.pop();if(n.kind!=="textValue"){if(n.namespaceUri===chunkANZ44KQT_cjs.fa&&n.localName==="numId"&&n.attributes.some(r=>r.namespaceUri===chunkANZ44KQT_cjs.fa&&r.localName==="val"&&r.value===e))return true;for(let r of n.children)o.push(r);}}return false}function Ba(t,e,o,n,r){let i=o.package;if(!i)return kt("no document");if(t.op==="setListLevelFormat"){let m=e.resolve(t.list,"list");if(!m||m.kind!=="list")return kt("that is not a list");let A=o.story(m.story),I=A&&Zt(A).find(S=>S.numId===m.numId);if(!A||!I)return kt("that list no longer exists");if(r&&!Da(A,I.paragraphIds,m.numId,r))return {ok:false,error:{code:"unsupported-capability",message:"Only a newly proposed list definition can change while tracking"}};if(!Jn(t.level,t.format))return kt("invalid list level format");for(let S of i.parts.values()){if(ws(S,m.numId))return kt("list is referenced by a style");for(let N of chunkANZ44KQT_cjs.zc(S))for(let w of chunkANZ44KQT_cjs.Cc(N.root))if(cn(w)?.numId===m.numId&&!A.has(w.id))return kt("list is shared across stories")}for(let S of I.paragraphIds){if(chunkANZ44KQT_cjs.Df(A.part,S).content||chunkANZ44KQT_cjs.Gf(A.part,S))return kt("list contains protected content");let N=n(A,S,{numId:m.numId,level:t.level});if(N)return N}return pn(i,m.numId,t.level,t.format)?{ok:true,kind:"command",story:A.story,ops:[],packageEdits:[S=>{let N=pn(S,m.numId,t.level,t.format);if(!N)throw new Error("list definition changed during transaction");return N}],answer:()=>({kind:"applied"})}:kt("cannot format this list")}let l=yt(t.paragraph,e,o);if(!l.ok)return {ok:false,error:{code:l.code,message:l.detail}};let u=o.story(l.value.story);if(!u)return kt("missing story");let d=n(u,l.value.paragraphId);if(d)return d;let c=null,h=0,g=[];if(t.op==="startNewList"){let m=Yn(i);if(!m)return kt("cannot create numbering definition");let A=l.value.paragraphId;if(!chunkANZ44KQT_cjs.Yj(u.part,{op:"setListNumbering",paragraphId:A,numId:m.numId,level:0}).ok)return kt("cannot number this paragraph");let S=m.numId;return {ok:true,kind:"command",story:u.story,ops:[],packageEdits:[N=>{let w=Yn(N),E=w?.pkg.parts.get(u.part.name);if(!w||!E)throw new Error("cannot create numbering definition");let L=chunkANZ44KQT_cjs.Yj(E,{op:"setListNumbering",paragraphId:A,numId:w.numId,level:0,...r?{revision:{author:r,date:new Date().toISOString()}}:{}});if(!L.ok)throw new Error("cannot number this paragraph");return S=w.numId,chunkANZ44KQT_cjs.ne(w.pkg,L.part)}],answer:()=>({kind:"handle",handle:e.list(S,u.story)})}}else if(t.op==="attachToList"){if(!Number.isSafeInteger(t.listId)||t.listId<=0||!Number.isInteger(t.level)||t.level<0||t.level>8)return kt("invalid list identity or level");if(c=String(t.listId),h=t.level,!Re(i,c,h))return kt("list level is not defined; configure that level first");if(!Zt(u).some(m=>m.numId===c))return kt("that list does not exist in this story")}let b=c;return {ok:true,kind:"command",story:u.story,ops:[{op:"setListNumbering",paragraphId:l.value.paragraphId,numId:t.op==="detachFromList"?"0":c,level:h}],packageEdits:g,answer:()=>b===null?{kind:"applied"}:{kind:"handle",handle:e.list(b,u.story)}}}var Zn=Object.freeze({None:"none",Single:"single",Word:"words",Double:"double",Thick:"thick",Dotted:"dotted",DottedHeavy:"dottedHeavy",DashLine:"dash",DashLineHeavy:"dashedHeavy",DashLineLong:"dashLong",DashLineLongHeavy:"dashLongHeavy",DotDashLine:"dotDash",DotDashLineHeavy:"dashDotHeavy",TwoDotDashLine:"dotDotDash",TwoDotDashLineHeavy:"dashDotDotHeavy",Wave:"wave",WaveHeavy:"wavyHeavy",WaveDouble:"wavyDouble"}),_a=[["Yellow","yellow","#FFFF00"],["Lime","green","#00FF00"],["Turquoise","cyan","#00FFFF"],["Pink","magenta","#FF00FF"],["Blue","blue","#0000FF"],["Red","red","#FF0000"],["DarkBlue","darkBlue","#000080"],["Teal","darkCyan","#008080"],["Green","darkGreen","#008000"],["Purple","darkMagenta","#800080"],["DarkRed","darkRed","#800000"],["Olive","darkYellow","#808000"],["Gray","darkGray","#808080"],["LightGray","lightGray","#C0C0C0"],["Black","black","#000000"],["White","white","#FFFFFF"]];function Va(t){return Object.entries(Zn).find(([,e])=>e===t)?.[0]??null}function Ua(t){return _a.find(([,e])=>e===t)?.[2]??null}function Wa(t){let e=[];if(t.underline!==void 0){let o=typeof t.underline=="string"&&Object.hasOwn(Zn,t.underline)?Zn[t.underline]:void 0;if(!o)return {ok:false,detail:"underline: unsupported underline style"};e.push({localName:"u",attributes:{val:o}});}if(t.strikeThrough!==void 0){if(typeof t.strikeThrough!="boolean")return {ok:false,detail:"strikeThrough: not a boolean"};e.push({localName:"strike",attributes:{val:t.strikeThrough?"1":"0"}});}for(let o of ["subscript","superscript"])if(t[o]!==void 0&&typeof t[o]!="boolean")return {ok:false,detail:`${o}: not a boolean`};if(t.subscript===true&&t.superscript===true)return {ok:false,detail:"subscript and superscript are mutually exclusive"};if(t.highlightColor!==void 0){let o=t.highlightColor,n=typeof o=="string"?_a.find(([r,,i])=>r.toLowerCase()===o.toLowerCase()||i===o.toUpperCase()):void 0;if(o!==null&&!n)return {ok:false,detail:"highlightColor: use an exact Word palette color or null to clear"};e.push({localName:"highlight",attributes:{val:n?.[1]??"none"}});}return {ok:true,value:e}}var Cs=31680,Ts=1999,Ns=Object.freeze({bold:null,italic:null,underline:null,strikeThrough:null,highlightColor:null,subscript:null,superscript:null,name:null,size:null,color:null});function pt(t,e){if(!t)return null;for(let o of t.attributes)if(o.localName===e)return o.value;return null}function fn(t){if(!t)return null;let e=pt(t,"val");if(e===null)return true;let o=e.trim().toLowerCase();return !(o==="0"||o==="false"||o==="off"||o==="none")}function Es(t){if(t===null)return null;let e=t.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function Ls(t){if(t===null)return null;let e=Number(t.trim());return !Number.isFinite(e)||e<=0?null:e/2}function qt(t){let e=chunkANZ44KQT_cjs._c(t??void 0);return e===null?null:chunkANZ44KQT_cjs.Yc(chunkANZ44KQT_cjs.Wc(e))}function Lt(t){if(t.length===0)return null;let e=t[0];if(e===null)return null;for(let o of t)if(o!==e)return null;return e}function za(t,e,o=chunkANZ44KQT_cjs.Yg){let n=[];for(let r of e)for(let i of chunkANZ44KQT_cjs.vh(t,r.paragraphId,r.start,r.end,o))n.push(chunkANZ44KQT_cjs.Jf(i));return n.length===0?Ns:{bold:Lt(n.map(r=>fn(chunkANZ44KQT_cjs.Kf(r,"b")))),italic:Lt(n.map(r=>fn(chunkANZ44KQT_cjs.Kf(r,"i")))),underline:Lt(n.map(r=>Va(pt(chunkANZ44KQT_cjs.Kf(r,"u"),"val")))),strikeThrough:Lt(n.map(r=>fn(chunkANZ44KQT_cjs.Kf(r,"strike")))),highlightColor:Lt(n.map(r=>Ua(pt(chunkANZ44KQT_cjs.Kf(r,"highlight"),"val")))),subscript:Lt(n.map(r=>Ka(r,"subscript"))),superscript:Lt(n.map(r=>Ka(r,"superscript"))),name:Lt(n.map(r=>{let i=chunkANZ44KQT_cjs.Kf(r,"rFonts"),l=pt(i,"ascii");return l===null||l.length===0?null:l})),size:Lt(n.map(r=>Ls(pt(chunkANZ44KQT_cjs.Kf(r,"sz"),"val")))),color:Lt(n.map(r=>Es(pt(chunkANZ44KQT_cjs.Kf(r,"color"),"val"))))}}var Ms=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),Fs=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function Hs(t){let e=pt(chunkANZ44KQT_cjs.Kf(t,"jc"),"val");return e===null?"Unknown":Ms[e.trim().toLowerCase()]??"Unknown"}function Ga(t,e,o){let n=chunkANZ44KQT_cjs.Ka(t,e);if(!n||n.kind!=="paragraph")return null;let r=chunkANZ44KQT_cjs.If(n),i=chunkANZ44KQT_cjs.Kf(r,"spacing"),l=chunkANZ44KQT_cjs.Kf(r,"ind");return {alignment:Hs(r),style:qe(t,e,o),firstLineIndent:Ds(l),leftIndent:qt(pt(l,"left")??pt(l,"start")),rightIndent:qt(pt(l,"right")??pt(l,"end")),lineSpacing:qt(pt(i,"line")),spaceBefore:qt(pt(i,"before")),spaceAfter:qt(pt(i,"after")),widowControl:fn(chunkANZ44KQT_cjs.Kf(r,"widowControl"))}}function Ds(t){let e=qt(pt(t,"hanging"));if(e!==null&&e>0)return -e;let o=qt(pt(t,"firstLine"));return o!==null?o:e===null?null:-e}function mn(t,e){if(typeof t!="number"||!Number.isFinite(t))return {ok:false,detail:`${e}: not a measurement`};let o=chunkANZ44KQT_cjs.Zc(chunkANZ44KQT_cjs.Xc(t));return Math.abs(o)>Cs?{ok:false,detail:`${e}: out of range`}:{ok:true,value:o}}function Xa(t){let e=Wa(t);if(!e.ok)return e;let o=e.value;if(t.bold!==void 0){if(typeof t.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};o.push({localName:"b",...t.bold?{}:{attributes:{val:"0"}}});}if(t.italic!==void 0){if(typeof t.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};o.push({localName:"i",...t.italic?{}:{attributes:{val:"0"}}});}if(t.name!==void 0){let n=t.name;if(typeof n!="string"||n.length===0||n.length>128)return {ok:false,detail:"name: not a font name"};if(!chunkANZ44KQT_cjs.O(n))return {ok:false,detail:"name: not valid XML text"};o.push({localName:"rFonts",attributes:{ascii:n,hAnsi:n}});}if(t.size!==void 0){let n=t.size;if(typeof n!="number"||!Number.isFinite(n)||n<=0)return {ok:false,detail:"size: not a positive number of points"};let r=Math.round(n*2);if(r<1||r>Ts)return {ok:false,detail:"size: out of range"};o.push({localName:"sz",attributes:{val:String(r)}}),o.push({localName:"szCs",attributes:{val:String(r)}});}if(t.color!==void 0){let n=t.color;if(typeof n!="string"||!/^#[0-9a-fA-F]{6}$/.test(n.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};o.push({localName:"color",attributes:{val:n.trim().slice(1).toUpperCase()}});}return o.length===0&&t.subscript===void 0&&t.superscript===void 0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:o}}function Ya(t,e,o,n){let r=chunkANZ44KQT_cjs.Ka(t,e);if(!r||r.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let i=chunkANZ44KQT_cjs.If(r),l=[];if(o.style!==void 0){let m=tn(o.style,n);if(!m.ok)return {ok:false,detail:m.detail};l.push({localName:"pStyle",attributes:{val:m.styleId}});}if(o.alignment!==void 0){let m=Fs[o.alignment];if(m===void 0)return {ok:false,detail:`alignment: ${String(o.alignment)}`};l.push({localName:"jc",attributes:{val:m}});}let u=chunkANZ44KQT_cjs.Kf(i,"ind"),d=$a(u),c=false;if(o.firstLineIndent!==void 0){let m=mn(o.firstLineIndent,"firstLineIndent");if(!m.ok)return m;delete d.firstLine,delete d.hanging,m.value<0?d.hanging=String(-m.value):d.firstLine=String(m.value),c=true;}for(let[m,A,I]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let S=o[m];if(S===void 0)continue;let N=mn(S,m);if(!N.ok)return N;delete d[I],d[A]=String(N.value),c=true;}c&&l.push({localName:"ind",attributes:d});let h=chunkANZ44KQT_cjs.Kf(i,"spacing"),g=$a(h),b=false;for(let[m,A]of [["spaceBefore","before"],["spaceAfter","after"]]){let I=o[m];if(I===void 0)continue;let S=mn(I,m);if(!S.ok)return S;if(S.value<0)return {ok:false,detail:`${m}: out of range`};g[A]=String(S.value),b=true;}if(o.lineSpacing!==void 0){let m=mn(o.lineSpacing,"lineSpacing");if(!m.ok)return m;if(m.value<=0)return {ok:false,detail:"lineSpacing: out of range"};g.line=String(m.value),g.lineRule??="auto",b=true;}if(b&&l.push({localName:"spacing",attributes:g}),o.widowControl!==void 0){if(typeof o.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};l.push({localName:"widowControl",...o.widowControl?{}:{attributes:{val:"0"}}});}return l.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:chunkANZ44KQT_cjs.ih(chunkANZ44KQT_cjs.gh(t,e),l)}}function $a(t){let e=Object.create(null);if(!t)return e;for(let o of t.attributes)e[o.localName]=o.value;return e}function qn(t,e){if(e.subscript===void 0&&e.superscript===void 0)return [...t];let o=t.find(r=>r.localName==="vertAlign")?.attributes?.val,n=e.subscript===true?"subscript":e.superscript===true?"superscript":o==="subscript"&&e.subscript===false||o==="superscript"&&e.superscript===false?"baseline":o??"baseline";return chunkANZ44KQT_cjs.ih(t,[{localName:"vertAlign",attributes:{val:n}}])}function Ka(t,e){let o=pt(chunkANZ44KQT_cjs.Kf(t,"vertAlign"),"val");return o===null?null:o===e}function Ja(){let t=false,e=false,o=false,n=false;return {conflict(r){let i=Vt(r),l=Je(r),u=r.op==="deleteComment",d=r.op==="updateFieldResult";return i&&(d&&t&&!n||n&&!d)?{message:"field result updates require a batch without other edits; sync document edits before updating fields",detail:r.op}:l&&t||e&&i?{message:"that command commits on its own and cannot share a batch",detail:r.op}:u&&t&&!o||o&&i&&!u?{message:"comment deletions may share a batch only with other comment deletions",detail:r.op}:null},note(r){Vt(r)&&(t=true,Je(r)&&(e=true),r.op==="deleteComment"&&(o=true),r.op==="updateFieldResult"&&(n=true));},get hasCommands(){return t}}}var js=256,Qa=1e4;function to(t,e){if(t.kind!=="textValue"){for(let o of t.attributes)if(o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName===e)return o.value}}function Bs(t){return t.startsWith("_")}function eo(t){let e=new Map,o=[],n=new Set;for(let r of t.paragraphIds){let i=t.node(r);if(i?.kind!=="paragraph")continue;let l=chunkANZ44KQT_cjs.Of(i),u=d=>{if(d.kind!=="textValue"){if(d.kind==="bookmarkStart"){if(o.length>=Qa||e.size>=Qa)return;let c=to(d,"id"),h=to(d,"name");if(c===void 0||h===void 0||h.length===0||h.length>js||Bs(h)||n.has(h)||e.has(c))return;let g=l.spanOf(d)?.start??0;e.set(c,{name:h,start:{paragraphId:r,offset:g}});return}if(d.kind==="bookmarkEnd"){let c=to(d,"id");if(c===void 0)return;let h=e.get(c);if(!h)return;e.delete(c),n.add(h.name);let g=l.spanOf(d)?.start??0;o.push(Object.freeze({name:h.name,start:h.start,end:{paragraphId:r,offset:g}}));return}for(let c of d.children)u(c);}};for(let d of i.children)u(d);}return Object.freeze(o)}function no(t,e){return eo(t).find(o=>o.name===e)??null}function Za(t,e){let o=t.node(e);if(o?.kind!=="paragraph")return Object.freeze([]);let n=chunkANZ44KQT_cjs.Of(o),r=[],i=(l,u)=>{if(!(l.kind==="textValue"||u>32)){if(chunkANZ44KQT_cjs.hd(l)){let d=n.spanOf(l);d&&r.push(Object.freeze({id:l.id,paragraphId:e,start:d.start,end:d.end}));return}for(let d of l.children)i(d,u+1);}};for(let l of o.children)i(l,0);return Object.freeze(r)}function qa(t,e,o){let n=chunkANZ44KQT_cjs.kd(o,r=>chunkANZ44KQT_cjs.mg(t,e,r));if(n.kind==="external")return n.href;if(n.kind==="internal"){let r=chunkANZ44KQT_cjs.id(o);return r===void 0||r.length===0?null:`#${r}`}return null}function ti(t,e,o,n,r){let i=Math.min(r?.limit??2e3,2e3),l=[],u=xt(e,t),d=u.length-1;for(let[c,h]of u.entries()){if(i<=0)break;let g=t.projectedText(h,r?.projection??"allMarkup");if(!g)continue;let b=g.findOccurrences(n,i,{matchCase:r?.matchCase===true,wholeWord:r?.matchWholeWord===true,...c===0&&e?{from:g.projectedOffset(e.start.offset)}:{},...c===d&&e?{to:g.projectedOffset(e.end.offset)}:{}});for(let m of b.matches){if(c===0&&e&&m.rawStart<e.start.offset||c===d&&e&&m.rawEnd>e.end.offset)continue;let A=o.paragraph(h,t.story);l.push({start:{paragraph:A,offset:m.rawStart},end:{paragraph:A,offset:m.rawEnd}}),i-=1;}}return {ok:true,spans:l}}var oi=256,_s=1<<22,ei=new WeakMap,Vs={story:new Map,copy:new Set};function Us(t){return t.kind!=="textValue"&&t.namespaceUri===chunkANZ44KQT_cjs.fa&&t.localName==="txbxContent"}function Ws(t){let e=t.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===chunkANZ44KQT_cjs.ia&&r.localName==="Fallback");if(!e||e.kind==="textValue")return null;let o=null,n=[{node:e,depth:0}];for(;n.length>0;){let{node:r,depth:i}=n.pop();if(!(r.kind==="textValue"||i>oi)){if(Us(r)){if(o)return null;o=r;continue}for(let l of r.children)n.push({node:l,depth:i+1});}}return o}function ni(t,e,o,n,r){let i=[{node:t,depth:0}];for(;i.length>0;){let{node:l,depth:u}=i.pop();if(--n.left<0||u>oi)return false;if(l.kind!=="textValue"){o.set(l.id,e),r?.add(l.id);for(let d of l.children)i.push({node:d,depth:u+1});}}return true}function Ce(t){let e=ei.get(t.root);if(e)return e;let o={left:_s},n=Ze(t,chunkANZ44KQT_cjs.Cc(chunkANZ44KQT_cjs.Bc(t)??t.root)),r=new Map,i=new Set,l=n.ok;for(let d of n.ok?n.shapes:[]){if(!l)break;let c=d.textboxRoot;if(!c)continue;l=ni(c,c.id,r,o);let h=d.alternate?Ws(d.alternate):null;l&&h&&(l=ni(h,c.id,r,o,i));}let u=!l||r.size===0?Vs:{story:r,copy:i};return ei.set(t.root,u),u}function ri(t,e,o,n){return e.length===0?o===null&&n():o===null?e.every(r=>!t.story.has(r))&&n():e.every(r=>t.story.get(r)===o)&&e.some(r=>!t.copy.has(r))}var $s={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function ai(t,e){return e.length===0?!Gt(t.story):e.every(o=>t.has(o.start.paragraphId))}function Ks(t,e){if(t.story.kind==="note")return ai(t,e.ranges);let o=Ce(t.part),n=t.story.kind==="textbox"&&t.root.kind!=="textValue"?t.root.id:null;return ri(o,chunkSUN62YU6_cjs.sa(e),n,()=>ai(t,e.ranges))}function gn(t){return Object.freeze(chunkSUN62YU6_cjs.Ma(t.part).filter(e=>Ks(t,e)))}function oo(t){let e=[];for(let o of gn(t)){if(o.readOnly)continue;let n=o.structuralChanges?.length===1?o.structuralChanges[0]:void 0,r=o.revisionKind==="structural"?n==="rowInsert"?"Insert":n==="rowDelete"?"Delete":void 0:$s[o.revisionKind];r!==void 0&&e.push(Object.freeze({id:o.id,type:r,author:o.author,date:o.date??"",item:o}));}return Object.freeze(e)}function zs(t,e){let o=t;for(let n=0;o!==void 0&&n<=64;n+=1){if(o.parentId===void 0)return o.range!==null;o=e.get(o.parentId);}return false}var Gs=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function ii(t,e){let o=t.parts.get(chunkSUN62YU6_cjs.ea(t,e.part.name));if(!o)return Gs;let n=t.parts.get(chunkSUN62YU6_cjs.fa(t,e.part.name)),r=chunkANZ44KQT_cjs.Fh(o),i=n?chunkANZ44KQT_cjs.Gh(n):new Map,l=chunkANZ44KQT_cjs.Dh(e.part).filter(g=>e.has(g.start.paragraphId)),u=chunkSUN62YU6_cjs.Na(r,l,i),d=new Map(u.map(g=>[g.id,g])),c=u.filter(g=>zs(g,d)),h=new Map(c.map(g=>[g.id,g]));return Object.freeze({items:Object.freeze(c),roots:Object.freeze(c.filter(g=>g.parentId===void 0)),byId:g=>h.get(g)??null,textOf:g=>{let b=h.get(g);return b?chunkSUN62YU6_cjs.Ia(b.comment):""}})}function si(t,e,o,n,r,i=true){let l=(M,O,j)=>({ok:false,error:{code:M,message:O,...j===void 0?{}:{detail:j}}}),u=M=>Ht(M,o),d=M=>({ok:true,kind:"query",value:M}),c=ya(t,e);if(c)return {ok:false,error:c};let h=t.op==="proposeInsertion",g=t.op==="proposeDeletion",b=G(t.span,o,n);if(!b.ok)return l(b.code,"that span is not a place",b.detail);let m=b.value;if(m&&e&&!h&&m.start.paragraphId!==m.end.paragraphId){if(!i)return l("unsupported-capability","tracked paragraph-range replacement is unsupported in collaboration","span");let M=nt(t.span,o,n);if(!M.ok)return l(M.code,"that story is not a place",M.detail);let O=M.value,j=O.indexOf(m.start.paragraphId),K=O.indexOf(m.end.paragraphId),$=O.paragraphIds.slice(j,K+1),B=chunkANZ44KQT_cjs.La(O.part,$[0]),Z=$.map(it=>B?.children.findIndex(st=>st.id===it)??-1);if(!B||Z.some((it,st)=>it<0||st>0&&it!==Z[st-1]+1))return l("unsupported-content","tracked ranges require adjacent sibling paragraphs","span");let et={author:t.author.trim(),date:new Date().toISOString()},rt=[];for(let it=0;it<$.length;it++){let st=$[it],U=it===0?m.start.offset:0,dt=it===$.length-1?m.end.offset:(O.rawText(st)??"").length,gt=pe(O,st,U,dt);if(gt)return {ok:false,error:gt};let q=r(O,st);if(q)return q;dt>U&&rt.push({op:"deleteText",paragraphId:st,start:U,end:dt,revision:et}),it<$.length-1&&rt.push({op:"setParagraphMarkRevision",paragraphId:st,kind:"del",revision:et});}let It={...m.start,offset:(O.rawText($[0])??"").length},bt=g?"":t.text;return bt&&rt.push({op:"insertText",paragraphId:$[0],offset:It.offset,text:bt,revision:et}),{ok:true,kind:"command",ops:rt,story:O.story,answer:()=>({kind:"span",span:u({start:It,end:{...It,offset:It.offset+bt.length}})})}}if(!m||m.start.paragraphId!==m.end.paragraphId)return l("unsupported-content","proposals require a single paragraph range","span");if(!e&&!h&&m.start.offset===m.end.offset)return l("unsupported-content","deletion and replacement need a non-empty range","span");let A=nt(t.span,o,n);if(!A.ok)return l(A.code,"that story is not a place",A.detail);let I=m.start.paragraphId,S=h&&t.where==="After"?m.end.offset:m.start.offset,N=h?S:m.end.offset;if(e&&!g&&S===N&&t.text==="")return d({kind:"span",span:u({start:m.start,end:m.start})});let w=pe(A.value,I,S,N,e&&h?t.author.trim():void 0,h&&S===(A.value.rawText(I)??"").length);if(w)return {ok:false,error:w};let E=r(A.value,I);if(E)return E;let L={author:t.author.trim(),date:new Date().toISOString()},T=[];return !h&&N>S&&T.push({op:"deleteText",paragraphId:I,start:S,end:N,revision:L}),!g&&t.text.length>0&&T.push({op:"insertText",paragraphId:I,offset:h?S:N,text:t.text,revision:L}),{ok:true,kind:"command",ops:T,story:A.value.story,answer:()=>{if(!e)return {kind:"applied"};let M={...m.start,offset:h?S:N};return {kind:"span",span:u({start:M,end:{...M,offset:M.offset+(g?0:t.text.length)}})}}}}function li(t,e,o){return pe(t,e,0,(t.rawText(e)??"").length,o,true)}var di=5e4;function ro(t,e,o){if("body"in t){let n=lt(t.body,"body",e,o);return n.ok?{ok:true,reads:n.value}:{ok:false,code:n.code,message:"that handle does not name a body",detail:n.detail}}return e.resolve(t.document,"document")?o.body?{ok:true,reads:o.body}:{ok:false,code:"document-unavailable",message:"this host holds no document"}:{ok:false,code:"invalid-handle",message:"that handle does not name a document",detail:"document"}}function Xs(t,e){if(e.root.kind!=="textValue"&&chunkANZ44KQT_cjs.$i({...e.part,root:e.root}).length===0)return [];let o=t.op,n=Ce(e.part),r=()=>chunkANZ44KQT_cjs.$i(e.part).map(d=>d.node.id),i=d=>{let c=[];for(let h=0;h<d.length;h+=di)c.push({op:o,siteNodeIds:d.slice(h,h+di)});return c};if(e.story.kind==="textbox"){let d=e.root.id,c=n.copy.size?r().filter(h=>n.copy.has(h)&&n.story.get(h)===d):[];return [{op:o,scopeRootId:d},...i(c)]}if(Gt(e.story))return [{op:o,scopeRootId:e.root.id}];if(n.story.size===0)return [{op:o}];let l=r(),u=l.filter(d=>!n.story.has(d));return u.length===l.length?[{op:o}]:i(u)}function Ys(t,e,o){let n=ro({op:"acceptAllRevisions",body:t.body},e,o);if(!n.ok)return n;if(!["accept","reject"].includes(t.action)||t.revisions!==void 0&&!Array.isArray(t.revisions))return {ok:false,code:"unsupported-content",message:"invalid revision batch"};let r=t.revisions===void 0?void 0:[];r===void 0&&!Gt(n.reads.story)&&Ce(n.reads.part).story.size>0&&(r=gn(n.reads).map(chunkSUN62YU6_cjs.ta));for(let l of t.revisions??[]){let u=e.resolve(l,"revision");if(!u||u.kind!=="revision"||z(u.story)!==z(n.reads.story))return {ok:false,code:"invalid-handle",message:"revision does not belong to this story"};r.push(`revision-${u.revisionId}`);}let i=chunkSUN62YU6_cjs.Ya(n.reads.part,t.action,r,Gt(n.reads.story)?n.reads.root:void 0);return {ok:true,reads:n.reads,...i}}function Js(t,e,o,n){let r=ro({op:"acceptAllRevisions",body:t},o,n);if(!r.ok)throw new Error("resolved story disappeared");let i=gn(r.reads).length;return {kind:"revisionBatch",result:{...e,remaining:i}}}function ui(t,e,o,n){if(t.op==="resolveRevisionBatch"){let l=Ys(t,e,o);if(!l.ok)return {ok:false,error:{code:l.code,message:l.message}};let u=n(l.reads);return u||{ok:true,kind:"command",story:l.reads.story,ops:l.ops,answer:d=>Js(t.body,l.result,e,d)}}let r=ro(t,e,o);if(!r.ok)return {ok:false,error:{code:r.code,message:r.message,detail:r.detail}};let i=n(r.reads);return i||{ok:true,kind:"command",story:r.reads.story,ops:Xs(t,r.reads),answer:()=>({kind:"applied"})}}function pi(t,e,o){if(e.revisionKind==="structural"||chunkANZ44KQT_cjs.Pi(t.root).length>0||e.revisionKind==="format"&&chunkSUN62YU6_cjs.sa(e).length>1){let n=chunkSUN62YU6_cjs.Ya(t.part,o,[chunkSUN62YU6_cjs.ta(e)],Gt(t.story)?t.root:void 0);return n.result.skipped.length?[]:n.ops}return e.addresses.map(n=>({op:o==="accept"?"acceptRevision":"rejectRevision",revision:n}))}var Qs=/[\r\n\u2028\u2029]/u,mi=Object.freeze({kind:"applied"});function te(t,e,o){return {ok:false,error:Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}}function ao(t,e){return te("unsupported-content",t==="author"?"a comment records who wrote it":t==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",t)}function io(t){return chunkSUN62YU6_cjs.Y(t.author)?ao("author",t.kind):chunkSUN62YU6_cjs.Z(t.text)?ao("text",t.kind):typeof t.text=="string"&&Qs.test(t.text)?te("unsupported-content",t.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):chunkSUN62YU6_cjs.$(t.date)?ao("date",t.kind):null}function so(t){if(t===void 0)return;let e=chunkSUN62YU6_cjs._(t);return e.ok?e.value:void 0}function ci(t,e){let o=chunkANZ44KQT_cjs.Ka(t.part,e);for(;o;){if(o.kind==="tableCell"||o.kind!=="textValue"&&o.namespaceUri===chunkANZ44KQT_cjs.fa&&o.localName==="tc")return o.id;o=chunkANZ44KQT_cjs.La(t.part,o.id);}return null}function fi(t,e,o,n){let r=io({author:t.author,text:t.text,date:t.date,kind:"comment"});if(r)return r;let i=G(t.span,e,o);if(!i.ok)return te(i.code,"that span is not a place",i.detail);if(i.value===null)return te("invalid-handle","an empty story has no comment anchor");let l=nt(t.span,e,o);if(!l.ok)return te(l.code,"that span is not a place",l.detail);if(l.value.story.kind==="textbox")return te("unsupported-content","a comment cannot be anchored in a text box");let u=i.value;if(ci(l.value,u.start.paragraphId)!==ci(l.value,u.end.paragraphId))return te("unsupported-content","a comment range cannot cross a table-cell boundary");let d=n(l.value);if(d)return d;let c=so(t.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:u.start.paragraphId,start:u.start.offset,end:u.end.offset,...u.end.paragraphId===u.start.paragraphId?{}:{endParagraphId:u.end.paragraphId}},text:t.text,author:t.author,...c===void 0?{}:{date:c}},story:l.value.story,answer:(g,b)=>b===void 0?mi:{kind:"handle",handle:e.comment(b,l.value.story)}}}function gi(t,e,o){let n=o(e);if(n)return n;let r=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:t.id,...t.parentId===void 0?{}:{parentCommentId:t.parentId},...r.kind==="note"?{noteId:r.noteId}:{}},story:r,answer:()=>mi}}var Zs=1e4;function hi(t,e){let o=[],n=e.kind==="contentControl"?chunkANZ44KQT_cjs.Ib(e):e;if(!n)return o;for(let r of chunkANZ44KQT_cjs.Mb(n))if(!(r.ancestors.length>0)){if(o.length>=Zs)break;o.push(Ai(t,r.node));}return o}function yi(t,e){for(let o of chunkANZ44KQT_cjs.Mb(t.root))if(o.node.id===e)return Ai(t,o.node);return null}function ki(t,e){for(let o of chunkANZ44KQT_cjs.Mb(t.root))if(o.node.id===e)return o.node;return null}function xi(t,e){for(let o of t.paragraphIds){let n=t.node(o);if(!(!n||n.kind!=="paragraph")&&chunkANZ44KQT_cjs.Mb(n).some(r=>r.node.id===e))return n}return null}function hn(t,e){let o=vi(e);if(o.length>0){let i=o[0],l=o[o.length-1],u=t.rawText(l);return u===null||!t.has(i)?null:{start:{paragraphId:i,offset:0},end:{paragraphId:l,offset:u.length}}}let n=xi(t,e.id);if(!n)return null;let r=chunkANZ44KQT_cjs.Of(n).spanOf(e);return r?{start:{paragraphId:n.id,offset:r.start},end:{paragraphId:n.id,offset:r.end}}:null}function qs(t,e,o){let n=xi(t,e.id),r=chunkANZ44KQT_cjs.Ib(e);if(!n||!r)return null;let i={...n,children:r.children},l=chunkANZ44KQT_cjs.fj(i);return en(i,l,o).text}function bi(t,e,o="allMarkup"){if(o==="allMarkup")return chunkANZ44KQT_cjs.Ob(e);let n=qs(t,e,o);if(n!==null)return n;let r=hn(t,e);if(!r)return "";let i=t.indexOf(r.start.paragraphId),l=t.indexOf(r.end.paragraphId);if(i<0||l<i)return "";let u=[];for(let d=i;d<=l;d+=1){let c=t.paragraphIds[d],h=t.projectedText(c,o),g=t.rawText(c);if(!h||g===null)return "";u.push(h.sliceRaw(d===i?r.start.offset:0,d===l?r.end.offset:g.length));}return u.join("\r")}function Ai(t,e){return {nodeId:e.id,properties:chunkANZ44KQT_cjs.Kb(e),lock:chunkANZ44KQT_cjs.wj(t.part,e.id),paragraphIds:vi(e)}}function vi(t){let e=chunkANZ44KQT_cjs.Ib(t);if(!e)return [];let o=[];return chunkANZ44KQT_cjs.Dc(e.children,o,0),o.map(n=>n.id)}var tl=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),el=4096,Ii=64;function Pi(t){if(t===void 0)return {ok:true,value:null};if(typeof t!="object"||t===null)return {ok:false,field:"payload"};let e=t;for(let o of ["namespaceUri","rootLocalName","nodeId"]){let n=e[o];if(typeof n!="string"||n.length===0||n.length>el)return {ok:false,field:o}}return typeof e.label!="string"||e.label.length>chunkSUN62YU6_cjs.ka?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>chunkSUN62YU6_cjs.ja?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function Oi(t){let e=t.at!==void 0,o=t.span!==void 0;return e===o?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof t.tag!="string"||t.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:t.tag.length>Ii?{message:`w:tag caps at ${String(Ii)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof t.text!="string"||t.text.length===0?{message:"a custom node shows some text",detail:"text"}:t.lock!==void 0&&!tl.has(t.lock)?{message:"that is not a lock",detail:String(t.lock)}:null}function Si(t,e,o,n){return {paragraphId:e.paragraphId,offset:e.offset,...o.offset>e.offset?{replaceUntil:o.offset}:{},tag:t.tag,text:t.text,...t.title===void 0?{}:{alias:t.title},...t.lock===void 0||t.lock==="unlocked"?{}:{lock:t.lock},...n===null?{}:{payload:n}}}function Ri(t,e,o){if(t.span){let r=G(t.span,e,o);return r.ok?r.value?r.value.start.paragraphId!==r.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:r.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:r.code,message:"that span is not a place",detail:r.detail}}let n=le(t.at,e,o);return n.ok?{range:{start:n.value,end:n.value}}:{code:n.code,message:"that is not a place",detail:n.detail}}var Te=/[\r\n\v\f\u2028\u2029]/,nl=16,ol=64;function rl(t,e,o){return Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}function y(t,e,o){return {ok:false,error:rl(t,e,o)}}var at=Object.freeze({kind:"applied"});function H(t){return {ok:true,kind:"query",value:t}}function lo(t){let{runPropertyEdits:e,mergedParagraphMarkProperties:o}=na(()=>t.reads.package?chunkANZ44KQT_cjs.Oc(t.reads.package)?.root??null:null,()=>t.reads.package?chunkANZ44KQT_cjs.xg(t.reads.package)?.root??null:null,()=>t.displayMode??"proposed"),{handles:n,capabilities:r}=t,i=t.reads,l=new Map,u=new Map,d=s=>{let f=`${z(s.story)}:${s.root.id}`,k=l.get(f);if(k)return k;let P=new Map,R=s.paragraphIds.map(p=>{let x={id:p};return P.set(p,x),x}),a={externalCreatedCount:0,reads:s,order:R,slotById:P,created:[],restructured:new Set,touched:new Set,textEdits:new sn,formatted:new Set,selected:new Set,retargets:[]};return l.set(f,a),a},c=[],h=Ja(),g=false,b=null,m=s=>b===null?(b=s,null):b===s?null:y("conflicting-operations","one batch writes into one story",`${z(b.reads.story)} then ${z(s.reads.story)}`),A=s=>m(d(s)),I=s=>{let f=i.package;return f===null?null:ii(f,s)},S=s=>{let f=n.resolve(s,"comment");if(!f||f.kind!=="comment")return {ok:false,planned:y("invalid-handle","that handle does not name a comment","comment")};let k=i.story(f.story);if(!k)return {ok:false,planned:y("invalid-handle","that story is not in this document")};let R=I(k)?.byId(f.commentId)??null;return R?{ok:true,reads:k,item:R}:{ok:false,planned:y("invalid-handle","this document no longer holds that comment",f.commentId)}},N=s=>{let f=n.resolve(s,"revision");if(!f||f.kind!=="revision")return {ok:false,planned:y("invalid-handle","that handle does not name a tracked change","revision")};let k=i.story(f.story);if(!k)return {ok:false,planned:y("invalid-handle","that story is not in this document")};let P=oo(k).find(R=>R.id===f.revisionId)??null;return P?{ok:true,reads:k,item:P}:{ok:false,planned:y("invalid-handle","this document no longer holds that tracked change",f.revisionId)}},w=(s,f)=>{let k=s.rawText(f.start.paragraphId),P=s.rawText(f.end.paragraphId);if(k===null||P===null)return null;let R={story:s.story,paragraphId:f.start.paragraphId,index:s.indexOf(f.start.paragraphId),offset:Math.min(f.start.offset,k.length)},a={story:s.story,paragraphId:f.end.paragraphId,index:s.indexOf(f.end.paragraphId),offset:Math.min(f.end.offset,P.length)};return K({start:R,end:a})},E=(s,f)=>s.order.indexOf(f),L=(s,f)=>s.selected.has(f)?y("conflicting-operations","this batch selects a paragraph it also edits",f):null,T=(s,f)=>{let k=L(s,f);return k||(s.restructured.has(f)||s.touched.has(f)?y("conflicting-operations","another operation in this batch already changes that paragraph",f):(s.restructured.add(f),s.touched.add(f),null))},M=(s,f)=>{let k=L(s,f);return k||(s.restructured.has(f)||s.textEdits.has(f)?y("conflicting-operations","another operation in this batch restructures that paragraph",f):(s.touched.add(f),null))},O=(s,f,k)=>{let P=`${k}:${f}`;if(s.formatted.has(P))return y("conflicting-operations","another operation in this batch already writes that formatting",f);let R=M(s,f);return R||(s.formatted.add(P),null)},j=(s,f)=>{let k={id:null};return s.order.splice(f,0,k),s.created.push(k),k},K=s=>Ht(s,n),$=s=>s===null?null:i.story(s.start.story),B=s=>s===void 0||s==="allMarkup"||s==="original"||s==="model",Z=(s,f,k,P)=>{if(!B(P?.projection))return y("unsupported-content","unknown text projection","projection");if(P?.matchWildcards===true)return y("unsupported-capability","wildcard search is not implemented","matchWildcards");if(P?.ignorePunct===true)return y("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(P?.ignoreSpace===true)return y("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!chunkSUN62YU6_cjs.Va(k))return y("unsupported-content","that is not a query this host will scan for","text");let R=P?.limit;if(R!==void 0&&(!Number.isInteger(R)||R<0))return y("invalid-offset","limit must be a non-negative integer",String(R));let a=ti(s,f,n,k,P);return H({kind:"spans",spans:a.spans})},et=(s,f,k,P=false)=>{let R=f.start.paragraphId,a=s.textEdits.has(R)?L(s,R):s.touched.has(R)?y("conflicting-operations","text edits cannot share a paragraph with other edits",R):M(s,R);return a||ra(s.textEdits,f,k,n,P)},rt=(s,f,k,P=false)=>{if(typeof k!="string"||Te.test(k))return y("unsupported-content","insertText needs text without paragraph marks","text");let R=m(s);if(R)return R;let a=t.replacementLanding?.(f.paragraphId,f.offset,f.offset)!=null,p=!a&&oa(s.reads.part,f.paragraphId,f.offset,k);if(p)return p;if(!a&&Gn(s.reads.part,f.paragraphId,f.offset))return et(s,{start:f,end:f},k,P);let x=T(s,f.paragraphId);return x||{ok:true,kind:"command",ops:k.length?[{op:"insertText",paragraphId:f.paragraphId,offset:f.offset,text:k}]:[],story:s.reads.story,answer:()=>({kind:"span",span:K({start:f,end:{...f,offset:f.offset+k.length}})})}},It=(s,f,k)=>{let P=s.reads;if(typeof k!="string")return y("unsupported-content","replaceSpan needs text","text");if(Te.test(k))return y("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let R=xt(f,P),a=f.start.paragraphId,p=[],x=m(s);if(x)return x;let v=R.length===1?f.end.offset:(P.rawText(a)??"").length,C=t.replacementLanding?.(a,f.start.offset,v);if(R.length===1&&C==null&&Gn(P.part,a,f.start.offset))return et(s,f,k);if(R.length===1){let ot=T(s,a);if(ot)return ot;if(C==null)return ia(P.part,f,k,n);f.end.offset>f.start.offset&&p.push({op:"deleteText",paragraphId:a,start:f.start.offset,end:f.end.offset});}else {for(let V of R){let W=T(s,V);if(W)return W}let ot=f.end.paragraphId,Y=(P.rawText(a)??"").length;f.start.offset<Y&&p.push({op:"deleteText",paragraphId:a,start:f.start.offset,end:Y}),f.end.offset>0&&p.push({op:"deleteText",paragraphId:ot,start:0,end:f.end.offset});for(let V of R.slice(1,-1))p.push({op:"deleteBlock",blockId:V});p.push({op:"joinParagraphs",firstId:a,secondId:ot});for(let V of R.slice(1)){let W=s.slotById.get(V);W&&s.order.splice(E(s,W),1);}}let F=C??f.start.offset;k.length>0&&p.push({op:"insertText",paragraphId:a,offset:F,text:k});let D={...f.start,paragraphId:a,offset:F},Q=()=>({kind:"span",span:K({start:D,end:{...D,offset:D.offset+k.length}})});return {ok:true,kind:"command",ops:p,story:s.reads.story,answer:Q}},bt=(s,f)=>{let k=s.reads;if(typeof f!="string")return y("unsupported-content","replaceSpan needs text","text");if(Te.test(f))return y("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let P=k.blocks,R=P.filter(V=>V.removable),a=P.filter(V=>!V.removable).flatMap(V=>V.paragraphIds),p=a.length===0?R.find(V=>V.kind==="paragraph"):void 0;if(!p&&a.length===0)return y("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let x=m(s);if(x)return x;for(let V of k.paragraphIds){let W=T(s,V);if(W)return W}let v=[],C=(p?[p.id]:[...a]).sort((V,W)=>k.indexOf(V)-k.indexOf(W)),F=C[0],D=(k.rawText(F)??"").length;for(let V of C){let W=(k.rawText(V)??"").length;W>0&&v.push({op:"deleteText",paragraphId:V,start:0,end:W});}for(let V of R)V.id!==p?.id&&v.push({op:"deleteBlock",blockId:V.id});let Q=t.replacementLanding?.(F,0,D)??0;f.length>0&&v.push({op:"insertText",paragraphId:F,offset:Q,text:f});for(let V of R)if(V.id!==p?.id)for(let W of V.paragraphIds){let Pt=s.slotById.get(W);Pt&&s.order.splice(E(s,Pt),1);}let ot={story:k.story,paragraphId:F,index:k.indexOf(F),offset:Q},Y=()=>({kind:"span",span:K({start:ot,end:{...ot,offset:Q+f.length}})});return {ok:true,kind:"command",ops:v,story:k.story,answer:Y}},it=(s,f)=>{if(!Array.isArray(f)||f.length<1||f.length>1e4||f.some(P=>typeof P!="string"||Te.test(P))||!chunkANZ44KQT_cjs.Rg(f))return y("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let k=m(s);if(k)return k;for(let P of s.reads.paragraphIds){let R=T(s,P);if(R)return R}s.order.splice(0,s.order.length);for(let P=0;P<f.length;P+=1)j(s,P);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:s.reads.root.id,paragraphs:f}],story:s.reads.story,answer:()=>at}},st=(s,f,k,P)=>{let R=s.reads;if(typeof P!="string")return y("unsupported-content","insertParagraph needs text","text");if(Te.test(P))return y("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let a=m(s);if(a)return a;let p=T(s,f.paragraphId);if(p)return p;let x=s.slotById.get(f.paragraphId);if(!x)return y("invalid-handle","that paragraph is not in the body");let v=(R.rawText(f.paragraphId)??"").length,C=[];k==="after"?(P.length>0&&C.push({op:"insertText",paragraphId:f.paragraphId,offset:v,text:P}),C.push({op:"splitParagraph",paragraphId:f.paragraphId,offset:v})):(P.length>0&&C.push({op:"insertText",paragraphId:f.paragraphId,offset:0,text:P}),C.push({op:"splitParagraph",paragraphId:f.paragraphId,offset:P.length}));let F=j(s,E(s,x)+1);k==="before"&&s.retargets.push({from:f.paragraphId,slot:F});let D=()=>{let Q=k==="after"?F.id:f.paragraphId;return Q===null?at:{kind:"handle",handle:n.paragraph(Q,R.story)}};return {ok:true,kind:"command",ops:C,story:R.story,answer:D}},U=(s,f,k,P,R)=>{let a=s.reads;if(!Array.isArray(k)||k.length===0)return y("unsupported-content","split needs at least one delimiter","delimiters");if(k.length>nl)return y("unsupported-content","too many delimiters",String(k.length));for(let W of k){if(typeof W!="string"||W.length===0)return y("unsupported-content","a delimiter must be a non-empty string","delimiters");if(W.length>ol)return y("unsupported-content","that delimiter is too long","delimiters")}let p=m(s);if(p)return p;let x=T(s,f.paragraphId);if(x)return x;let v=s.slotById.get(f.paragraphId);if(!v)return y("invalid-handle","that paragraph is not in the body");let C=a.rawText(f.paragraphId)??"",F=la(C,k),D=[],Q=[],ot=[];if(F.length===0)ot.push(C);else if(P){for(let ct of [...F].reverse())D.push({op:"deleteText",paragraphId:f.paragraphId,start:ct.start,end:ct.start+ct.length});let W=0,Pt=0;for(let ct of F){let xn=ct.start-W;Q.push(xn),ot.push(C.slice(Pt,ct.start)),Pt=ct.start+ct.length,W+=ct.length;}ot.push(C.slice(Pt));}else {let W=0;for(let Pt of F){let ct=Pt.start+Pt.length;Q.push(ct),ot.push(C.slice(W,ct)),W=ct;}ot.push(C.slice(W));}Q.length>0&&D.push({op:"splitParagraphMany",paragraphId:f.paragraphId,offsets:Q});let Y=[v];for(let W=0;W<Q.length;W+=1)Y.push(j(s,E(s,v)+1+W));let V=W=>{let Pt=W.story(a.story),ct=[];return Y.forEach((xn,Ei)=>{let bn=xn.id;if(bn===null)return;let An=Pt?.rawText(bn)??ot[Ei]??"",[Li,Mi]=R?pa(An,0,An.length):[0,An.length],mo=n.paragraph(bn,a.story);ct.push({start:{paragraph:mo,offset:Li},end:{paragraph:mo,offset:Mi}});}),{kind:"spans",spans:ct}};return {ok:true,kind:"command",ops:D,story:a.story,answer:V}},dt=(s,f)=>{let k=m(s);if(k)return k;let P=T(s,f.paragraphId);if(P)return P;let R=s.slotById.get(f.paragraphId);return R&&s.order.splice(E(s,R),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:f.paragraphId}],story:s.reads.story,answer:()=>at}},gt=(s,f,k)=>{let P=s.reads,R=P.part,a=m(s);if(a)return a;let p=Xa(k??{});if(!p.ok)return y("unsupported-content","that is not formatting this host writes",p.detail);let x=[];for(let v of Yt(f,P)){if(v.end<=v.start&&!v.whole)continue;let C=O(s,v.paragraphId,"runs");if(C)return C;for(let F of e(R,v.paragraphId,v.start,v.end,p.value.filter(D=>D.localName!=="vertAlign"),t.displayMode))x.push({op:"setRunProperties",paragraphId:v.paragraphId,start:F.start,end:F.end,properties:qn(F.properties,k),...F.targetRunIds?{targetRunIds:F.targetRunIds}:{}});v.whole&&x.push({op:"setParagraphMarkProperties",paragraphId:v.paragraphId,properties:qn(o(R,v.paragraphId,p.value.filter(F=>F.localName!=="vertAlign")),k)});}return x.length===0?y("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:x,story:P.story,answer:()=>at}},q=(s,f,k)=>{let P=s.reads,R=P.part,a=m(s);if(a)return a;let p=tn(k,P.styles());if(!p.ok)return y("unsupported-content","that is not a style this document has",p.detail);let x={localName:"pStyle",attributes:{val:p.styleId}},v=[];for(let C of xt(f,P)){let F=O(s,C,"paragraph");if(F)return F;v.push({op:"setParagraphProperties",paragraphId:C,properties:chunkANZ44KQT_cjs.ih(chunkANZ44KQT_cjs.gh(R,C),x)});}return v.length===0?y("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:v,story:P.story,answer:()=>at}},X=(s,f,k)=>{let P=s.reads,R=P.part,a=m(s);if(a)return a;let p=Ya(R,f.paragraphId,k??{},P.styles());if(!p.ok)return y("unsupported-content","that is not paragraph formatting this host writes",p.detail);let x=O(s,f.paragraphId,"paragraph");return x||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:f.paragraphId,properties:p.value}],story:P.story,answer:()=>at}},Ut=(s,f)=>{let k=i.body;if(!k)return y("document-unavailable","this host holds no document right now");let P=i.sections();if(!P[s])return y("invalid-handle","that section is not in this document");let a=Lr(f);if(!a.ok)return y("unsupported-content",a.reason,a.detail);let p=da(k,P,s);if(p===null)return y("unsupported-content","that section holds no paragraph to address it by","no-anchor");let x=d(k),v=m(x);return v||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...a.value,anchorParagraphId:p}],story:Ot,answer:()=>at}},Ne=(s,f)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:s,noteId:f}],story:Ot,lifecycle:true,answer:()=>at}),yn=s=>{let f=n.resolve(s,"list");if(!f||f.kind!=="list")return y("invalid-handle","that handle does not name a list","list");let k=i.story(f.story);if(!k)return y("invalid-handle","that story is not in this document");let P=Zt(k).find(R=>R.numId===f.numId);return P?{ok:true,plan:d(k),list:P}:y("invalid-handle","this story numbers nothing with that list",f.numId)},kn=s=>{if(typeof s!="object"||s===null)return y("invalid-handle","that is not a scope a control lives in","scope");let f=s;if("body"in s){let k=lt(f.body,"body",n,i);return k.ok?{reads:k.value,node:k.value.root}:y(k.code,"that handle does not name a body",k.detail)}if("contentControl"in s){let k=Tt(f.contentControl);return "control"in k?{reads:k.reads,node:k.node}:k}return y("invalid-handle","that is not a scope a control lives in","scope")},Tt=s=>{let f=n.resolve(s,"contentControl");if(!f||f.kind!=="contentControl")return y("invalid-handle","that handle does not name a content control","contentControl");let k=i.story(f.story);if(!k)return y("invalid-handle","that story is not in this document");let P=yi(k,f.nodeId),R=ki(k,f.nodeId);return !P||!R?y("invalid-handle","this document no longer holds that content control"):{reads:k,control:P,node:R}},wi=(s,f,k)=>{if(!Number.isInteger(k)||k<0||k>ce)return y("invalid-offset",`a list level is 0 to ${String(ce)}`,String(k));let P=we(s.reads,f);if(!P)return y("unsupported-content","that paragraph is not in a list",f);if(!i.package||!Re(i.package,P.numId,k))return y("unsupported-content","list level is not defined; configure that level first",f);let R=m(s);if(R)return R;let a=O(s,f,"paragraph");return a||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:f,level:k}],story:s.reads.story,answer:()=>at}},Ci=(s,f,k,P)=>{if(k!=="start"&&k!=="end")return y("unknown-operation","a list takes an item at its start or its end",String(k));let R=s.reads,a=k==="start"?f.paragraphIds[0]:f.paragraphIds[f.paragraphIds.length-1];if(a===void 0)return y("invalid-handle","that list holds no paragraph");let p={story:R.story,paragraphId:a,index:R.indexOf(a)};return st(s,p,k==="start"?"before":"after",P)},uo=(s,f)=>{if(f.start.paragraphId!==f.end.paragraphId)return null;for(let k of Za(s,f.start.paragraphId))if(k.start<=f.start.offset&&k.end>=f.end.offset)return k;return null},Ti=(s,f,k)=>{if(typeof k!="string")return y("unsupported-content","a hyperlink target is a string","target");let P=s.reads,R=uo(P,f),a=f.start.paragraphId===f.end.paragraphId&&f.start.offset===f.end.offset,p=R&&(f.start.offset!==R.start||f.end.offset!==R.end),x=p?{range:{start:f.start.offset,end:f.end.offset}}:{};if(p){let Y=P.node(R.paragraphId),V=Y?.kind==="paragraph"?Y.children.find(W=>W.id===R.id):void 0;if(a||!V||!chunkANZ44KQT_cjs.Ei(V)||Y?.kind!=="paragraph"||!Y.children.some(W=>W.id===R.id))return y("unsupported-capability","partial hyperlink edits require ordinary text in a paragraph")}if(k.length===0){if(!R)return y("unsupported-content","that text is not a link","no-link");let Y=m(s);if(Y)return Y;let V=M(s,R.paragraphId);return V||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:R.id,...x}],story:P.story,answer:()=>at}}let v={},C=null;if(k.startsWith("#")){let Y=k.slice(1);if(Y.length===0||!no(P,Y))return y("unsupported-content","this document declares no such bookmark",k);v={anchor:Y};}else {if(chunkANZ44KQT_cjs.kg(k)===null)return y("unsupported-content","this engine will not author that target","target");C=k;}let F=m(s);if(F)return F;let D=Y=>C===null?{ok:true,kind:"command",ops:[Y(v)],story:P.story,answer:()=>at}:{ok:true,kind:"command",ops:[],relate:{url:C,ops:V=>[Y({relationshipId:V})]},story:P.story,answer:()=>at};if(R){let Y=M(s,R.paragraphId);return Y||D(V=>({op:"setHyperlinkTarget",linkId:R.id,...x,...V}))}if(a)return y("unsupported-content","a link with no text has nothing to click","collapsed");if(f.start.paragraphId!==f.end.paragraphId)return y("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let Q=M(s,f.start.paragraphId);if(Q)return Q;let ot=P.styles().idOf("hyperlink");return D(Y=>({op:"insertHyperlink",paragraphId:f.start.paragraphId,start:f.start.offset,end:f.end.offset,...Y,...ot===null?{}:{styleId:ot}}))},po=(s,f,k)=>{let P=s.reads;if(!r.selection||!t.select)return y("unsupported-capability","this host has no reader to move","selection");if(k!=="select"&&k!=="start"&&k!=="end")return y("unknown-operation","that is not a selection mode",String(k));let R=xt(f,P);for(let a of R)if(s.touched.has(a))return y("conflicting-operations","this batch edits a paragraph the selection covers",a);for(let a of R)s.selected.add(a);return c.push({range:f,mode:k}),{ok:true,kind:"command",ops:[],story:P.story,answer:()=>at}},co=s=>{let f=n.resolve(s,"bookmark");if(!f||f.kind!=="bookmark")return y("invalid-handle","that handle does not name a bookmark","bookmark");let k=i.story(f.story);if(!k)return y("invalid-handle","that story is not in this document");let P=no(k,f.name);if(!P)return y("invalid-handle","this document no longer declares that bookmark",f.name);let R=a=>({story:k.story,paragraphId:a.paragraphId,index:k.indexOf(a.paragraphId),offset:a.offset});return {reads:k,range:{start:R(P.start),end:R(P.end)}}},Ni=(s,f)=>{let k=Ra(s,t,a=>lo({...t,reads:a}));if(k)return f&&k.ok&&k.kind==="command"?y("unsupported-content","header/footer creation cannot be tracked"):k;let P=Oa(s,{trackingAuthor:f,trackedRangeReplacement:t.trackedRangeReplacement,handles:n,reads:i,admitWrite:(a,p,x)=>{let v=d(a),C=m(v);if(C)return C;for(let F of x){let D=T(v,F);if(D)return D}return v.externalCreatedCount+=p,null}});if(P)return P;let R=f!==void 0;switch(R&&s.op==="insertText"?s={op:"proposeInsertion",span:{start:s.at,end:s.at},text:s.text,where:"Before",author:f}:R&&s.op==="replaceSpan"&&(s={op:"proposeReplacement",span:s.span,text:s.text,author:f}),s.op){case "getFields":case "getField":case "setFieldCode":case "deleteField":case "updateFieldResult":case "insertField":return va(s,n,i,(a,p,x)=>{let v=d(a);return m(v)??(x?null:T(v,p))},t.fieldPageContext);case "getShapes":case "getShape":case "getShapeBody":return $r(s,n,i);case "getInlinePictures":case "getInlinePicture":case "setInlinePicture":case "deleteInlinePicture":case "insertInlinePicture":return La(s,n,i,(a,p)=>{let x=d(a);return m(x)??T(x,p)});case "insertBreak":return Ma(s,n,i,(a,p,x)=>{let v=d(a),C=m(v)??T(v,p);return C||(v.externalCreatedCount+=x),C});case "startNewList":case "attachToList":case "detachFromList":case "setListLevelFormat":return Ba(s,n,i,(a,p,x)=>{let v=d(a);return m(v)??O(v,p,x?`list:${x.numId}:${x.level}`:"paragraph")},f);case "removeDocumentInformation":case "getDocumentProperty":case "setDocumentProperties":return Yr(s,i,()=>m(d(i.body)),!t.collaborative);case "getDocument":return H({kind:"handle",handle:n.document()});case "getBody":return n.resolve(s.document,"document")?i.body?H({kind:"handle",handle:n.body(Ot)}):y("document-unavailable","this host holds no document right now"):y("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let a=lt(s.body,"body",n,i);return a.ok?H({kind:"handles",handles:a.value.paragraphIds.map(p=>n.paragraph(p,a.value.story))}):y(a.code,"that handle does not name a body",a.detail)}case "getRange":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","empty story");if(!["Whole","Content","Start","End"].includes(s.location))return y("unsupported-content","unsupported range location");let p=a.value,x=s.location==="Start"?{start:p.start,end:p.start}:s.location==="End"?{start:p.end,end:p.end}:p;return H({kind:"span",span:Ht(x,n)})}case "getSpanParagraphs":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.span,n,i);return p.ok?H({kind:"handles",handles:xt(a.value,p.value).map(x=>n.paragraph(x,p.value.story))}):y(p.code,"that span is not a place",p.detail)}case "getText":{if(!B(s.projection))return y("unsupported-content","unknown text projection","projection");if(n.resolve(s.target,"body")){let v=lt(s.target,"body",n,i);return v.ok?H({kind:"text",text:v.value.text(s.projection??"allMarkup")}):y(v.code,"that handle does not name a body",v.detail)}let p=yt(s.target,n,i);if(!p.ok)return y(p.code,"that handle does not name a body or a paragraph",p.detail);let x=i.story(p.value.story);return H({kind:"text",text:x?.paragraphText(p.value.paragraphId,s.projection??"allMarkup")??""})}case "getSpanText":{if(!B(s.projection))return y("unsupported-content","unknown text projection","projection");let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.span,n,i);return p.ok?H({kind:"text",text:Wr(a.value,p.value,jn,s.projection??"allMarkup")}):y(p.code,"that span is not a place",p.detail)}case "getParagraphId":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let x=i.story(a.value.story)?.paragraph(a.value.paragraphId);return H({kind:"text",text:x?.paraId??""})}case "search":{let a=G(s.scope,n,i);if(!a.ok)return y(a.code,"that is not a scope to search",a.detail);let p=nt(s.scope,n,i);return p.ok?Z(p.value,a.value,s.text,s.options):y(p.code,"that is not a scope to search",p.detail)}case "proposeInsertion":case "proposeDeletion":case "proposeReplacement":return si(s,R,n,i,(a,p)=>{let x=d(a);return m(x)??T(x,p)},t.trackedRangeReplacement!==false);case "insertText":{let a=le(s.at,n,i);if(!a.ok)return y(a.code,"that is not a place to insert at",a.detail);let p=i.story(a.value.story);return p?rt(d(p),a.value,s.text,"at"in s.at&&s.at.at==="start"):y("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in s.span){let x=lt(s.span.body,"body",n,i);return x.ok?bt(d(x.value),s.text):y(x.code,"that handle does not name a body",x.detail)}let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","that story holds no paragraph to write into","empty-story");let p=$(a.value);return p?It(d(p),a.value,s.text):y("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let a=lt(s.body,"body",n,i);return a.ok?it(d(a.value),s.paragraphs):y(a.code,"that handle does not name a body",a.detail)}case "insertParagraph":{let a=on(s.anchor,n,i);if(!a.ok)return y(a.code,"that is not a paragraph to insert beside",a.detail);if(s.where!=="before"&&s.where!=="after")return y("unknown-operation","that is not a place to insert",String(s.where));let p=i.story(a.value.story);if(!p)return y("invalid-handle","that story is not in this document");let x=R&&li(p,a.value.paragraphId,f);return x?{ok:false,error:x}:st(d(p),a.value,s.where,s.text)}case "splitParagraph":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let p=i.story(a.value.story);return p?U(d(p),a.value,s.delimiters,s.trimDelimiters===true,s.trimSpacing===true):y("invalid-handle","that story is not in this document")}case "getFont":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.span,n,i);if(!p.ok)return y(p.code,"that span is not a place",p.detail);let x=Yt(a.value,p.value);return H({kind:"font",font:za(p.value.part,x,t.displayMode)})}case "setFont":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","that story holds no paragraph to format","empty-story");let p=$(a.value);return p?gt(d(p),a.value,s.font):y("invalid-handle","that story is not in this document")}case "getStyle":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.span,n,i);if(!p.ok)return y(p.code,"that span is not a place",p.detail);let x=p.value.part,v=p.value.styles(),C=xt(a.value,p.value).map(D=>qe(x,D,v)),F=C.length>0&&C.every(D=>D!==null&&D===C[0])?C[0]:null;return H({kind:"style",name:F})}case "setStyle":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","that story holds no paragraph to style","empty-story");let p=$(a.value);return p?q(d(p),a.value,s.name):y("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let a=on(s.paragraph,n,i);if(!a.ok)return y(a.code,"that is not a paragraph",a.detail);let p=i.story(a.value.story);if(!p)return y("document-unavailable","this host holds no document right now");let x=Ga(p.part,a.value.paragraphId,p.styles());return x?H({kind:"paragraphFormat",format:x}):y("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let a=on(s.paragraph,n,i);if(!a.ok)return y(a.code,"that is not a paragraph",a.detail);let p=i.story(a.value.story);return p?X(d(p),a.value,s.format):y("invalid-handle","that story is not in this document")}case "deleteParagraph":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let p=i.story(a.value.story);return p?dt(d(p),a.value):y("invalid-handle","that story is not in this document")}case "getSections":return n.resolve(s.document,"document")?H({kind:"handles",handles:i.sections().map(a=>n.section(a.index))}):y("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let a=n.resolve(s.section,"section");if(!a||a.kind!=="section")return y("invalid-handle","that handle does not name a section","section");let p=i.sections()[a.index];return p?H({kind:"pageSetup",setup:p.pageSetup}):y("invalid-handle","that section is not in this document")}case "setPageSetup":{let a=n.resolve(s.section,"section");return !a||a.kind!=="section"?y("invalid-handle","that handle does not name a section","section"):Ut(a.index,s.setup)}case "getFurniture":{let a=n.resolve(s.section,"section");if(!a||a.kind!=="section")return y("invalid-handle","that handle does not name a section","section");if(s.kind!=="header"&&s.kind!=="footer")return y("unknown-operation","that is not furniture",String(s.kind));let p={kind:s.kind,sectionIndex:a.index,variant:s.variant};return Dn(p)?i.sections()[a.index]?H({kind:"handle",handle:n.body(p)}):y("invalid-handle","that section no longer exists"):y("unknown-operation","that is not a furniture variant",String(s.variant))}case "getNotes":{if(!n.resolve(s.document,"document"))return y("invalid-handle","that handle does not name a document","document");if(s.noteKind!=="footnote"&&s.noteKind!=="endnote")return y("unknown-operation","that is not a kind of note",String(s.noteKind));let a=s.noteKind,p=i.noteIds(a);if(!p.ok)return y("ambiguous-document",`${a} identities are not completely and unambiguously enumerable`,p.reason==="duplicates"?p.duplicateIds.join(","):p.reason);let x=p.ids;if(s.scope){let v=lt(s.scope,"body",n,i);if(!v.ok)return y(v.code,"that handle does not name a body",v.detail);let C=Jr(v.value.root,a),F=new Set(p.ids);if(C.some(D=>!F.has(D)))return y("ambiguous-document","a note reference has no matching note");x=C;}return H({kind:"handles",handles:x.map(v=>n.note(a,v))})}case "getNoteBody":case "getNoteText":{let a=n.resolve(s.note,"note");if(!a||a.kind!=="note")return y("invalid-handle","that handle does not name a note","note");let p=a,x=i.story(p);return x?s.op==="getNoteText"?H({kind:"text",text:x.text(s.projection)}):H({kind:"handle",handle:n.body(p)}):y("invalid-handle","that note is not in this document",z(p))}case "getNoteKind":{let a=n.resolve(s.note,"note");return !a||a.kind!=="note"?y("invalid-handle","that handle does not name a note","note"):H({kind:"text",text:a.noteKind})}case "deleteNote":{let a=n.resolve(s.note,"note");if(!a||a.kind!=="note")return y("invalid-handle","that handle does not name a note","note");let p=i.noteIds(a.noteKind);return p.ok?p.ids.includes(a.noteId)?Ne(a.noteKind,a.noteId):y("invalid-handle","that note is not in this document"):y("ambiguous-document",`${a.noteKind} identities are not completely and unambiguously enumerable`,p.reason==="duplicates"?p.duplicateIds.join(","):p.reason)}case "getLists":{let a=lt(s.body,"body",n,i);return a.ok?H({kind:"handles",handles:Zt(a.value).map(p=>n.list(p.numId,a.value.story))}):y(a.code,"that handle does not name a body",a.detail)}case "getListId":{let a=yn(s.list);return "list"in a?H({kind:"number",value:Number(a.list.numId)}):a}case "getListById":{let a=lt(s.body,"body",n,i);if(!a.ok)return y(a.code,"that handle does not name a body",a.detail);if(!Number.isInteger(s.id)||s.id<=0)return y("unsupported-content","a list is numbered from one",String(s.id));let p=String(s.id),x=Zt(a.value).find(v=>v.numId===p);return x?H({kind:"handle",handle:n.list(x.numId,a.value.story)}):y("invalid-handle","no list in that story carries that number",p)}case "getListParagraphs":{let a=yn(s.list);if(!("list"in a))return a;let p=s.level;if(p!==void 0&&(!Number.isInteger(p)||p<0||p>ce))return y("invalid-offset",`a list level is 0 to ${String(ce)}`,String(p));let x=a.plan.reads,v=p===void 0?a.list.paragraphIds:a.list.paragraphIds.filter(C=>we(x,C)?.level===p);return H({kind:"handles",handles:v.map(C=>n.paragraph(C,x.story))})}case "getParagraphList":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let p=i.story(a.value.story);if(!p)return y("invalid-handle","that story is not in this document");let x=we(p,a.value.paragraphId);return x?H({kind:"handle",handle:n.list(x.numId,p.story)}):y("unsupported-content","that paragraph is not in a list",a.value.paragraphId)}case "getListLevel":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let p=i.story(a.value.story);if(!p)return y("invalid-handle","that story is not in this document");let x=we(p,a.value.paragraphId);return x?H({kind:"number",value:x.level}):y("unsupported-content","that paragraph is not in a list",a.value.paragraphId)}case "setListLevel":{let a=yt(s.paragraph,n,i);if(!a.ok)return y(a.code,"that handle does not name a paragraph",a.detail);let p=i.story(a.value.story);return p?wi(d(p),a.value.paragraphId,s.level):y("invalid-handle","that story is not in this document")}case "insertListParagraph":{let a=yn(s.list);return "list"in a?Ci(a.plan,a.list,s.where,s.text):a}case "getHyperlink":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.span,n,i);if(!p.ok)return y(p.code,"that span is not a place",p.detail);let x=i.package;if(!x||!a.value)return H({kind:"text",text:""});let v=uo(p.value,a.value);if(!v)return H({kind:"text",text:""});let C=chunkANZ44KQT_cjs.Ka(p.value.part,v.id),F=C?qa(x,p.value.part.name,C):null;return H({kind:"text",text:F??""})}case "setHyperlink":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","that story holds no text to link","empty-story");let p=$(a.value);return p?Ti(d(p),a.value,s.target):y("invalid-handle","that story is not in this document")}case "getBookmarks":{let a=G(s.scope,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);let p=nt(s.scope,n,i);if(!p.ok)return y(p.code,"that span is not a place",p.detail);let x=p.value,v=a.value,C=v===null?null:new Set(xt(v,x)),F=eo(x).filter(D=>{if(!C||!C.has(D.start.paragraphId)&&!C.has(D.end.paragraphId)||v===null)return false;let Q=D.start.paragraphId===v.end.paragraphId&&D.start.offset>v.end.offset,ot=D.end.paragraphId===v.start.paragraphId&&D.end.offset<v.start.offset;return !Q&&!ot});return H({kind:"handles",handles:F.map(D=>n.bookmark(D.name,x.story))})}case "getBookmarkName":{let a=n.resolve(s.bookmark,"bookmark");return !a||a.kind!=="bookmark"?y("invalid-handle","that handle does not name a bookmark","bookmark"):H({kind:"text",text:a.name})}case "getBookmarkRange":{let a=co(s.bookmark);return "reads"in a?H({kind:"span",span:K(a.range)}):a}case "getComments":{let a=G(s.scope,n,i);if(!a.ok)return y(a.code,"that scope is not a place",a.detail);let p=nt(s.scope,n,i);if(!p.ok)return y(p.code,"that scope names no story",p.detail);let x=p.value,v=I(x);if(!v)return y("document-unavailable","this host holds no document");let C=a.value,F=v.roots.filter(D=>{if(!C)return true;let Q=D.range;if(!Q)return false;let ot=x.indexOf(Q.start.paragraphId),Y=x.indexOf(Q.end.paragraphId),V=x.indexOf(C.start.paragraphId),W=x.indexOf(C.end.paragraphId);return Y<V||ot>W?false:Y===V&&ot===V&&W===V?Q.end.offset>C.start.offset&&Q.start.offset<C.end.offset:true});return H({kind:"handles",handles:F.map(D=>n.comment(D.id,x.story))})}case "getCommentReplies":{let a=S(s.comment);return a.ok?H({kind:"handles",handles:a.item.replyIds.map(p=>n.comment(p,a.reads.story))}):a.planned}case "getCommentId":{let a=S(s.comment);return a.ok?H({kind:"text",text:a.item.id}):a.planned}case "getCommentAuthor":{let a=S(s.comment);return a.ok?H({kind:"text",text:a.item.comment.author}):a.planned}case "getCommentDate":{let a=S(s.comment);return a.ok?H({kind:"text",text:a.item.comment.date??""}):a.planned}case "getCommentText":{let a=S(s.comment);if(!a.ok)return a.planned;let p=I(a.reads);return H({kind:"text",text:p?.textOf(a.item.id)??""})}case "getCommentRange":{let a=S(s.comment);if(!a.ok)return a.planned;let p=a.item.range;if(!p||a.item.orphaned)return y("invalid-handle","that comment has no range in this document");let x=w(a.reads,p);return x?H({kind:"span",span:x}):y("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let a=S(s.comment);return a.ok?H({kind:"flag",value:a.item.resolved}):a.planned}case "insertComment":return fi(s,n,i,A);case "setCommentResolved":{let a=S(s.comment);if(!a.ok)return a.planned;if(typeof s.resolved!="boolean")return y("unsupported-content","resolved is a yes or a no",String(s.resolved));let p=m(d(a.reads));return p||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:a.item.id,resolved:s.resolved},story:a.reads.story,answer:()=>at}}case "replyToComment":{let a=S(s.comment);if(!a.ok)return a.planned;let p=io({author:s.author,text:s.text,date:s.date,kind:"reply"});if(p)return p;let x=a.item.range;if(!x||a.item.orphaned)return y("invalid-handle","that comment has no range to reply over");let v=m(d(a.reads));if(v)return v;let C=a.reads.story,F=so(s.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:a.item.id,anchor:{paragraphId:x.start.paragraphId,start:x.start.offset,end:x.end.offset,...x.end.paragraphId===x.start.paragraphId?{}:{endParagraphId:x.end.paragraphId}},text:s.text,author:s.author,...F===void 0?{}:{date:F}},story:a.reads.story,answer:(D,Q)=>Q===void 0?at:{kind:"handle",handle:n.comment(Q,C)}}}case "deleteComment":{let a=S(s.comment);return a.ok?gi(a.item,a.reads,p=>m(d(p))):a.planned}case "getRevisions":{let a=lt(s.body,"body",n,i);if(!a.ok)return y(a.code,"that handle does not name a body",a.detail);let p=a.value;return H({kind:"handles",handles:oo(p).map(x=>n.revision(x.id,p.story))})}case "getRevisionType":{let a=N(s.revision);return a.ok?H({kind:"text",text:a.item.type}):a.planned}case "getRevisionAuthor":{let a=N(s.revision);return a.ok?H({kind:"text",text:a.item.author}):a.planned}case "getRevisionDate":{let a=N(s.revision);return a.ok?H({kind:"text",text:a.item.date}):a.planned}case "getRevisionRange":{let a=N(s.revision);if(!a.ok)return a.planned;let[p]=a.item.item.ranges;if(!p)return y("invalid-handle","that change covers no characters");let x=w(a.reads,p);return x?H({kind:"span",span:x}):y("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let a=N(s.revision);if(!a.ok)return a.planned;let p=d(a.reads),x=m(p);if(x)return x;let v=pi(a.reads,a.item.item,s.op==="acceptRevision"?"accept":"reject");return v.length?{ok:true,kind:"command",story:a.reads.story,ops:v,answer:()=>at}:y("unsupported-revision","the table decision has unresolved dependencies")}case "resolveRevisionBatch":case "acceptAllRevisions":case "rejectAllRevisions":return ui(s,n,i,a=>m(d(a)));case "selectSpan":{let a=G(s.span,n,i);if(!a.ok)return y(a.code,"that span is not a place",a.detail);if(!a.value)return y("invalid-offset","that story holds no paragraph to select","empty-story");let p=$(a.value);return p?po(d(p),a.value,s.mode):y("invalid-handle","that story is not in this document")}case "selectBookmark":{let a=co(s.bookmark);return "reads"in a?po(d(a.reads),a.range,s.mode):a}case "getContentControls":{let a=kn(s.scope);return "reads"in a?H({kind:"handles",handles:hi(a.reads,a.node).map(p=>n.contentControl(p.nodeId,a.reads.story))}):a}case "getContentControlById":{let a=kn(s.scope);if(!("reads"in a))return a;if(!Number.isInteger(s.id))return y("unsupported-content","a control id is a whole number",String(s.id));let p=ue(a.node).find(x=>chunkANZ44KQT_cjs.Kb(x).id===s.id);return p?H({kind:"handle",handle:n.contentControl(p.id,a.reads.story)}):y("invalid-handle","no control in that scope carries that id",String(s.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let a=kn(s.scope);if(!("reads"in a))return a;let p=s.op==="getContentControlsByTag"?s.tag:s.title;if(typeof p!="string"||p.length===0)return y("unsupported-content","a tag or title to match is required",s.op);let x=ue(a.node).filter(v=>{let C=chunkANZ44KQT_cjs.Kb(v);return s.op==="getContentControlsByTag"?C.tag===p:C.alias===p});return H({kind:"handles",handles:x.map(v=>n.contentControl(v.id,a.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let a=Tt(s.contentControl);if(!("control"in a))return a;let p=a.control.properties;if(s.op==="getContentControlLock")return H({kind:"text",text:a.control.lock});if(s.op==="getContentControlSubtype")return H({kind:"text",text:p.type});if(s.op==="getContentControlFileId")return H({kind:"text",text:p.id===void 0?"":String(p.id)});let x=s.op==="getContentControlTag"?p.tag:p.alias;return H({kind:"text",text:x??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let a=Tt(s.contentControl);if(!("control"in a))return a;let p=s.op==="getContentControlIsBound"?a.control.properties.dataBinding!==void 0:s.op==="getContentControlPlaceholderShown"?a.control.properties.showingPlaceholder:a.control.properties.temporary;return H({kind:"flag",value:p})}case "getContentControlText":{let a=Tt(s.contentControl);return "control"in a?H({kind:"text",text:bi(a.reads,a.node,s.projection)}):a}case "getContentControlParagraphs":{let a=Tt(s.contentControl);return "control"in a?H({kind:"handles",handles:a.control.paragraphIds.map(p=>n.paragraph(p,a.reads.story))}):a}case "getContentControlRange":{let a=Tt(s.contentControl);if(!("control"in a))return a;let p=s.location??"whole";if(!ma.has(p))return y("unsupported-content","that is not a place in a control",p);let x=hn(a.reads,a.node);if(!x)return y("unsupported-content","that control holds nothing addressable","empty");let v=p==="start"||p==="before"?x.start:x.end,C=p!=="whole"&&p!=="content",F=D=>({story:a.reads.story,paragraphId:D.paragraphId,index:a.reads.indexOf(D.paragraphId),offset:D.offset});return H({kind:"span",span:Ht(C?{start:F(v),end:F(v)}:{start:F(x.start),end:F(x.end)},n)})}case "setContentControlValue":{let a=Tt(s.contentControl);if(!("control"in a))return a;let p=ha(s.value);if(!p.ok)return y(p.code,p.message,p.detail);let x=d(a.reads),v=m(x);return v||{ok:true,kind:"command",story:a.reads.story,ops:[{op:"setContentControlValue",controlId:a.control.nodeId,value:p.value}],answer:()=>at}}case "setContentControlProperties":{let a=Tt(s.contentControl);if(!("control"in a))return a;if(R&&(!xa(a.reads.part,a.control.nodeId,f)||s.lock!==void 0||s.cannotEdit!==void 0||s.cannotDelete!==void 0))return y("unsupported-capability","tracked control metadata requires an own pending insertion; locks require direct edits");if(s.tag===void 0&&s.title===void 0&&s.lock===void 0&&s.cannotEdit===void 0&&s.cannotDelete===void 0)return y("unsupported-content","nothing to write","no-properties");if(s.lock!==void 0&&!ca.has(s.lock))return y("unsupported-content","that is not a lock this schema declares",s.lock);for(let C of [s.cannotEdit,s.cannotDelete])if(C!==void 0&&typeof C!="boolean")return y("unsupported-content","lock flags must be boolean");let p=d(a.reads),x=s.lock;if(s.cannotEdit!==void 0||s.cannotDelete!==void 0){let C=x??u.get(p)?.get(a.control.nodeId)??a.control.properties.lock,F=s.cannotEdit??(C==="contentLocked"||C==="sdtContentLocked"),D=s.cannotDelete??(C==="sdtLocked"||C==="sdtContentLocked");x=F?D?"sdtContentLocked":"contentLocked":D?"sdtLocked":"unlocked";}let v=m(p);if(v)return v;if(x!==void 0){let C=u.get(p)??new Map;C.set(a.control.nodeId,x),u.set(p,C);}return {ok:true,kind:"command",story:a.reads.story,ops:[{op:"setContentControlProperties",controlId:a.control.nodeId,...s.tag===void 0?{}:{tag:s.tag},...s.title===void 0?{}:{alias:s.title},...x===void 0?{}:{lock:x}}],answer:()=>at}}case "insertContentControlText":{let a=Tt(s.contentControl);if(!("control"in a))return a;let p=ga(a.control.properties.type,s.text,s.at);if(p)return {ok:false,error:p};let x=d(a.reads),v=m(x);if(v)return v;let C=hn(a.reads,a.node);if(!C)return y("unsupported-content","that control holds nothing addressable","empty");let F=s.at==="end"?C.end:C.start,D=()=>({kind:"span",span:K({start:{story:a.reads.story,paragraphId:F.paragraphId,index:a.reads.indexOf(F.paragraphId),offset:F.offset},end:{story:a.reads.story,paragraphId:F.paragraphId,index:a.reads.indexOf(F.paragraphId),offset:F.offset+s.text.length}})});return s.at==="replace"?{ok:true,kind:"command",story:a.reads.story,ops:[{op:"setContentControlValue",controlId:a.control.nodeId,value:{kind:"text",text:s.text}}],answer:D}:{ok:true,kind:"command",story:a.reads.story,ops:s.text.length===0?[]:[{op:"insertText",paragraphId:F.paragraphId,offset:F.offset,text:s.text,inside:a.node.id}],answer:D}}case "deleteContentControl":{let a=Tt(s.contentControl);if(!("control"in a))return a;if(typeof s.keepContent!="boolean")return y("unsupported-content","keepContent is required","keepContent");let p=d(a.reads),x=m(p);return x||{ok:true,kind:"command",story:a.reads.story,ops:[{op:"removeContentControl",controlId:a.control.nodeId,keepContent:s.keepContent}],answer:()=>at}}case "insertContentControl":return ka(s,n,i,f,t.trackedRangeReplacement,(a,p)=>{let x=d(a);return m(x)??T(x,p)});case "insertCustomNode":{let a=Oi(s);if(a)return y("unsupported-content",a.message,a.detail);let p=Pi(s.payload);if(!p.ok)return y("unsupported-content","that payload cannot be written",p.field);let x=Ri(s,n,i);if("code"in x)return y(x.code,x.message,x.detail);let{start:v,end:C}=x.range,F=$(x.range);if(!F)return y("invalid-handle","that story is not in this document");let D=m(d(F));return D||{ok:true,kind:"customNodeWrite",story:F.story,write:Si(s,v,C,p.value),answer:()=>at}}default:return y("unknown-operation","this host does not implement that operation",String(s.op))}};return {plan(s,f){if(g&&Vt(s))return y("conflicting-operations","header/footer creation must commit alone");let k=h.conflict(s);if(k)return y("conflicting-operations",k.message,k.detail);let P=Ni(s,f);if(P.ok&&P.kind==="command"&&P.solitary){if(h.hasCommands)return y("conflicting-operations","header/footer creation must commit alone");g=true;}return P.ok&&h.note(s),P},get hasCommands(){return h.hasCommands},get writeScope(){return b?.reads.scope??null},settle(s){let f=b;if(f){let k=s.story(f.reads.story),P=k&&chunkANZ44KQT_cjs.Ka(k.part,f.reads.root.id),R=k&&P&&P.id!==k.root.id?nn(k,P):k;if(!R)return {ok:false,detail:`the story this batch wrote is gone: ${z(f.reads.story)}`};let a=new Set(f.reads.paragraphIds),p=R.paragraphIds.filter(v=>!a.has(v));if(p.length!==f.created.length+f.externalCreatedCount)return {ok:false,detail:`planned ${String(f.created.length+f.externalCreatedCount)} new paragraphs, the transaction made ${String(p.length)}`};f.order.filter(v=>v.id===null).forEach((v,C)=>{v.id=p[C]??null;});for(let v of f.retargets)v.slot.id&&n.retarget(v.from,v.slot.id);}for(let k of c){let P=s.story(k.range.start.story);!P||!ua(k.range,P)||t.select?.(k.range,k.mode);}return {ok:true}}}}var al=Object.freeze({status:"skipped"});function ft(t,e,o){return Object.freeze(o===void 0?{code:t,message:e}:{code:t,message:e,detail:o})}function il(t){if(t==="review-module-required"||t==="automation-structural-tracking-unsupported")return ft("unsupported-capability","this edit requires a supported review mode",t);let e=t==="unsupported-revision"||t.startsWith("unsupported-revision:");return ft(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",t)}function vt(t,e,o,n){return {ok:false,results:t.map((r,i)=>i===e?{status:"error",error:o}:al),revision:n,changed:false}}function bm(t){let{port:e}=t,o=Object.freeze({...t.capabilities}),n=Ur(),r=new Set,i=false,l={mode:"Off"},u=0,d=null,c=null,h=o.events?e.subscribe(()=>{if(i)return;let A=Object.freeze({revision:e.revision()});if(u>0)d=A;else for(let I of [...r])I(A);}):()=>{},g=A=>{if(c&&c.pkg===A)return c.value;let I=Pe(A);return c={pkg:A,value:I},I},b=A=>{let I=Array.isArray(A?.operations)?A.operations:[],S=e.revision();if(i)return vt(I,0,ft("disposed","this host was disposed"),S);if(!o.document)return vt(I,0,ft("unsupported-capability","this host has no document","document"),S);let N=e.currentPackage();if(!N)return vt(I,0,ft("document-unavailable","this host holds no document right now"),S);if(A.expectedRevision!==void 0&&A.expectedRevision!==S)return vt(I,0,ft("stale-revision","the document moved since that revision",`expected ${String(A.expectedRevision)}, at ${S}`),S);let w=lo({handles:n,reads:g(N),capabilities:o,collaborative:e.collaborative?.()??false,trackedRangeReplacement:e.trackedRangeReplacement?.()??true,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.replacementLanding?{replacementLanding:e.replacementLanding.bind(e)}:{},...e.fieldPageContext?{fieldPageContext:e.fieldPageContext.bind(e)}:{},...e.select?{select:e.select.bind(e)}:{}}),E=[],L=[],T=null,M=[],O=[],j=null,K,$=null,B=-1,Z=false,et=l;for(let U=0;U<I.length;U+=1){let dt=I[U];if(e.suggesting?.()&&dt.op!=="replaceSpan"&&(!Bn(dt)||!et.author&&["insertContentControl","setContentControlProperties","startNewList","setListLevelFormat","insertTable","insertTableRows","updateTable","updateTableCell"].includes(dt.op)))return vt(I,U,ft("unsupported-capability","this operation has no supported tracked form in suggesting mode"),S);let gt=_r(dt,e.localChangeTracking===true,et),q=gt?.step??Vr(dt,w.plan(dt,et.author),et.author);if(gt&&(et=gt.state),!q.ok)return vt(I,U,q.error,S);if(E.push(q),q.kind==="command")if(et.author&&(q.packageEdits?.length||dt.op==="setContentControlProperties")&&(Z=true),q.packageEdits&&M.push(...q.packageEdits),B<0&&(B=U),q.lifecycle)T=q.ops[0]??null;else if(q.relate){let X=q.relate;L.push(Ut=>{let Ne=Ut(X.url);return Ne===null?null:X.ops(Ne)});}else {let{ops:X}=q;L.push(()=>X);}else q.kind==="commentWrite"?(B<0&&(B=U),O.push(q.write),j=w.writeScope??{kind:"body"}):q.kind==="customNodeWrite"&&(B<0&&(B=U),$={write:q.write,scope:w.writeScope??{kind:"body"}});}let rt=false;if(O.length>0){let U=e.applyCommentWrites(O,j??{kind:"body"});if(!U.ok)return vt(I,B<0?0:B,ft("transaction-refused","the document store refused the comment write",U.reason),S);rt=U.changed,K=U.commentId;}if($){let U=e.applyCustomNodeWrite($.write,$.scope);if(!U.ok)return vt(I,B<0?0:B,ft("transaction-refused","the document store refused the custom-node write",U.reason),S);rt=U.changed;}if(T){let U=e.applyLifecycle(T);if(!U.ok)return vt(I,B<0?0:B,ft("transaction-refused","the document store refused the transaction",U.reason),S);rt=U.changed;}if(L.length>0){let U=e.apply(dt=>{let gt=[];for(let q of L){let X=q(dt);if(X===null)return null;gt.push(...X);}return gt},w.writeScope??{kind:"body"},M,Z);if(!U.ok)return vt(I,B<0?0:B,il(U.reason),S);rt=U.changed;}let It=e.currentPackage();if(!It)return vt(I,0,ft("document-unavailable","this host holds no document right now"),S);let bt=g(It),it=w.settle(bt);return it.ok?(l=et,{ok:true,results:E.map(U=>({status:"ok",value:U.kind==="query"?U.value:U.kind==="customNodeWrite"?U.answer(bt):U.answer(bt,K)})),revision:e.revision(),changed:rt}):vt(I,B<0?0:B,ft("transaction-refused","the transaction did not produce the document the batch planned",it.detail),e.revision())};return {capabilities:o,revision:()=>e.revision(),execute:A=>{u+=1;try{return b(A)}finally{if(u-=1,u===0&&d){let I=d;d=null;for(let S of [...r])S(I);}}},...e.prepare?{prepare:e.prepare.bind(e)}:{},save(){if(i)return {ok:false,error:ft("disposed","this host was disposed")};if(!o.save)return {ok:false,error:ft("unsupported-capability","this host cannot save","save")};let A=e.save();return A?{ok:true,bytes:A}:{ok:false,error:ft("document-unavailable","this host holds no document right now")}},subscribe(A){return i||!o.events?()=>{}:(r.add(A),()=>{r.delete(A);})},dispose(){i||(i=true,r.clear(),h(),e.dispose(),c=null);}}}
|
|
2
|
-
exports.a=ea;exports.b=na;exports.c=Fi;exports.d=pl;exports.e=cl;exports.f=Ye;exports.g=Pe;exports.h=Hi;exports.i=Nr;exports.j=Er;exports.k=Je;exports.l=Vt;exports.m=bm;
|
package/dist/chunk-5BIASAN3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {_a}from'./chunk-L6V3IJ3S.js';import {fa}from'./chunk-DDGGSBAN.js';var z=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,J=128,Q=/[\u0000-\u001F\u007F-\u009F]/,G=16,nn=2,en=3276;function V(e){return e.kind!=="textValue"}function P(e,n){for(let t of e.children)if(V(t)&&t.localName===n)return t}function O(e,n){return e.attributes.find(t=>t.localName===n)?.value}function D(e){return e===void 0||e.length===0||e.length>J||Q.test(e)?null:e}function v(e,n){let t=_a(O(e,"asciiTheme"),n)??_a(O(e,"hAnsiTheme"),n);if(t!==null)return t;let l=O(e,"ascii")??O(e,"hAnsi");return l===void 0?null:z.test(l)?l:null}function C(e,n){let t=_a(O(e,"eastAsiaTheme"),n);if(t!==null)return t;let l=O(e,"eastAsia");return l===void 0?null:z.test(l)?l:null}function tn(e){return e!==void 0&&z.test(e)?e:null}function On(e){return tn(e)}function ln(e){return e!==void 0&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(n=>!!O(e,n))}function Y(e,n){if(!e)return {fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};let t=P(e,"rFonts"),l=P(e,"sz"),i=l?O(l,"val"):void 0,r=i!==void 0&&/^\d{1,4}$/.test(i)?Number(i):null;return {fontFamily:t?v(t,n):null,hasLatinFontReference:ln(t),fontSizeHalfPoints:r!==null&&r>=nn&&r<=en?r:null}}function Sn(e,n){let t=new Map,l={fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};if(e){let a=P(e,"docDefaults"),s=a?P(a,"rPrDefault"):void 0;l=Y(s?P(s,"rPr"):void 0,n);for(let u of e.children){if(!V(u)||u.localName!=="style")continue;let o=D(O(u,"styleId"));if(o===null||t.has(o))continue;let f=P(u,"basedOn");t.set(o,{basedOn:D(f?O(f,"val"):void 0),own:Y(P(u,"rPr"),n)});}}let i=new Map,r=a=>{let s=a??"",u=i.get(s);if(u)return u;let o=null,f=null,m=l.hasLatinFontReference,b=new Set,y=a;for(let I=0;y!==null&&I<G&&!b.has(y);I+=1){b.add(y);let E=t.get(y);if(!E)break;o??=E.own.fontFamily,m||=E.own.hasLatinFontReference,f??=E.own.fontSizeHalfPoints,y=E.basedOn;}let g={hasLatinFontReference:m,fontFamily:o??l.fontFamily,fontSizeHalfPoints:f??l.fontSizeHalfPoints};return i.set(s,g),g};return (a,s)=>{let u=r(a),o=s?.find(b=>b.localName==="rFonts"),f=o?_a(o.attributes?.asciiTheme,n)??_a(o.attributes?.hAnsiTheme,n):null,m=["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(b=>!!o?.attributes?.[b]);return {fontFamily:f??u.fontFamily??(!u.hasLatinFontReference&&!m?n.minor:null),fontSizeHalfPoints:u.fontSizeHalfPoints}}}var an=16,on=16,rn=32,sn=4096;function x(e){return e.kind!=="textValue"}function c(e,n){for(let t of e.children)if(x(t)&&t.localName===n)return t}function M(e,n){return e.attributes.find(t=>t.localName===n)?.value}function un(e){return e==="1"||e==="true"||e==="on"}function H(){return {families:new Map,styleIds:new Set,anyText:false,bareParagraph:false,bareRun:false,bareTable:false}}function _(e,n){for(let[t,l]of n.families)e.families.has(t)||e.families.set(t,l);for(let t of n.styleIds)e.styleIds.add(t);e.anyText||=n.anyText,e.bareParagraph||=n.bareParagraph,e.bareRun||=n.bareRun,e.bareTable||=n.bareTable;}function T(e,n){if(n===null)return;let t=n.toLowerCase();e.has(t)||e.set(t,n);}var fn=new Set(["tab","noBreakHyphen","softHyphen","footnoteRef","endnoteRef","footnoteReference","endnoteReference"]),dn=128;function cn(e){for(let n of e.attributes)if(n.localName==="font"&&!(n.namespaceUri!==fa&&n.namespaceUri!==""))return n.value.length>0&&n.value.length<=dn;return false}function $(e,n){if(n?.has(e.id))return true;for(let t of e.children)if(!(!x(t)||t.namespaceUri!==fa)){if(fn.has(t.localName))return true;if(t.localName==="sym"){if(!cn(t))return true;continue}if(!(t.localName!=="t"&&t.localName!=="delText")){for(let l of t.children)if(!x(l)&&l.value.length>0)return true}}return false}function mn(e){for(let n of e.children)if(!(!x(n)||n.namespaceUri!==fa)&&!(n.localName!=="t"&&n.localName!=="delText")){for(let t of n.children)if(!x(t))for(let l of t.value){let i=l.codePointAt(0);if(i>=4352&&i<=4607||i>=11904&&i<=40959||i>=43360&&i<=43391||i>=44032&&i<=55295||i>=63744&&i<=64255||i>=65072&&i<=65103||i>=65280&&i<=65519||i>=131072&&i<=262143)return true}}return false}function K(e,n){let t=[e];for(;t.length>0;){let l=t.pop();if(x(l)){if(n?.has(l.id))return true;if(l.localName==="r"&&l.namespaceUri===fa){if($(l,n))return true;continue}for(let i of l.children)t.push(i);}}return false}function yn(e,n,t,l){if(!$(e,l))return;n.anyText=true;let i=c(e,"rPr"),r=i?c(i,"rFonts"):void 0;r&&(T(n.families,v(r,t)),mn(e)&&T(n.families,C(r,t)));let a=i?c(i,"rStyle"):void 0,s=D(a?M(a,"val"):void 0);s!==null?n.styleIds.add(s):n.bareRun=true;}function gn(e,n,t){if(!t)return;n.anyText=true;let l=e.localName==="tbl",i=c(e,l?"tblPr":"pPr"),r=i?c(i,l?"tblStyle":"pStyle"):void 0,a=D(r?M(r,"val"):void 0);a!==null?n.styleIds.add(a):l?n.bareTable=true:n.bareParagraph=true;}function X(e){return (e.localName==="p"||e.localName==="tbl")&&e.namespaceUri===fa}function U(e,n,t,l,i){e.namespaceUri===fa&&(i?.has(e.id)&&e.localName==="fldSimple"&&(n.anyText=true,n.bareRun=true),e.localName==="r"?yn(e,n,t,i):X(e)&&gn(e,n,l));}var W=new WeakMap;function q(e,n,t){let l=W.get(e);if(l&&l.major===n.major&&l.minor===n.minor&&l.majorEastAsia===n.majorEastAsia&&l.minorEastAsia===n.minorEastAsia&&l.majorBidi===n.majorBidi&&l.minorBidi===n.minorBidi)return l.summary;let i=H();if(e.children.length>=on&&t<rn){for(let r of e.children)x(r)&&_(i,q(r,n,t+1));U(e,i,n,i.anyText);}else {let r=[e];for(;r.length>0;){let a=r.pop();if(!x(a))continue;let s=X(a)&&K(a);U(a,i,n,s);for(let u=a.children.length-1;u>=0;u-=1)r.push(a.children[u]);}}return W.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,summary:i}),i}var xn={docDefaultFamilies:[],defaultParagraph:null,defaultCharacter:null,defaultTable:null,chainFamilies:()=>[]},Z=new WeakMap;function w(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?v(l,n):null}function k(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?C(l,n):null}function hn(e,n){let t=new Map,l=null,i=null,r=null,a=null,s=null,u=c(e,"docDefaults"),o=u?c(u,"rPrDefault"):void 0;o&&(l=w(o,n),i=k(o,n));let f=o?c(o,"rPr"):void 0,m=f?c(f,"rFonts"):void 0;m&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(d=>!!M(m,d))||(l??=n.minor);let y=0;for(let d of e.children){if(!x(d)||d.localName!=="style")continue;if(y>=sn)break;y+=1;let h=D(M(d,"styleId"));if(h===null)continue;let S=c(d,"basedOn"),F=[];for(let p of d.children){if(!x(p)||p.localName!=="tblStylePr")continue;let L=w(p,n);L!==null&&F.push(L);let R=k(p,n);R!==null&&F.push(R);}t.set(h,{basedOn:D(S?M(S,"val"):void 0),family:w(d,n),eastAsiaFamily:k(d,n),conditionalFamilies:F});let A=un(M(d,"default")),j=M(d,"type");j==="paragraph"?A?r=h:r===h&&(r=null):j==="character"?A?a=h:a===h&&(a=null):j==="table"&&(A?s=h:s===h&&(s=null));}let g=new Map,I=d=>{if(d===null)return [];let h=g.get(d);if(h)return h;let S=[],F=null,A=null,j=new Set,p=d;for(let L=0;p!==null&&L<an&&!j.has(p);L+=1){j.add(p);let R=t.get(p);if(!R)break;F??=R.family,A??=R.eastAsiaFamily,S.push(...R.conditionalFamilies),p=R.basedOn;}return F!==null&&S.unshift(F),A!==null&&S.unshift(A),g.set(d,S),S};return {docDefaultFamilies:[l,i].filter(d=>d!==null),defaultParagraph:r,defaultCharacter:a,defaultTable:s,chainFamilies:I}}function bn(e,n){if(!e)return {...xn,docDefaultFamilies:n.minor?[n.minor]:[]};let t=Z.get(e);if(t&&t.major===n.major&&t.minor===n.minor&&t.majorEastAsia===n.majorEastAsia&&t.minorEastAsia===n.minorEastAsia&&t.majorBidi===n.majorBidi&&t.minorBidi===n.minorBidi)return t.index;let l=hn(e,n);return Z.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,index:l}),l}function En(e,n,t,l){let i=H(),r=new Map;for(let o of e){let f=H();for(let m of o.children){if(!x(m))continue;if(!l||l.size===0){_(f,q(m,t,0));continue}let b=H(),y=[m];for(;y.length>0;){let g=y.pop();if(!x(g))continue;let I=X(g)&&K(g,l);U(g,b,t,I,l);for(let E=g.children.length-1;E>=0;E-=1)y.push(g.children[E]);}_(f,b);}_(i,f);for(let m of f.families.values())T(r,m);}let a=bn(n,t),s=new Map;for(let o of i.styleIds)for(let f of a.chainFamilies(o))T(s,f);if(i.bareParagraph)for(let o of a.chainFamilies(a.defaultParagraph))T(s,o);if(i.bareRun)for(let o of a.chainFamilies(a.defaultCharacter))T(s,o);if(i.bareTable)for(let o of a.chainFamilies(a.defaultTable))T(s,o);if(i.anyText)for(let o of a.docDefaultFamilies)T(s,o);for(let o of r.keys())s.delete(o);let u=[...s.values()].sort((o,f)=>o<f?-1:o>f?1:0);return Object.freeze({direct:Object.freeze([...r.values()]),inherited:Object.freeze(u)})}function An(e,n,t){let l=En(e,n,t),i=[...l.direct,...l.inherited];return i.sort((r,a)=>r<a?-1:r>a?1:0),i}export{tn as a,On as b,Sn as c,En as d,An as e};
|
package/dist/chunk-6SEIXJTX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {Bh,Ka,Pa,ne,me,Da,Ca,Zj,fa,Ea,qb,ib,hb,ga}from'./chunk-DDGGSBAN.js';var X=new Set(["document","hdr","ftr","footnotes","endnotes"]),W=24,U=512,E=Bh(W);function z(o){let t=o.root;return t.namespaceUri===fa&&X.has(t.localName)}function $(o){let t=[],e=r=>{if(r.kind!=="textValue"){r.namespaceUri===fa&&r.localName==="p"&&t.push(r);for(let i of r.children)e(i);}};return e(o.root),t}function V(o){let t=qb(o);let e=[],r=new Set;for(let i of $(t)){let n=ib(i);if(!n||!hb(n))continue;let a=n.toUpperCase();if(r.has(a))continue;r.add(a);let s=Zj(t,i.id);s!==null&&e.push(Object.freeze({paragraphId:a,nodeId:i.id,text:s}));}return Object.freeze(e)}function Y(o){let t=E.get(o.root);if(t)return t;let e=qb(o);let r=new Map,i=new Set,n=a=>{if(a.kind!=="textValue"){if(a.namespaceUri===fa&&a.localName==="p"){let s=ib(a);if(s&&hb(s)){let p=s.toUpperCase();i.has(p)||(i.add(p),a.kind==="paragraph"&&r.set(p,a.id));}}for(let s of a.children)n(s);}};return n(e.root),E.set(o.root,r),r}function w(o,t){if(o.length!==t.length)return false;for(let e=0;e<o.length;e+=1)if(o[e].root!==t[e])return false;return true}function B(o){let t=new Map,e=null,r=(n,a,s)=>{for(t.delete(n),t.set(n,{partName:a.name,root:a.root,nodeId:s});t.size>U;){let p=t.keys().next();if(p.done)break;t.delete(p.value);}},i=(n,a)=>{let s=t.get(n);if(!s)return null;let p=a.find(c=>c.name===s.partName);if(!p)return null;if(p.root===s.root)return {part:p,nodeId:s.nodeId};let l=Ka(p,s.nodeId);if(!l||l.kind!=="paragraph")return null;let d=ib(l);return !d||d.toUpperCase()!==n?null:(r(n,p,s.nodeId),{part:p,nodeId:s.nodeId})};return n=>{let a=o(),s=i(n,a);if(s)return s;if(e&&e.ids.has(n)&&w(a,e.roots))return null;for(let p of a){let l=Y(p).get(n);if(l!==void 0)return r(n,p,l),{part:p,nodeId:l}}return (!e||!w(a,e.roots))&&(e={roots:a.map(p=>p.root),ids:new Set}),e.ids.size<U&&e.ids.add(n),null}}function H(o,t){return Ea(o,t)}var q=Object.freeze({kind:"body"}),F=1e6;function b(o,t){if(t<=0||t>=o.length)return false;let e=o.charCodeAt(t-1),r=o.charCodeAt(t);return e>=55296&&e<=56319&&r>=56320&&r<=57343}function Q(o,t,e){if(t===e)return [];let r=0,i=Math.min(t.length,e.length);for(;r<i&&t.charCodeAt(r)===e.charCodeAt(r);)r+=1;for(;r>0&&(b(t,r)||b(e,r));)r-=1;let n=0;for(;n<t.length-r&&n<e.length-r&&t.charCodeAt(t.length-n-1)===e.charCodeAt(e.length-n-1);)n+=1;for(;n>0&&(b(t,t.length-n)||b(e,e.length-n));)n-=1;let a=t.length-r-n,s=e.slice(r,e.length-n),p=[];return a>0&&p.push({op:"deleteText",paragraphId:o,start:r,end:r+a}),s.length>0&&p.push({op:"insertText",paragraphId:o,offset:r,text:s}),Object.freeze(p)}function K(o){let t=r=>!!r&&r.kind!=="textValue"&&r.namespaceUri===fa&&r.localName==="t"&&r.attributes.every(i=>i.namespaceUri===ga&&i.localName==="space")&&r.children.every(i=>i.kind==="textValue"),e=[];for(let r of o){let i=e.at(-1);if(!t(i)||!t(r)){e.push(r);continue}let n=i.children.map(a=>a.kind==="textValue"?a.value:"").join("")+r.children.map(a=>a.kind==="textValue"?a.value:"").join("");e[e.length-1]={...i,attributes:/^\s|\s$/.test(n)?[{kind:"xmlSpace",namespaceUri:ga,localName:"space",prefix:"xml",value:"preserve"}]:[],children:[{id:i.children[0]?.id??`${i.id}/text`,kind:"textValue",value:n}]};}return e}function G(o){if(o.kind==="textValue")return o;let t=false,e=o.children.map(r=>{let i=G(r);return i!==r&&(t=true),i});if(o.namespaceUri===fa&&o.localName==="r"){let r=K(e);(r.length!==e.length||r.some((i,n)=>i!==e[n]))&&(e=[...r],t=true);}return t?{...o,children:e}:o}function rr(o,t,e){let r=o.parts.get(t);if(!r)return o;let i=false,n=new Set;for(let a of e)(a.op==="insertText"||a.op==="deleteText")&&!a.revision&&n.add(a.paragraphId);for(let a of n){let s=Ka(r,a);if(!s||s.kind==="textValue")continue;let p=G(s);if(p===s)continue;let l=Pa(r,a,p,{deferValidation:true});l.ok&&(r=l.part,i=true);}return i?ne(o,r):o}function er(o,t){let e=t.documentId.trim();if(e.length===0||e.length>256)throw new TypeError("documentId must contain 1 to 256 characters");let r=()=>V(o.bodyStore().part),i,a=B(()=>{let l=o.bodyStore().part,d=o.currentPackage();if(i?.pkg===d&&i.body===l)return i.parts;let c=[l];for(let g of d.parts.values())g===l||!z(g)||c.push(g);return i={pkg:d,body:l,parts:Object.freeze(c)},i.parts}),s=(l,d)=>{if(l.length===0)return {ok:true,changed:false};let c=r(),g=new Set,h=[];for(let u of l){if(typeof u.text!="string"||u.text.length>F)return {ok:false,reason:"collaboration-text-limit"};if(typeof u.paragraphId!="string"||u.paragraphId.length===0||u.paragraphId.length>256)return {ok:false,reason:"unknown-paragraph-id"};let m=u.paragraphId.toUpperCase();if(g.has(m))return {ok:false,reason:"duplicate-paragraph-id"};g.add(m);let N=c.filter(L=>L.paragraphId===m);if(N.length!==1)return {ok:false,reason:"unknown-paragraph-id"};let T=N[0];h.push(...Q(T.nodeId,T.text,u.text));}if(h.length===0)return {ok:true,changed:false};let y=o.transact(q,u=>{for(let m of h)u.apply(m);u.applyPackage(m=>rr(m,m.mainDocumentPart,h));},{origin:d.origin,actorId:d.actorId,operationId:d.operationId,recordsHistory:false});return y.ok?{ok:true,changed:y.change!==null}:{ok:false,reason:y.detail??y.reason}};return Object.freeze({documentId:e,paragraphs:r,paragraphByNodeId(l){return r().find(d=>d.nodeId===l)??null},paragraphByStableId(l){let d=l.toUpperCase(),c=a(d);if(!c)return null;let g=Zj(c.part,c.nodeId);return g===null?null:Object.freeze({paragraphId:d,nodeId:c.nodeId,text:g})},applyParagraphText(l,d,c){return s([{paragraphId:l,text:d}],c)},applyParagraphTexts:s,applyRemotePackage(l,d){let c=o.publishRemotePackage(l,d);return c.ok?{ok:true,changed:c.change!==null}:{ok:false,reason:c.detail??c.reason}},revision:()=>o.packageRevision,subscribe:l=>o.subscribe(l),observePrimitiveJournal:l=>H(o,l),hasPendingJournals:()=>Ca(o),flushPendingJournals:()=>{Da(o);},save:()=>me(o.currentPackage()),binaryPart(l){let d=o.currentPackage();return d.partBytes.get(l)??d.partBytes.get(l.startsWith("/")?l.slice(1):`/${l}`)??null}})}export{rr as a,er as b};
|
package/dist/chunk-73PG6L2X.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {Ga}from'./chunk-L6V3IJ3S.js';import {if as _if,Ye,Te,jf,Ze,$e,kf,hf,Wa}from'./chunk-DDGGSBAN.js';function U(e){return e.kind!=="textValue"}function k(e,t){for(let l of e.children)if(U(l)&&l.localName===t)return l}function _(e,t){return e.attributes.find(l=>l.localName===t)?.value}function Y(e){let t=k(e,"pPr"),l=t?k(t,"outlineLvl"):void 0;if(l){let i=_(l,"val");return i!==void 0&&/^[0-8]$/.test(i)?Number(i):null}let n=k(e,"name"),o=n?/^heading\s+([1-9])$/i.exec(_(n,"val")?.trim()??""):null;return o?Number(o[1])-1:null}function h(e,t=0,l=e.length,n){let o=new Set,i=new Map,d=new Map,a=n?[n]:[];n&&o.add(n);for(let s=t;s<l;s+=1){let r=e[s].node;if(Ye(r,"begin")){a.push(r.id);continue}if(Ye(r,"separate")){let u=a[a.length-1];u&&(o.add(u),i.set(r.id,u));continue}if(Ye(r,"end")){let u=a.pop();u&&(o.add(u),d.set(r.id,u));}}return {activeBegins:o,separateBegin:i,endBegin:d}}function b(e,t,l){if(Ye(l,"begin"))return t.activeBegins.has(l.id)&&e.push({beginId:l.id,separated:false}),true;if(Ye(l,"separate")){let n=t.separateBegin.get(l.id),o=e[e.length-1];return n&&o?.beginId===n&&(o.separated=true),true}if(Ye(l,"end")){let n=t.endBegin.get(l.id),o=e[e.length-1];return n&&o?.beginId===n&&e.pop(),true}return false}function g(e){for(let t of e)if(!t.separated)return false;return true}function K(e,t){let l=[];_if(e,l,t);let n=h(l),o=[];return {consume:i=>b(o,n,i),visible:()=>g(o)}}var j=4096,L=jf*16;function O(){return {out:[],runs:[],symbols:[],symbolDisplays:[],length:0}}function v(e,t,l,n){if(t.length===0||l===n)return;let o=e.runs[e.runs.length-1];if(o?.runId===t&&o.end===l){e.runs[e.runs.length-1]={runId:t,start:o.start,end:n};return}e.runs.push({runId:t,start:l,end:n});}function C(e,t,l,n){let o=hf(t);if(o.length>n.left)return false;if(n.left-=o.length,o.length>0){let i=e.length;Wa(t)&&(e.symbols.push(i),e.symbolDisplays.push(Ga(t))),e.out.push(o),e.length+=o.length,v(e,l,i,e.length);}return true}function X(e,t){let l=e.length;t.text.length>0&&e.out.push(t.text),e.length+=t.text.length;for(let n of t.runs)v(e,n.runId,l+n.start,l+n.end);for(let n of t.symbols??[])e.symbols.push(l+n);for(let n of t.symbolDisplays??[])e.symbolDisplays.push(n);}function N(e){let t=e.out.join("");return e.symbols.length>0?{text:t,runs:e.runs,symbols:e.symbols,symbolDisplays:e.symbolDisplays}:{text:t,runs:e.runs}}var H=Object.freeze({text:"",runs:[]});function M(){return {text:Te,runs:[]}}function $(e,t,l,n){let o=[];if(!_if(e,o,l))return null;let i=o.reverse(),d=O();for(;i.length>0;){let a=i.pop();if(!(t==="original"&&a.hiddenInOriginal)){if($e(a.node)){let s=[];if(!_if(a.node,s,l))return null;for(let r=s.length-1;r>=0;r-=1)i.push(s[r]);continue}if(!Ze(a.node)&&!C(d,a.node,a.runId,n))return null}}return N(d)}function z(e,t,l,n,o){let i=O(),d=[],a=h(e);for(let s of e){let r=s.node;if(!b(d,a,r)&&!Ze(r)&&g(d)&&!(t==="original"&&s.hiddenInOriginal)){if($e(r)){let u=o>=kf?$(r,t,l,n):V(r,t,l,n,o+1);if(u===null)return null;X(i,u);continue}if(!C(i,r,s.runId,n))return null}}return N(i)}function V(e,t,l,n,o){let i=[];return _if(e,i,l)?z(i,t,l,n,o):null}function G(e,t,l){let n=t.node;return e.owned.has(n.id)&&(e.nodesLeft-=1,e.nodesLeft<0&&(e.overflow=true)),n.id===e.endId?true:(n.id===e.span.node.id||b(e.states,e.markers,n)||e.overflow||Ze(n)||$e(n)||!e.owned.has(n.id)||!g(e.states)||l==="original"&&t.hiddenInOriginal||C(e.result,n,t.runId,e.chars)||(e.overflow=true),false)}function te(e,t,l="allMarkup"){let n=new Map,o=new Map,i=new Map;for(let r of t)r.kind==="complex"?o.set(r.node.id,r):i.set(r.node.id,r);let d=[];_if(e,d);let a=new Map;for(let r=0;r<d.length;r+=1)a.set(d[r].node.id,r);let s=null;for(let r=0;r<d.length;r+=1){let u=d[r],y=i.get(u.node.id);if(y)if(s!==null&&!g(s.states))n.set(y.node.id,H);else {let f={left:j},I={left:L},m=V(y.node,l,f,I,0);n.set(y.node.id,m??M());}if(s===null){let f=o.get(u.node.id);if(!f)continue;let I=new Set(f.removeNodeIds),m=-1;for(let S=f.removeNodeIds.length-1;S>=0;S-=1){let x=a.get(f.removeNodeIds[S]);if(!(x===void 0||x<=r)&&Ye(d[x].node,"end")){m=x;break}}let w=d[m];if(!w){n.set(f.node.id,M());continue}s={span:f,owned:I,states:[{beginId:f.node.id,separated:false}],markers:h(d,r+1,m,f.node.id),endId:w.node.id,result:O(),chars:{left:L},nodesLeft:j,overflow:false};}G(s,u,l)&&(n.set(s.span.node.id,s.overflow?M():N(s.result)),s=null);}return s!==null&&n.set(s.span.node.id,M()),n}export{K as a,j as b,te as c,Y as d};
|