@docx-editor.dev/core 2.9.2 → 2.11.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.
Files changed (140) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.cts +14 -5
  3. package/dist/automation.d.ts +14 -5
  4. package/dist/automation.js +1 -1
  5. package/dist/binding.cjs +1 -1
  6. package/dist/binding.d.cts +78 -13
  7. package/dist/binding.d.ts +78 -13
  8. package/dist/binding.js +1 -1
  9. package/dist/chunk-34BNQUD4.js +10 -0
  10. package/dist/chunk-5AVHO75P.cjs +19 -0
  11. package/dist/chunk-6HMSC7UV.js +2 -0
  12. package/dist/chunk-6JIJOZDW.js +1 -0
  13. package/dist/chunk-76Y3Y45J.cjs +2 -0
  14. package/dist/chunk-BP7ANXGA.js +1 -0
  15. package/dist/chunk-BTQKU64Q.cjs +1 -0
  16. package/dist/chunk-CRZR6K5Z.js +19 -0
  17. package/dist/chunk-D5EHDHYV.js +1 -0
  18. package/dist/chunk-EJATEGJZ.cjs +1 -0
  19. package/dist/{chunk-PSZH2VXP.js → chunk-GOEBQ26R.js} +1 -1
  20. package/dist/chunk-GRDFEH5Q.cjs +2 -0
  21. package/dist/chunk-GWV65NQW.cjs +10 -0
  22. package/dist/chunk-GXLZCXEH.js +2 -0
  23. package/dist/chunk-JUQOPVSK.cjs +2 -0
  24. package/dist/chunk-LAETEBHD.js +1 -0
  25. package/dist/chunk-M6Z3KFXM.cjs +5 -0
  26. package/dist/{chunk-YMYCPY5Y.cjs → chunk-OHJQ7GPZ.cjs} +1 -1
  27. package/dist/chunk-UQFOYZJO.cjs +18 -0
  28. package/dist/chunk-WPQMPHNR.cjs +1 -0
  29. package/dist/chunk-WXQ245MQ.js +18 -0
  30. package/dist/chunk-WZHIFNSU.js +5 -0
  31. package/dist/chunk-X7A5XART.js +2 -0
  32. package/dist/chunk-ZKWRCLT2.cjs +1 -0
  33. package/dist/collaboration/replication.cjs +1 -0
  34. package/dist/collaboration/replication.d.cts +216 -0
  35. package/dist/collaboration/replication.d.ts +216 -0
  36. package/dist/collaboration/replication.js +1 -0
  37. package/dist/collaboration.cjs +1 -0
  38. package/dist/collaboration.d.cts +176 -0
  39. package/dist/collaboration.d.ts +176 -0
  40. package/dist/collaboration.js +1 -0
  41. package/dist/contracts/document.d.cts +6 -1
  42. package/dist/contracts/document.d.ts +6 -1
  43. package/dist/contracts/editor.cjs +1 -1
  44. package/dist/contracts/editor.d.cts +8 -9
  45. package/dist/contracts/editor.d.ts +8 -9
  46. package/dist/contracts/editor.js +1 -1
  47. package/dist/contracts/interaction.d.cts +8 -9
  48. package/dist/contracts/interaction.d.ts +8 -9
  49. package/dist/contracts/modules.cjs +1 -1
  50. package/dist/contracts/modules.d.cts +20 -8
  51. package/dist/contracts/modules.d.ts +20 -8
  52. package/dist/contracts/modules.js +1 -1
  53. package/dist/custom-node-writes-CwkYRw3V.d.cts +310 -0
  54. package/dist/custom-node-writes-JfTn-Sy6.d.ts +310 -0
  55. package/dist/document-properties-D6Ahr8D6.d.cts +28 -0
  56. package/dist/document-properties-D6Ahr8D6.d.ts +28 -0
  57. package/dist/{editor-Cvd7Geoc.d.ts → editor-BogcVHXk.d.ts} +176 -59
  58. package/dist/{editor-cAEf1uXW.d.cts → editor-C8edZgy5.d.cts} +176 -59
  59. package/dist/editor.cjs +1 -1
  60. package/dist/editor.css +1 -7698
  61. package/dist/editor.d.cts +26 -25
  62. package/dist/editor.d.ts +26 -25
  63. package/dist/editor.js +1 -1
  64. package/dist/failure-BnGjoXf0.d.cts +64 -0
  65. package/dist/failure-BnGjoXf0.d.ts +64 -0
  66. package/dist/{index-DRqY5JVF.d.ts → index-BNv-ZLQP.d.ts} +327 -86
  67. package/dist/{index-wb-iOxfh.d.cts → index-Dn0lOp9Z.d.cts} +327 -86
  68. package/dist/index.cjs +1 -1
  69. package/dist/index.d.cts +20 -19
  70. package/dist/index.d.ts +20 -19
  71. package/dist/index.js +1 -1
  72. package/dist/layout.cjs +1 -1
  73. package/dist/layout.d.cts +92 -55
  74. package/dist/layout.d.ts +92 -55
  75. package/dist/layout.js +1 -1
  76. package/dist/{note-properties-jvnw_DGG.d.ts → note-properties-BmoSdyKS.d.ts} +1 -1
  77. package/dist/{note-properties-CQlxjic_.d.cts → note-properties-BvGfHk5e.d.cts} +1 -1
  78. package/dist/{omml-equation-Dd3mBep-.d.ts → omml-equation-Ciq5rgb7.d.ts} +1 -1
  79. package/dist/{omml-equation-BD-LsmWE.d.cts → omml-equation-CqQOt_dD.d.cts} +1 -1
  80. package/dist/output.cjs +1 -1
  81. package/dist/output.d.cts +6 -8
  82. package/dist/output.d.ts +6 -8
  83. package/dist/output.js +1 -1
  84. package/dist/{protocol-UuZOcOp7.d.cts → protocol-BB-WP3zk.d.cts} +2 -2
  85. package/dist/{protocol-C7ahrdUx.d.ts → protocol-Ckl7hWsv.d.ts} +2 -2
  86. package/dist/{review-items-bdGxFWNA.d.ts → review-items-BdeLNRi2.d.cts} +1 -2
  87. package/dist/{review-items-B8tffIXj.d.cts → review-items-CkYyXhXM.d.ts} +1 -2
  88. package/dist/{review-reads-Bxz03tHG.d.cts → review-reads-BOLSBm5w.d.cts} +2 -2
  89. package/dist/{review-reads-CHODU0LI.d.ts → review-reads-Crf0Xn42.d.ts} +2 -2
  90. package/dist/{revision-projection-CILpvv4M.d.ts → revision-projection-Ae2CWa8E.d.ts} +1 -1
  91. package/dist/{revision-projection-Cc4wz30g.d.cts → revision-projection-C2S8PSQm.d.cts} +1 -1
  92. package/dist/{semantic-cell-selection-BPzx6DdT.d.cts → semantic-cell-selection-C0OFD4D9.d.cts} +4 -4
  93. package/dist/{semantic-cell-selection-CsHcr-yk.d.ts → semantic-cell-selection-DdmoxC-y.d.ts} +4 -4
  94. package/dist/{semantic-interaction-D-RZ9Ust.d.ts → semantic-interaction-COyhZ9WH.d.ts} +21 -2
  95. package/dist/{semantic-interaction-BfWDD_0V.d.cts → semantic-interaction-Cs2jErnt.d.cts} +21 -2
  96. package/dist/{semantic-paint-WhVtSDJK.d.ts → semantic-paint-UHaj3sBY.d.cts} +2 -2
  97. package/dist/{semantic-paint-Bd7EqzXV.d.cts → semantic-paint-vA-oLSdV.d.ts} +2 -2
  98. package/dist/{semantic-records-DadVT_E1.d.cts → semantic-records-5AOQJmLX.d.cts} +20 -5
  99. package/dist/{semantic-records-DCt-ZwKU.d.ts → semantic-records-9xhwbJ23.d.ts} +20 -5
  100. package/dist/{shaped-measurer-CninrHr_.d.cts → shaped-measurer-NeF2mPSu.d.cts} +1 -1
  101. package/dist/{shaped-measurer-B9f4A7QA.d.ts → shaped-measurer-vzsY88oK.d.ts} +1 -1
  102. package/dist/store.cjs +1 -1
  103. package/dist/store.d.cts +193 -19
  104. package/dist/store.d.ts +193 -19
  105. package/dist/store.js +1 -1
  106. package/dist/tree-op-types-BPyXNxyL.d.cts +3053 -0
  107. package/dist/tree-op-types-DnzAOnc9.d.ts +3053 -0
  108. package/dist/{custom-node-writes-D6SGwebL.d.ts → tree-package-fragment-BjZ3RWAS.d.cts} +128 -312
  109. package/dist/{custom-node-writes-Dy3b20PS.d.cts → tree-package-fragment-CDER0G3B.d.ts} +128 -312
  110. package/dist/{tree-session-ZuBFOhIh.d.ts → tree-session-contract-BF2FVBOM.d.cts} +52 -106
  111. package/dist/{tree-session-Df02ajqc.d.cts → tree-session-contract-DhdsFT_z.d.ts} +52 -106
  112. package/dist/{tree-store-B_sJBMIS.d.cts → tree-store-CNZ3O83s.d.ts} +130 -25
  113. package/dist/{tree-store-DgETo6Mf.d.ts → tree-store-DfZi7FqY.d.cts} +130 -25
  114. package/package.json +14 -3
  115. package/dist/chunk-6JWP2H7K.js +0 -2
  116. package/dist/chunk-6KNLLEUW.cjs +0 -18
  117. package/dist/chunk-7ADTI533.cjs +0 -10
  118. package/dist/chunk-7ETDCPF6.cjs +0 -2
  119. package/dist/chunk-7I3BSGGS.js +0 -1
  120. package/dist/chunk-7UU5YFCD.cjs +0 -2
  121. package/dist/chunk-7VQ7YLW3.cjs +0 -1
  122. package/dist/chunk-CKDAK3MV.js +0 -10
  123. package/dist/chunk-DIMEYVNS.js +0 -2
  124. package/dist/chunk-GQQOL4PV.js +0 -1
  125. package/dist/chunk-H2656QDI.cjs +0 -1
  126. package/dist/chunk-KQGENNL5.cjs +0 -15
  127. package/dist/chunk-LIXPSV4T.js +0 -18
  128. package/dist/chunk-O4UULRAQ.cjs +0 -5
  129. package/dist/chunk-SIIFNE6U.js +0 -15
  130. package/dist/chunk-VXYECPKA.js +0 -5
  131. package/dist/hf-references-Dvk6De4Q.d.cts +0 -70
  132. package/dist/hf-references-z5Y4N1ab.d.ts +0 -70
  133. package/dist/image-resources-BgA9EQxY.d.ts +0 -203
  134. package/dist/image-resources-BiA-IXgo.d.cts +0 -203
  135. package/dist/note-nodes-BNCANoGN.d.ts +0 -108
  136. package/dist/note-nodes-DL-Au22P.d.cts +0 -108
  137. package/dist/ooxml-package-CdEy9ufK.d.cts +0 -1222
  138. package/dist/ooxml-package-CdEy9ufK.d.ts +0 -1222
  139. package/dist/tree-op-types-CnRb7AYo.d.ts +0 -1589
  140. package/dist/tree-op-types-D1vNJ7XC.d.cts +0 -1589
@@ -0,0 +1 @@
1
+ var a=Object.freeze({review:null,collaboration:null,customNodes:Object.freeze([]),customNodePayloadNamespaces:Object.freeze([]),customNodeDiagnostics:Object.freeze([])});function d(e){if(!e||e.length===0)return a;let t=null,n=null,i=[],r=new Set,s=[];for(let o of e){o.review&&t===null&&(t=o.review),o.collaboration&&n===null&&(n=o.collaboration),o.customNodes&&i.push(...o.customNodes);for(let l of o.customNodePayloadNamespaces??[])r.add(l);o.onCustomNodeDiagnostic&&s.push(o.onCustomNodeDiagnostic);}return {review:t,collaboration:n,customNodes:i,customNodePayloadNamespaces:[...r],customNodeDiagnostics:s}}export{d as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk76Y3Y45J_cjs=require('./chunk-76Y3Y45J.cjs'),chunkGWV65NQW_cjs=require('./chunk-GWV65NQW.cjs');var Bt=Object.freeze(["default","first","even"]),ct=Object.freeze({kind:"body"});function B(n){switch(n.kind){case "body":return "body";case "note":return `note:${n.noteKind}:${String(n.noteId)}`;default:return `${n.kind}:${String(n.sectionIndex)}:${n.variant}`}}function an(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="body"?true: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&&Bt.includes(e.variant)}var fr=["getDocument","getBody","getParagraphs","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"],lo=["insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],uo=["deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],co=new Set(uo);function Zt(n){return co.has(n.op)}var po=new Set(lo);function qt(n){return po.has(n.op)}function mo(){let n=globalThis.crypto,e=n?.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 s=e.call(n,new Uint8Array(16)),a="";for(let i of s)a+=i.toString(16).padStart(2,"0");return a}function fo(n){return typeof n=="object"&&n!==null&&"kind"in n&&"ref"in n}function sn(){let n=new Map,e=new Map,s=new Map,a=new Map,i=mo(),u=null,c=(m,y)=>{let v=(a.get(m)??0)+1;a.set(m,v);let k=`${m}:${i}:${String(v)}`;return n.set(k,y),Object.freeze({kind:m,ref:k})},g=(m,y,v)=>{let k=`${m}\0${y}`,S=s.get(k);if(S)return Object.freeze({kind:m,ref:S});let A=c(m,v);return s.set(k,A.ref),A};return {document(){return u??=c("document",{kind:"document"}),u},body(m){return g("body",B(m),{kind:"body",story:m})},paragraph(m,y){let v=e.get(m);if(v)return Object.freeze({kind:"paragraph",ref:v});let k=c("paragraph",{kind:"paragraph",paragraphId:m,story:y});return e.set(m,k.ref),k},section(m){return g("section",String(m),{kind:"section",index:m})},note(m,y){return g("note",`${m}:${String(y)}`,{kind:"note",noteKind:m,noteId:y})},comment(m,y){return g("comment",`${B(y)}\0${m}`,{kind:"comment",commentId:m,story:y})},revision(m,y){return g("revision",`${B(y)}\0${m}`,{kind:"revision",revisionId:m,story:y})},bookmark(m,y){return g("bookmark",`${B(y)}\0${m}`,{kind:"bookmark",name:m,story:y})},list(m,y){return g("list",`${B(y)}\0${m}`,{kind:"list",numId:m,story:y})},contentControl(m,y){return g("contentControl",`${B(y)}\0${m}`,{kind:"contentControl",nodeId:m,story:y})},retarget(m,y){let v=e.get(m);if(!v||m===y)return;let k=n.get(v);!k||k.kind!=="paragraph"||(e.delete(m),n.set(v,{kind:"paragraph",paragraphId:y,story:k.story}),e.has(y)||e.set(y,v));},resolve(m,y){if(!fo(m)||m.kind!==y||typeof m.ref!="string")return null;let v=n.get(m.ref);return !v||v.kind!==y?null:v}}}var yo=255,go=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function dn(n){let e=chunkGWV65NQW_cjs.td(n);if(!e)return go;let s=new Map,a=new Map,i=null;for(let u of chunkGWV65NQW_cjs.sd(e).values())if(u.type==="paragraph"){if(s.set(u.styleId,u.name),u.name!==null){let c=u.name.trim().toLowerCase();a.has(c)||a.set(c,u.styleId);}u.isDefault&&i===null&&(i=u.styleId);}return Object.freeze({nameOf:u=>s.get(u)??null,idOf:u=>a.get(u.trim().toLowerCase())??null,defaultId:i,present:true})}function Ft(n,e,s){let a=chunkGWV65NQW_cjs.Ca(n,e);if(!a||a.kind!=="paragraph")return null;let i=ho(chunkGWV65NQW_cjs.De(chunkGWV65NQW_cjs.Be(a),"pStyle"));return i!==null?s.nameOf(i):s.defaultId===null?null:s.nameOf(s.defaultId)}function ho(n){if(!n)return null;for(let e of n.attributes)if(e.localName==="val")return e.value;return null}function _t(n,e){if(typeof n!="string"||n.trim().length===0)return {ok:false,detail:"style: not a name"};if(n.length>yo)return {ok:false,detail:"style: name too long"};if(!chunkGWV65NQW_cjs.O(n))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let s=e.idOf(n);return s===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:s}}var ko=31680,Ao=1999,vo=Object.freeze({bold:null,italic:null,name:null,size:null,color:null});function Y(n,e){if(!n)return null;for(let s of n.attributes)if(s.localName===e)return s.value;return null}function te(n){if(!n)return null;let e=Y(n,"val");if(e===null)return true;let s=e.trim().toLowerCase();return !(s==="0"||s==="false"||s==="off"||s==="none")}function bo(n){if(n===null)return null;let e=n.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function xo(n){if(n===null)return null;let e=Number(n.trim());return !Number.isFinite(e)||e<=0?null:e/2}function ft(n){if(n===null)return null;let e=Number(n.trim());return Number.isFinite(e)?chunkGWV65NQW_cjs.id(chunkGWV65NQW_cjs.gd(e)):null}function Rt(n){if(n.length===0)return null;let e=n[0];if(e===null)return null;for(let s of n)if(s!==e)return null;return e}function un(n,e,s=chunk76Y3Y45J_cjs.C){let a=[];for(let i of e)for(let u of chunk76Y3Y45J_cjs.U(n,i.paragraphId,i.start,i.end,s))a.push(chunkGWV65NQW_cjs.Ce(u));return a.length===0?vo:{bold:Rt(a.map(i=>te(chunkGWV65NQW_cjs.De(i,"b")))),italic:Rt(a.map(i=>te(chunkGWV65NQW_cjs.De(i,"i")))),name:Rt(a.map(i=>{let u=chunkGWV65NQW_cjs.De(i,"rFonts"),c=Y(u,"ascii");return c===null||c.length===0?null:c})),size:Rt(a.map(i=>xo(Y(chunkGWV65NQW_cjs.De(i,"sz"),"val")))),color:Rt(a.map(i=>bo(Y(chunkGWV65NQW_cjs.De(i,"color"),"val"))))}}var Io=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),So=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function Ro(n){let e=Y(chunkGWV65NQW_cjs.De(n,"jc"),"val");return e===null?"Unknown":Io[e.trim().toLowerCase()]??"Unknown"}function cn(n,e,s){let a=chunkGWV65NQW_cjs.Ca(n,e);if(!a||a.kind!=="paragraph")return null;let i=chunkGWV65NQW_cjs.Be(a),u=chunkGWV65NQW_cjs.De(i,"spacing"),c=chunkGWV65NQW_cjs.De(i,"ind");return {alignment:Ro(i),style:Ft(n,e,s),firstLineIndent:Co(c),leftIndent:ft(Y(c,"left")??Y(c,"start")),rightIndent:ft(Y(c,"right")??Y(c,"end")),lineSpacing:ft(Y(u,"line")),spaceBefore:ft(Y(u,"before")),spaceAfter:ft(Y(u,"after")),widowControl:te(chunkGWV65NQW_cjs.De(i,"widowControl"))}}function Co(n){let e=ft(Y(n,"hanging"));if(e!==null&&e>0)return -e;let s=ft(Y(n,"firstLine"));return s!==null?s:e===null?null:-e}function Dt(n,e){if(typeof n!="number"||!Number.isFinite(n))return {ok:false,detail:`${e}: not a measurement`};let s=chunkGWV65NQW_cjs.jd(chunkGWV65NQW_cjs.hd(n));return Math.abs(s)>ko?{ok:false,detail:`${e}: out of range`}:{ok:true,value:s}}function pn(n){let e=[];if(n.bold!==void 0){if(typeof n.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};e.push({localName:"b",...n.bold?{}:{attributes:{val:"0"}}});}if(n.italic!==void 0){if(typeof n.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};e.push({localName:"i",...n.italic?{}:{attributes:{val:"0"}}});}if(n.name!==void 0){let s=n.name;if(typeof s!="string"||s.length===0||s.length>128)return {ok:false,detail:"name: not a font name"};if(!chunkGWV65NQW_cjs.O(s))return {ok:false,detail:"name: not valid XML text"};e.push({localName:"rFonts",attributes:{ascii:s,hAnsi:s}});}if(n.size!==void 0){let s=n.size;if(typeof s!="number"||!Number.isFinite(s)||s<=0)return {ok:false,detail:"size: not a positive number of points"};let a=Math.round(s*2);if(a<1||a>Ao)return {ok:false,detail:"size: out of range"};e.push({localName:"sz",attributes:{val:String(a)}}),e.push({localName:"szCs",attributes:{val:String(a)}});}if(n.color!==void 0){let s=n.color;if(typeof s!="string"||!/^#[0-9a-fA-F]{6}$/.test(s.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};e.push({localName:"color",attributes:{val:s.trim().slice(1).toUpperCase()}});}return e.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:e}}function mn(n,e,s,a){let i=chunkGWV65NQW_cjs.Ca(n,e);if(!i||i.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let u=chunkGWV65NQW_cjs.Be(i),c=[];if(s.style!==void 0){let A=_t(s.style,a);if(!A.ok)return {ok:false,detail:A.detail};c.push({localName:"pStyle",attributes:{val:A.styleId}});}if(s.alignment!==void 0){let A=So[s.alignment];if(A===void 0)return {ok:false,detail:`alignment: ${String(s.alignment)}`};c.push({localName:"jc",attributes:{val:A}});}let g=chunkGWV65NQW_cjs.De(u,"ind"),m=ln(g),y=false;if(s.firstLineIndent!==void 0){let A=Dt(s.firstLineIndent,"firstLineIndent");if(!A.ok)return A;delete m.firstLine,delete m.hanging,A.value<0?m.hanging=String(-A.value):m.firstLine=String(A.value),y=true;}for(let[A,b,C]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let O=s[A];if(O===void 0)continue;let T=Dt(O,A);if(!T.ok)return T;delete m[C],m[b]=String(T.value),y=true;}y&&c.push({localName:"ind",attributes:m});let v=chunkGWV65NQW_cjs.De(u,"spacing"),k=ln(v),S=false;for(let[A,b]of [["spaceBefore","before"],["spaceAfter","after"]]){let C=s[A];if(C===void 0)continue;let O=Dt(C,A);if(!O.ok)return O;if(O.value<0)return {ok:false,detail:`${A}: out of range`};k[b]=String(O.value),S=true;}if(s.lineSpacing!==void 0){let A=Dt(s.lineSpacing,"lineSpacing");if(!A.ok)return A;if(A.value<=0)return {ok:false,detail:"lineSpacing: out of range"};k.line=String(A.value),k.lineRule??="auto",S=true;}if(S&&c.push({localName:"spacing",attributes:k}),s.widowControl!==void 0){if(typeof s.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};c.push({localName:"widowControl",...s.widowControl?{}:{attributes:{val:"0"}}});}return c.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:chunk76Y3Y45J_cjs.M(chunk76Y3Y45J_cjs.K(n,e),c)}}function ln(n){let e=Object.create(null);if(!n)return e;for(let s of n.attributes)e[s.localName]=s.value;return e}function fn(){let n=false,e=false,s=false;return {conflict(a){let i=qt(a),u=Zt(a),c=a.op==="deleteComment";return u&&n||e&&i?{message:"that command commits on its own and cannot share a batch",detail:a.op}:c&&n&&!s||s&&i&&!c?{message:"comment deletions may share a batch only with other comment deletions",detail:a.op}:null},note(a){qt(a)&&(n=true,Zt(a)&&(e=true),a.op==="deleteComment"&&(s=true));},get hasCommands(){return n}}}var Po=63360;function lt(n){return Math.round(chunkGWV65NQW_cjs.id(chunkGWV65NQW_cjs.gd(n))*100)/100}function Oo(n,e){if(typeof n!="number"||!Number.isFinite(n))return null;let s=chunkGWV65NQW_cjs.jd(chunkGWV65NQW_cjs.hd(n));return s>Po||s<0||s===0&&!e?null:s}var wo=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function yn(n){if(typeof n!="object"||n===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=n,s={},a=0;for(let[u,c,g]of wo){let m=e[u];if(m===void 0)continue;let y=Oo(m,g);if(y===null)return {ok:false,reason:`that is not a value for ${u}`,detail:String(m)};s[c]=y,a+=1;}let i=e.orientation;if(i!==void 0){if(i!=="portrait"&&i!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(i)};s.orientation=i,a+=1;}return a===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:s}}function To(n){let e=chunkGWV65NQW_cjs.Ig(n),s=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:lt(e.widthTwips),pageHeight:lt(e.heightTwips),orientation:s,topMargin:lt(e.topTwips),rightMargin:lt(e.rightTwips),bottomMargin:lt(e.bottomTwips),leftMargin:lt(e.leftTwips),headerDistance:lt(e.headerTwips),footerDistance:lt(e.footerTwips),gutter:lt(e.gutterTwips)})}function No(n,e){if(!e)return null;let s=null,a=(i,u,c)=>{if(s!==null||i.kind==="textValue"||c>64)return;let g=i.kind==="paragraph"?i.id:u;if(i.id===e.id){s=g;return}for(let m of i.children)a(m,g,c+1);};return a(n.root,null,0),s}function gn(n,e,s){let a=chunkGWV65NQW_cjs.sc(e.root);return Object.freeze(a.map((i,u)=>{let c=s[u];return Object.freeze({index:u,markParagraphId:No(e,i),pageSetup:To(i),titlePage:c?.titlePage??false,evenAndOddHeaders:c?.evenAndOddHeaders??false})}))}function kn(n,e,s){if(s==="allMarkup")return hn(e);let a=Ho(n);if(a.length===0)return hn(e);let i=[],u=[],c=0,g=0;for(let m of a){if(c<m.start){let y=e.slice(c,m.start);i.push({projectedStart:g,projectedEnd:g+y.length,rawStart:c,rawEnd:m.start}),u.push(y),g+=y.length;}c=Math.max(c,m.end);}if(c<e.length){let m=e.slice(c);i.push({projectedStart:g,projectedEnd:g+m.length,rawStart:c,rawEnd:e.length}),u.push(m);}return An(u.join(""),i)}function hn(n){return An(n,n.length===0?[]:[{projectedStart:0,projectedEnd:n.length,rawStart:0,rawEnd:n.length}])}function An(n,e){return {text:n,projectedOffset(s){let a=0;for(let i of e)if(s<=i.rawStart||(a+=Math.max(0,Math.min(s,i.rawEnd)-i.rawStart),s<=i.rawEnd))return a;return a},rawRange(s,a){let i=e.find(c=>s>=c.projectedStart&&s<c.projectedEnd),u=e.find(c=>a>c.projectedStart&&a<=c.projectedEnd);return !i||!u||s>=a?null:{start:i.rawStart+s-i.projectedStart,end:u.rawStart+a-u.projectedStart}},sliceRaw(s,a){return s>=a?"":e.map(i=>{let u=Math.max(s,i.rawStart),c=Math.min(a,i.rawEnd);return u<c?n.slice(i.projectedStart+u-i.rawStart,i.projectedStart+c-i.rawStart):""}).join("")}}}function Ho(n){let e=chunkGWV65NQW_cjs.Fe(n),s=[],a=(u,c)=>{if(!(c>64||u.kind==="textValue")){if(u.kind==="revisionInsert"||u.kind==="revisionMoveTo"){let g=e.spanOf(u);g&&g.end>g.start&&s.push({start:g.start,end:g.end});return}for(let g of u.children)a(g,c+1);}};a(n,0),s.sort((u,c)=>u.start-c.start||c.end-u.end);let i=[];for(let u of s){let c=i[i.length-1];c&&u.start<=c.end?c.end=Math.max(c.end,u.end):i.push({...u});}return i}var ne="\r",jo=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),Mo=Object.freeze([]),Lo=Object.freeze([]),vn=Object.freeze([]),Eo=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>Lo,furniture:()=>vn,noteIds:()=>({ok:true,ids:xn}),styles:()=>jo});function Bo(n){return n.kind==="textValue"?Mo:Object.freeze(n.children.filter(e=>e.kind!=="textValue").map(e=>{let s=[];chunkGWV65NQW_cjs.If([e],s,0);let a=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",i=e.kind==="paragraph"&&chunkGWV65NQW_cjs.De(chunkGWV65NQW_cjs.Be(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:a,paragraphIds:Object.freeze(s.map(u=>u.id)),removable:a!=="other"&&!i})}))}function ee(n,e,s,a,i){let u=chunkGWV65NQW_cjs.Hf(a),c=Object.freeze(u.map(A=>A.id)),g=new Map,m=new Map;u.forEach((A,b)=>{g.set(A.id,b),m.set(A.id,A);});let y=new Map,v=A=>{if(!g.has(A))return null;let b=y.get(A);if(b!==void 0)return b;let C=chunkGWV65NQW_cjs.Xg(e,A)??"";return y.set(A,C),C},k=new Map,S=(A,b="allMarkup")=>{let C=m.get(A);if(!C||C.kind!=="paragraph")return null;let O=`${A}:${b}`,T=k.get(O);if(T)return T;let L=kn(C,v(A)??"",b);return k.set(O,L),L};return {story:n,part:e,root:a,scope:s,paragraphIds:c,blocks:Bo(a),has:A=>g.has(A),indexOf:A=>g.get(A)??-1,paragraph(A){let b=m.get(A);return b?{nodeId:A,paraId:chunkGWV65NQW_cjs.sb(b),text:v(A)??""}:null},node:A=>m.get(A)??null,paragraphText:(A,b)=>S(A,b)?.text??null,projectedText:S,text:A=>c.map(b=>S(b,A)?.text??"").join(ne),styles:i}}function bn(n){let e=n.parts.get(n.mainDocumentPart);if(!e)return Eo;let s,a=()=>s??=dn(n),i,u=()=>i??=chunkGWV65NQW_cjs.uc(n),c,g=new Map,m=new Map,y=b=>{let C=m.get(b);if(C)return C;let O=chunkGWV65NQW_cjs.Me(n,b);if(!O){let V={ok:true,ids:xn};return m.set(b,V),V}let T=[],L=new Set,F=new Set,J=0,X=false;for(let V of O.root.children){if(chunkGWV65NQW_cjs.Vd(V)!==b)continue;if(J+=1,V.kind!=="note"){X=true;continue}if(!chunkGWV65NQW_cjs.Yd(V))continue;let nt=chunkGWV65NQW_cjs.Wd(V);if(nt===null){X=true;continue}L.has(nt)?F.add(nt):(L.add(nt),T.push(nt));}let M=J>chunkGWV65NQW_cjs.de?{ok:false,reason:"truncated"}:X?{ok:false,reason:"malformed"}:F.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...F])}:{ok:true,ids:Object.freeze(T)};return m.set(b,M),M},v=b=>{let C=u()[b.sectionIndex];return C?(b.kind==="header"?C.headers:C.footers).get(b.variant)??null:null},k=b=>{if(b.kind==="body"){let O=chunkGWV65NQW_cjs.Gf(e);return O?ee(b,e,{kind:"body"},O,a):null}if(b.kind==="note"){let O=y(b.noteKind);if(!O.ok||!O.ids.includes(b.noteId))return null;let T=chunkGWV65NQW_cjs.Me(n,b.noteKind);if(!T)return null;let L=chunkGWV65NQW_cjs.ge(T.root,b.noteId);return !L||!chunkGWV65NQW_cjs.Yd(L)?null:ee(b,T,{kind:"notesPart",noteKind:b.noteKind},L,a)}let C=v(b);return C?ee(b,C.part,{kind:"headerFooter",rId:C.rId},C.part.root,a):null},S=b=>{let C=B(b);if(g.has(C))return g.get(C)??null;let O=k(b);return g.set(C,O),O};return {package:n,get body(){return S(ct)},story:S,storyOf:b=>{if(S(ct)?.has(b))return ct;for(let[O]of u().entries())for(let T of ["header","footer"])for(let L of Bt){let F={kind:T,sectionIndex:O,variant:L};if(S(F)?.has(b))return F}for(let O of ["footnote","endnote"]){let T=y(O);if(T.ok)for(let L of T.ids){let F={kind:"note",noteKind:O,noteId:L};if(S(F)?.has(b))return F}}return null},sections:()=>c??=gn(n,e,u()),furniture(b){let C=u()[b];if(!C)return vn;let O=[];for(let T of ["header","footer"]){let L=T==="header"?C.headers:C.footers;for(let F of Bt){let J=L.get(F);J&&O.push(Object.freeze({kind:T,variant:F,declared:!J.inherited}));}}return Object.freeze(O)},noteIds:y,styles:a}}var xn=Object.freeze([]);function rt(n,e){return {ok:false,code:n,detail:e}}function at(n){return {ok:true,value:n}}function K(n,e,s,a){let i=s.resolve(n,e);if(!i||i.kind!=="body"&&i.kind!=="paragraph")return rt("invalid-handle",`not-a-${e}-handle`);let u=a.story(i.story);return u?at(u):rt("invalid-handle",`no-such-story:${B(i.story)}`)}function Z(n,e,s){let a=e.resolve(n,"paragraph");if(!a||a.kind!=="paragraph")return rt("invalid-handle","not-a-paragraph-handle");let i=s.story(a.story);if(!i)return rt("invalid-handle",`no-such-story:${B(a.story)}`);let u=i.indexOf(a.paragraphId);return u<0?rt("invalid-handle","paragraph-not-in-body"):at({story:a.story,paragraphId:a.paragraphId,index:u,offset:0})}function Fo(n,e,s){let a=Z(n.paragraph,e,s);if(!a.ok)return a;let u=(s.story(a.value.story)?.paragraphText(a.value.paragraphId)??"").length,{offset:c}=n;return !Number.isInteger(c)||c<0||c>u?rt("invalid-offset",`offset ${String(c)} outside 0..${String(u)}`):at({...a.value,offset:c})}function kt(n,e,s){if("paragraph"in n){if(!("at"in n))return Fo(n,e,s);let g=Z(n.paragraph,e,s);if(!g.ok||n.at==="start")return g;let y=(s.story(g.value.story)?.paragraphText(g.value.paragraphId)??"").length;return at({...g.value,offset:y})}let a=K(n.body,"body",e,s);if(!a.ok)return a;let i=a.value.paragraphIds;if(i.length===0)return rt("invalid-offset","empty-story");if(n.at==="start")return at({story:a.value.story,paragraphId:i[0],index:0,offset:0});let u=i.length-1,c=i[u];return at({story:a.value.story,paragraphId:c,index:u,offset:(a.value.paragraphText(c)??"").length})}function _o(n,e){return n.index<e.index||n.index===e.index&&n.offset<=e.offset}function Do(n){let e=n.paragraphIds;if(e.length===0)return null;let s=e.length-1,a=e[s];return {start:{story:n.story,paragraphId:e[0],index:0,offset:0},end:{story:n.story,paragraphId:a,index:s,offset:(n.paragraphText(a)??"").length}}}function W(n,e,s){if("body"in n){let u=K(n.body,"body",e,s);return u.ok?at(Do(u.value)):u}if("paragraph"in n){let u=Z(n.paragraph,e,s);if(!u.ok)return u;let g=(s.story(u.value.story)?.paragraphText(u.value.paragraphId)??"").length;return at({start:u.value,end:{...u.value,offset:g}})}let a=kt(n.start,e,s);if(!a.ok)return a;let i=kt(n.end,e,s);return i.ok?B(a.value.story)!==B(i.value.story)?rt("invalid-handle","span-crosses-stories"):_o(a.value,i.value)?at({start:a.value,end:i.value}):rt("invalid-offset","span-start-after-end"):i}function q(n,e,s){if("body"in n)return K(n.body,"body",e,s);if("paragraph"in n)return K(n.paragraph,"paragraph",e,s);let a=n.start;return "paragraph"in a?K(a.paragraph,"paragraph",e,s):K(a.body,"body",e,s)}function Wt(n,e,s){if("paragraph"in n)return Z(n.paragraph,e,s);let a=K(n.body,"body",e,s);if(!a.ok)return a;let i=a.value.paragraphIds;if(i.length===0)return rt("invalid-offset","empty-story");let u=n.at==="first"?0:i.length-1;return at({story:a.value.story,paragraphId:i[u],index:u,offset:0})}function tt(n,e){return n?e.paragraphIds.slice(n.start.index,n.end.index+1):[]}function oe(n,e){if(!n)return [];let s=tt(n,e),a=s.length-1;return s.map((i,u)=>{let c=(e.paragraphText(i)??"").length,g=u===0?n.start.offset:0,m=u===a?n.end.offset:c;return {paragraphId:i,start:g,end:m,whole:g===0&&m===c}})}function In(n,e,s,a="allMarkup"){if(!n)return "";let i=tt(n,e);return i.length===1?e.projectedText(n.start.paragraphId,a)?.sliceRaw(n.start.offset,n.end.offset)??"":i.map((u,c)=>{let g=e.projectedText(u,a);if(!g)return "";let m=(e.paragraphText(u)??"").length;return c===0?g.sliceRaw(n.start.offset,m):c===i.length-1?g.sliceRaw(0,n.end.offset):g.text}).join(s)}function re(n,e){return {start:{paragraph:e.paragraph(n.start.paragraphId,n.start.story),offset:n.start.offset},end:{paragraph:e.paragraph(n.end.paragraphId,n.end.story),offset:n.end.offset}}}var Wo=256,Sn=1e4;function ae(n,e){if(n.kind!=="textValue"){for(let s of n.attributes)if(s.namespaceUri===chunkGWV65NQW_cjs.ca&&s.localName===e)return s.value}}function zo(n){return n.startsWith("_")}function se(n){let e=new Map,s=[],a=new Set;for(let i of n.paragraphIds){let u=n.node(i);if(u?.kind!=="paragraph")continue;let c=chunkGWV65NQW_cjs.Fe(u),g=m=>{if(m.kind!=="textValue"){if(m.kind==="bookmarkStart"){if(s.length>=Sn||e.size>=Sn)return;let y=ae(m,"id"),v=ae(m,"name");if(y===void 0||v===void 0||v.length===0||v.length>Wo||zo(v)||a.has(v)||e.has(y))return;let k=c.spanOf(m)?.start??0;e.set(y,{name:v,start:{paragraphId:i,offset:k}});return}if(m.kind==="bookmarkEnd"){let y=ae(m,"id");if(y===void 0)return;let v=e.get(y);if(!v)return;e.delete(y),a.add(v.name);let k=c.spanOf(m)?.start??0;s.push(Object.freeze({name:v.name,start:v.start,end:{paragraphId:i,offset:k}}));return}for(let y of m.children)g(y);}};for(let m of u.children)g(m);}return Object.freeze(s)}function ie(n,e){return se(n).find(s=>s.name===e)??null}function Rn(n,e){let s=n.node(e);if(s?.kind!=="paragraph")return Object.freeze([]);let a=chunkGWV65NQW_cjs.Fe(s),i=[],u=(c,g)=>{if(!(c.kind==="textValue"||g>32)){if(chunkGWV65NQW_cjs.Pa(c)){let m=a.spanOf(c);m&&i.push(Object.freeze({id:c.id,paragraphId:e,start:m.start,end:m.end}));return}for(let m of c.children)u(m,g+1);}};for(let c of s.children)u(c,0);return Object.freeze(i)}function Cn(n,e,s){let a=chunkGWV65NQW_cjs.Sa(s,i=>chunkGWV65NQW_cjs.Cd(n,e,i));if(a.kind==="external")return a.href;if(a.kind==="internal"){let i=chunkGWV65NQW_cjs.Qa(s);return i===void 0||i.length===0?null:`#${i}`}return null}var At=8;function Pn(n){if(!n||n.kind==="textValue")return null;for(let e of n.attributes)if(e.namespaceUri===chunkGWV65NQW_cjs.ca&&e.localName==="val")return e.value;return null}function On(n){let e=chunkGWV65NQW_cjs.De(chunkGWV65NQW_cjs.Be(n),"numPr");if(!e)return null;let s=Pn(chunkGWV65NQW_cjs.De(e,"numId"));if(s===null||!/^\d{1,10}$/.test(s)||s==="0")return null;let a=Pn(chunkGWV65NQW_cjs.De(e,"ilvl")),i=a===null?0:Number(a);return !Number.isInteger(i)||i<0||i>At?null:{numId:s,level:i}}function zt(n){let e=new Map;for(let s of n.paragraphIds){let a=n.node(s);if(!a)continue;let i=On(a);if(!i)continue;let u=e.get(i.numId);u?u.push(s):e.set(i.numId,[s]);}return Object.freeze([...e].map(([s,a])=>Object.freeze({numId:s,paragraphIds:Object.freeze(a)})))}function Ct(n,e){let s=n.node(e);return s?On(s):null}function wn(n,e,s,a,i){let u=Math.min(i?.limit??2e3,2e3),c=[],g=tt(e,n),m=g.length-1;for(let[y,v]of g.entries()){if(u<=0)break;let k=n.projectedText(v,i?.projection??"allMarkup");if(!k)continue;let S=chunk76Y3Y45J_cjs.oa(k.text,a,u,{matchCase:i?.matchCase===true,wholeWord:i?.matchWholeWord===true,...y===0&&e?{from:k.projectedOffset(e.start.offset)}:{},...y===m&&e?{to:k.projectedOffset(e.end.offset)}:{}});for(let A of S.matches){let b=k.rawRange(A.start,A.start+A.length);if(!b)return {ok:false,paragraphId:v};if(y===0&&e&&b.start<e.start.offset||y===m&&e&&b.end>e.end.offset)continue;let C=s.paragraph(v,n.story);c.push({start:{paragraph:C,offset:b.start},end:{paragraph:C,offset:b.end}}),u-=1;}}return {ok:true,spans:c}}var Ko={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Vo(n){return n.kind==="note"}function $o(n,e){return e.length===0?!Vo(n.story):e.every(s=>n.has(s.start.paragraphId))}function Uo(n){return Object.freeze(chunk76Y3Y45J_cjs.da(n.part).filter(e=>$o(n,e.ranges)))}function de(n){let e=[];for(let s of Uo(n)){if(s.readOnly||s.revisionKind==="structural")continue;let a=Ko[s.revisionKind];a!==void 0&&e.push(Object.freeze({id:s.id,type:a,author:s.author,date:s.date??"",item:s}));}return Object.freeze(e)}function Xo(n,e){let s=n;for(let a=0;s!==void 0&&a<=64;a+=1){if(s.parentId===void 0)return s.range!==null;s=e.get(s.parentId);}return false}var Yo=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function Tn(n,e){let s=n.parts.get(chunk76Y3Y45J_cjs.o(n,e.part.name));if(!s)return Yo;let a=n.parts.get(chunk76Y3Y45J_cjs.p(n,e.part.name)),i=chunkGWV65NQW_cjs.Mf(s),u=a?chunkGWV65NQW_cjs.Nf(a):new Map,c=chunkGWV65NQW_cjs.Lf(e.part).filter(k=>e.has(k.start.paragraphId)),g=chunk76Y3Y45J_cjs.ea(i,c,u),m=new Map(g.map(k=>[k.id,k])),y=g.filter(k=>Xo(k,m)),v=new Map(y.map(k=>[k.id,k]));return Object.freeze({items:Object.freeze(y),roots:Object.freeze(y.filter(k=>k.parentId===void 0)),byId:k=>v.get(k)??null,textOf:k=>{let S=v.get(k);return S?chunk76Y3Y45J_cjs.ba(S.comment):""}})}function Nn(n,e,s){if("body"in n){let a=K(n.body,"body",e,s);return a.ok?{ok:true,reads:a.value}:{ok:false,code:a.code,message:"that handle does not name a body",detail:a.detail}}return e.resolve(n.document,"document")?s.body?{ok:true,reads:s.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 Hn(n,e){let s=n.op==="acceptAllRevisions",a=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [s?{op:"acceptAllRevisions",...a}:{op:"rejectAllRevisions",...a}]}var Go=/[\r\n\u2028\u2029]/u,Mn=Object.freeze({kind:"applied"});function vt(n,e,s){return {ok:false,error:Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}}function le(n,e){return vt("unsupported-content",n==="author"?"a comment records who wrote it":n==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",n)}function ue(n){return chunk76Y3Y45J_cjs.g(n.author)?le("author",n.kind):chunk76Y3Y45J_cjs.h(n.text)?le("text",n.kind):typeof n.text=="string"&&Go.test(n.text)?vt("unsupported-content",n.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):chunk76Y3Y45J_cjs.j(n.date)?le("date",n.kind):null}function ce(n){if(n===void 0)return;let e=chunk76Y3Y45J_cjs.i(n);return e.ok?e.value:void 0}function jn(n,e){let s=chunkGWV65NQW_cjs.Ca(n.part,e);for(;s;){if(s.kind==="tableCell"||s.kind!=="textValue"&&s.namespaceUri===chunkGWV65NQW_cjs.ca&&s.localName==="tc")return s.id;s=chunkGWV65NQW_cjs.Da(n.part,s.id);}return null}function Ln(n,e,s,a){let i=ue({author:n.author,text:n.text,date:n.date,kind:"comment"});if(i)return i;let u=W(n.span,e,s);if(!u.ok)return vt(u.code,"that span is not a place",u.detail);if(u.value===null)return vt("invalid-handle","an empty story has no comment anchor");let c=q(n.span,e,s);if(!c.ok)return vt(c.code,"that span is not a place",c.detail);let g=u.value;if(jn(c.value,g.start.paragraphId)!==jn(c.value,g.end.paragraphId))return vt("unsupported-content","a comment range cannot cross a table-cell boundary");let m=a(c.value);if(m)return m;let y=ce(n.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:g.start.paragraphId,start:g.start.offset,end:g.end.offset,...g.end.paragraphId===g.start.paragraphId?{}:{endParagraphId:g.end.paragraphId}},text:n.text,author:n.author,...y===void 0?{}:{date:y}},story:c.value.story,answer:(k,S)=>S===void 0?Mn:{kind:"handle",handle:e.comment(S,c.value.story)}}}function En(n,e,s){let a=s(e);if(a)return a;let i=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:n.id,...n.parentId===void 0?{}:{parentCommentId:n.parentId},...i.kind==="note"?{noteId:i.noteId}:{}},story:i,answer:()=>Mn}}var Jo=1e4;function Bn(n,e){let s=[],a=e.kind==="contentControl"?chunkGWV65NQW_cjs.qf(e):e;if(!a)return s;for(let i of chunkGWV65NQW_cjs.uf(a))if(!(i.ancestors.length>0)){if(s.length>=Jo)break;s.push(Wn(n,i.node));}return s}function Fn(n,e){for(let s of chunkGWV65NQW_cjs.uf(n.root))if(s.node.id===e)return Wn(n,s.node);return null}function _n(n,e){for(let s of chunkGWV65NQW_cjs.uf(n.root))if(s.node.id===e)return s.node;return null}function Kt(n,e){let s=zn(e);if(s.length>0){let a=s[0],i=s[s.length-1],u=n.paragraphText(i);return u===null||!n.has(a)?null:{start:{paragraphId:a,offset:0},end:{paragraphId:i,offset:u.length}}}for(let a of n.paragraphIds){let i=n.node(a);if(!i||i.kind!=="paragraph"||!i.children.some(c=>c.id===e.id))continue;let u=chunkGWV65NQW_cjs.Fe(i).spanOf(e);return u?{start:{paragraphId:a,offset:u.start},end:{paragraphId:a,offset:u.end}}:null}return null}function Dn(n,e,s="allMarkup"){if(s==="allMarkup")return chunkGWV65NQW_cjs.wf(e);let a=Kt(n,e);if(!a)return "";let i=n.indexOf(a.start.paragraphId),u=n.indexOf(a.end.paragraphId);if(i<0||u<i)return "";let c=[];for(let g=i;g<=u;g+=1){let m=n.paragraphIds[g],y=n.projectedText(m,s),v=n.paragraphText(m);if(!y||v===null)return "";c.push(y.sliceRaw(g===i?a.start.offset:0,g===u?a.end.offset:v.length));}return c.join("\r")}function Wn(n,e){return {nodeId:e.id,properties:chunkGWV65NQW_cjs.sf(e),lock:chunkGWV65NQW_cjs.wg(n.part,e.id),paragraphIds:zn(e)}}function zn(n){let e=chunkGWV65NQW_cjs.qf(n);if(!e)return [];let s=[];return chunkGWV65NQW_cjs.If(e.children,s,0),s.map(a=>a.id)}var Qo=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Zo=4096,Kn=64;function Vn(n){if(n===void 0)return {ok:true,value:null};if(typeof n!="object"||n===null)return {ok:false,field:"payload"};let e=n;for(let s of ["namespaceUri","rootLocalName","nodeId"]){let a=e[s];if(typeof a!="string"||a.length===0||a.length>Zo)return {ok:false,field:s}}return typeof e.label!="string"||e.label.length>chunk76Y3Y45J_cjs.u?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>chunk76Y3Y45J_cjs.t?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function $n(n){let e=n.at!==void 0,s=n.span!==void 0;return e===s?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof n.tag!="string"||n.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:n.tag.length>Kn?{message:`w:tag caps at ${String(Kn)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof n.text!="string"||n.text.length===0?{message:"a custom node shows some text",detail:"text"}:n.lock!==void 0&&!Qo.has(n.lock)?{message:"that is not a lock",detail:String(n.lock)}:null}function Un(n,e,s,a){return {paragraphId:e.paragraphId,offset:e.offset,...s.offset>e.offset?{replaceUntil:s.offset}:{},tag:n.tag,text:n.text,...n.title===void 0?{}:{alias:n.title},...n.lock===void 0||n.lock==="unlocked"?{}:{lock:n.lock},...a===null?{}:{payload:a}}}function Xn(n,e,s){if(n.span){let i=W(n.span,e,s);return i.ok?i.value?i.value.start.paragraphId!==i.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:i.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:i.code,message:"that span is not a place",detail:i.detail}}let a=kt(n.at,e,s);return a.ok?{range:{start:a.value,end:a.value}}:{code:a.code,message:"that is not a place",detail:a.detail}}var Pt=/[\r\n\v\f\u2028\u2029]/,qo=16,tr=64,Yn=/\s/;function er(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function l(n,e,s){return {ok:false,error:er(n,e,s)}}var E=Object.freeze({kind:"applied"});function I(n){return {ok:true,kind:"query",value:n}}function Gn(n){let e=n.kind==="contentControl"?chunkGWV65NQW_cjs.qf(n):n;return e?chunkGWV65NQW_cjs.uf(e).map(s=>s.node):[]}var nr=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),or=new Set(["whole","content","start","end","before","after"]),rr=new Set(["richText","plainText","dropDownList","comboBox","date"]),ar=4096;function sr(n){let e=(i,u)=>({ok:false,code:"unsupported-content",message:i,detail:u});if(typeof n!="object"||n===null||!("kind"in n))return e("a control value states its kind","value");let s=n,a=s.kind;if(a==="text"||a==="listItem"){let i=a==="text"?s.text:s.value;return typeof i!="string"?e("that value is not a string",String(a)):i.length>ar?e("that value is too long",String(i.length)):{ok:true,value:a==="text"?{kind:"text",text:i}:{kind:"listItem",value:i}}}if(a==="checkbox"){let i=s.checked;return typeof i!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:i}}}if(a==="date"){let i=s.iso;return typeof i!="string"?e("a date is an ISO-8601 string","iso"):i.length>64?e("that is not a date",String(i.length)):{ok:true,value:{kind:"date",iso:i}}}return e("that is not a value any control accepts",String(a))}function ir(n,e){let s=[],a=0;for(;a<n.length;){let i=null;for(let u of e){let c=n.indexOf(u,a);c<0||(!i||c<i.start||c===i.start&&u.length>i.length)&&(i={start:c,length:u.length});}if(!i)break;s.push(i),a=i.start+i.length;}return s}function dr(n,e,s){let a=e[s]?.markParagraphId??null;if(a!==null)return a;let i=n.paragraphIds,u=i[i.length-1];return u===void 0||new Set(e.map(g=>g.markParagraphId).filter(g=>g!==null)).has(u)?null:u}function lr(n,e){for(let s of [n.start,n.end]){let a=e.paragraphText(s.paragraphId);if(a===null||s.offset>a.length)return false}return true}function ur(n,e,s){let a=e,i=s;for(;a<i&&Yn.test(n[a]);)a+=1;for(;i>a&&Yn.test(n[i-1]);)i-=1;return [a,i]}function Jn(n){let{handles:e,capabilities:s}=n,a=n.reads,i=new Map,u=o=>{let t=B(o.story),r=i.get(t);if(r)return r;let d=new Map,p=o.paragraphIds.map(h=>{let x={id:h};return d.set(h,x),x}),f={reads:o,order:p,slotById:d,created:[],restructured:new Set,touched:new Set,formatted:new Set,selected:new Set,retargets:[]};return i.set(t,f),f},c=[],g=fn(),m=null,y=o=>m===null?(m=o,null):m===o?null:l("conflicting-operations","one batch writes into one story",`${B(m.reads.story)} then ${B(o.reads.story)}`),v=o=>y(u(o)),k=o=>{let t=a.package;return t===null?null:Tn(t,o)},S=o=>{let t=e.resolve(o,"comment");if(!t||t.kind!=="comment")return {ok:false,planned:l("invalid-handle","that handle does not name a comment","comment")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let p=k(r)?.byId(t.commentId)??null;return p?{ok:true,reads:r,item:p}:{ok:false,planned:l("invalid-handle","this document no longer holds that comment",t.commentId)}},A=o=>{let t=e.resolve(o,"revision");if(!t||t.kind!=="revision")return {ok:false,planned:l("invalid-handle","that handle does not name a tracked change","revision")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let d=de(r).find(p=>p.id===t.revisionId)??null;return d?{ok:true,reads:r,item:d}:{ok:false,planned:l("invalid-handle","this document no longer holds that tracked change",t.revisionId)}},b=(o,t)=>{let r=o.paragraphText(t.start.paragraphId),d=o.paragraphText(t.end.paragraphId);if(r===null||d===null)return null;let p={story:o.story,paragraphId:t.start.paragraphId,index:o.indexOf(t.start.paragraphId),offset:Math.min(t.start.offset,r.length)},f={story:o.story,paragraphId:t.end.paragraphId,index:o.indexOf(t.end.paragraphId),offset:Math.min(t.end.offset,d.length)};return X({start:p,end:f})},C=(o,t)=>o.order.indexOf(t),O=(o,t)=>o.selected.has(t)?l("conflicting-operations","this batch selects a paragraph it also edits",t):null,T=(o,t)=>{let r=O(o,t);return r||(o.restructured.has(t)||o.touched.has(t)?l("conflicting-operations","another operation in this batch already changes that paragraph",t):(o.restructured.add(t),o.touched.add(t),null))},L=(o,t)=>{let r=O(o,t);return r||(o.restructured.has(t)?l("conflicting-operations","another operation in this batch restructures that paragraph",t):(o.touched.add(t),null))},F=(o,t,r)=>{let d=`${r}:${t}`;if(o.formatted.has(d))return l("conflicting-operations","another operation in this batch already writes that formatting",t);let p=L(o,t);return p||(o.formatted.add(d),null)},J=(o,t)=>{let r={id:null};return o.order.splice(t,0,r),o.created.push(r),r},X=o=>re(o,e),M=o=>o===null?null:a.story(o.start.story),V=o=>o===void 0||o==="allMarkup"||o==="original",nt=(o,t,r,d)=>{if(!V(d?.projection))return l("unsupported-content","unknown text projection","projection");if(d?.matchWildcards===true)return l("unsupported-capability","wildcard search is not implemented","matchWildcards");if(d?.ignorePunct===true)return l("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(d?.ignoreSpace===true)return l("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!chunk76Y3Y45J_cjs.na(r))return l("unsupported-content","that is not a query this host will scan for","text");let p=d?.limit;if(p!==void 0&&(!Number.isInteger(p)||p<0))return l("invalid-offset","limit must be a non-negative integer",String(p));let f=wn(o,t,e,r,d);return f.ok?I({kind:"spans",spans:f.spans}):l("invalid-offset","projection mapping failed",f.paragraphId)},bt=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","insertText needs text","text");if(Pt.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=y(o);if(d)return d;let p=L(o,t.paragraphId);if(p)return p;let f=r.length===0?[]:[{op:"insertText",paragraphId:t.paragraphId,offset:t.offset,text:r}],h=()=>({kind:"span",span:X({start:t,end:{...t,offset:t.offset+r.length}})});return {ok:true,kind:"command",ops:f,story:o.reads.story,answer:h}},Ot=(o,t,r)=>{let d=o.reads;if(typeof r!="string")return l("unsupported-content","replaceSpan needs text","text");if(Pt.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let p=tt(t,d),f=t.start.paragraphId,h=[],x=y(o);if(x)return x;if(p.length===1){let j=L(o,f);if(j)return j;t.end.offset>t.start.offset&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:t.end.offset});}else {for(let w of p){let P=T(o,w);if(P)return P}let j=t.end.paragraphId,D=(d.paragraphText(f)??"").length;t.start.offset<D&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:D}),t.end.offset>0&&h.push({op:"deleteText",paragraphId:j,start:0,end:t.end.offset});for(let w of p.slice(1,-1))h.push({op:"deleteBlock",blockId:w});h.push({op:"joinParagraphs",firstId:f,secondId:j});for(let w of p.slice(1)){let P=o.slotById.get(w);P&&o.order.splice(C(o,P),1);}}r.length>0&&h.push({op:"insertText",paragraphId:f,offset:t.start.offset,text:r});let R={...t.start,paragraphId:f},H=()=>({kind:"span",span:X({start:R,end:{...R,offset:R.offset+r.length}})});return {ok:true,kind:"command",ops:h,story:o.reads.story,answer:H}},pe=(o,t)=>{let r=o.reads;if(typeof t!="string")return l("unsupported-content","replaceSpan needs text","text");if(Pt.test(t))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=r.blocks,p=d.filter(P=>P.removable),f=d.filter(P=>!P.removable).flatMap(P=>P.paragraphIds),h=f.length===0?p.find(P=>P.kind==="paragraph"):void 0;if(!h&&f.length===0)return l("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let x=y(o);if(x)return x;for(let P of r.paragraphIds){let Q=T(o,P);if(Q)return Q}let R=[],H=(h?[h.id]:[...f]).sort((P,Q)=>r.indexOf(P)-r.indexOf(Q)),j=H[0];for(let P of H){let Q=(r.paragraphText(P)??"").length;Q>0&&R.push({op:"deleteText",paragraphId:P,start:0,end:Q});}for(let P of p)P.id!==h?.id&&R.push({op:"deleteBlock",blockId:P.id});t.length>0&&R.push({op:"insertText",paragraphId:j,offset:0,text:t});for(let P of p)if(P.id!==h?.id)for(let Q of P.paragraphIds){let wt=o.slotById.get(Q);wt&&o.order.splice(C(o,wt),1);}let D={story:r.story,paragraphId:j,index:r.indexOf(j),offset:0},w=()=>({kind:"span",span:X({start:D,end:{...D,offset:t.length}})});return {ok:true,kind:"command",ops:R,story:r.story,answer:w}},N=(o,t)=>{if(!Array.isArray(t)||t.length<1||t.length>1e4||t.some(d=>typeof d!="string"||Pt.test(d)||!chunkGWV65NQW_cjs.O(d)))return l("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let r=y(o);if(r)return r;for(let d of o.reads.paragraphIds){let p=T(o,d);if(p)return p}o.order.splice(0,o.order.length);for(let d=0;d<t.length;d+=1)J(o,d);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:o.reads.root.id,paragraphs:t}],story:o.reads.story,answer:()=>E}},z=(o,t,r,d)=>{let p=o.reads;if(typeof d!="string")return l("unsupported-content","insertParagraph needs text","text");if(Pt.test(d))return l("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let f=y(o);if(f)return f;let h=T(o,t.paragraphId);if(h)return h;let x=o.slotById.get(t.paragraphId);if(!x)return l("invalid-handle","that paragraph is not in the body");let R=(p.paragraphText(t.paragraphId)??"").length,H=[];r==="after"?(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:R,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:R})):(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:0,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:d.length}));let j=J(o,C(o,x)+1);r==="before"&&o.retargets.push({from:t.paragraphId,slot:j});let D=()=>{let w=r==="after"?j.id:t.paragraphId;return w===null?E:{kind:"handle",handle:e.paragraph(w,p.story)}};return {ok:true,kind:"command",ops:H,story:p.story,answer:D}},st=(o,t,r,d,p)=>{let f=o.reads;if(!Array.isArray(r)||r.length===0)return l("unsupported-content","split needs at least one delimiter","delimiters");if(r.length>qo)return l("unsupported-content","too many delimiters",String(r.length));for(let $ of r){if(typeof $!="string"||$.length===0)return l("unsupported-content","a delimiter must be a non-empty string","delimiters");if($.length>tr)return l("unsupported-content","that delimiter is too long","delimiters")}let h=y(o);if(h)return h;let x=T(o,t.paragraphId);if(x)return x;let R=o.slotById.get(t.paragraphId);if(!R)return l("invalid-handle","that paragraph is not in the body");let H=f.paragraphText(t.paragraphId)??"",j=ir(H,r),D=[],w=[],P=[];if(j.length===0)P.push(H);else if(d){for(let U of [...j].reverse())D.push({op:"deleteText",paragraphId:t.paragraphId,start:U.start,end:U.start+U.length});let $=0,ut=0;for(let U of j){let Ut=U.start-$;w.push(Ut),P.push(H.slice(ut,U.start)),ut=U.start+U.length,$+=U.length;}P.push(H.slice(ut));}else {let $=0;for(let ut of j){let U=ut.start+ut.length;w.push(U),P.push(H.slice($,U)),$=U;}P.push(H.slice($));}w.length>0&&D.push({op:"splitParagraphMany",paragraphId:t.paragraphId,offsets:w});let Q=[R];for(let $=0;$<w.length;$+=1)Q.push(J(o,C(o,R)+1+$));let wt=$=>{let ut=$.story(f.story),U=[];return Q.forEach((Ut,ao)=>{let Xt=Ut.id;if(Xt===null)return;let Yt=ut?.paragraphText(Xt)??P[ao]??"",[so,io]=p?ur(Yt,0,Yt.length):[0,Yt.length],ge=e.paragraph(Xt,f.story);U.push({start:{paragraph:ge,offset:so},end:{paragraph:ge,offset:io}});}),{kind:"spans",spans:U}};return {ok:true,kind:"command",ops:D,story:f.story,answer:wt}},xt=(o,t)=>{let r=y(o);if(r)return r;let d=T(o,t.paragraphId);if(d)return d;let p=o.slotById.get(t.paragraphId);return p&&o.order.splice(C(o,p),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:t.paragraphId}],story:o.reads.story,answer:()=>E}},pt=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=pn(r??{});if(!h.ok)return l("unsupported-content","that is not formatting this host writes",h.detail);let x=[];for(let R of oe(t,d)){if(R.end<=R.start&&!R.whole)continue;let H=F(o,R.paragraphId,"runs");if(H)return H;for(let j of chunk76Y3Y45J_cjs.S(p,R.paragraphId,R.start,R.end,h.value,n.displayMode))x.push({op:"setRunProperties",paragraphId:R.paragraphId,start:j.start,end:j.end,properties:j.properties,...j.targetRunIds?{targetRunIds:j.targetRunIds}:{}});R.whole&&x.push({op:"setParagraphMarkProperties",paragraphId:R.paragraphId,properties:chunk76Y3Y45J_cjs.R(p,R.paragraphId,h.value)});}return x.length===0?l("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:x,story:d.story,answer:()=>E}},Qn=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=_t(r,d.styles());if(!h.ok)return l("unsupported-content","that is not a style this document has",h.detail);let x={localName:"pStyle",attributes:{val:h.styleId}},R=[];for(let H of tt(t,d)){let j=F(o,H,"paragraph");if(j)return j;R.push({op:"setParagraphProperties",paragraphId:H,properties:chunk76Y3Y45J_cjs.M(chunk76Y3Y45J_cjs.K(p,H),x)});}return R.length===0?l("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:R,story:d.story,answer:()=>E}},Zn=(o,t,r)=>{let d=o.reads,p=d.part,f=y(o);if(f)return f;let h=mn(p,t.paragraphId,r??{},d.styles());if(!h.ok)return l("unsupported-content","that is not paragraph formatting this host writes",h.detail);let x=F(o,t.paragraphId,"paragraph");return x||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:t.paragraphId,properties:h.value}],story:d.story,answer:()=>E}},qn=(o,t)=>{let r=a.body;if(!r)return l("document-unavailable","this host holds no document right now");let d=a.sections();if(!d[o])return l("invalid-handle","that section is not in this document");let f=yn(t);if(!f.ok)return l("unsupported-content",f.reason,f.detail);let h=dr(r,d,o);if(h===null)return l("unsupported-content","that section holds no paragraph to address it by","no-anchor");let x=u(r),R=y(x);return R||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...f.value,anchorParagraphId:h}],story:ct,answer:()=>E}},to=(o,t)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:o,noteId:t}],story:ct,lifecycle:true,answer:()=>E}),Vt=o=>{let t=e.resolve(o,"list");if(!t||t.kind!=="list")return l("invalid-handle","that handle does not name a list","list");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=zt(r).find(p=>p.numId===t.numId);return d?{ok:true,plan:u(r),list:d}:l("invalid-handle","this story numbers nothing with that list",t.numId)},$t=o=>{if(typeof o!="object"||o===null)return l("invalid-handle","that is not a scope a control lives in","scope");let t=o;if("body"in o){let r=K(t.body,"body",e,a);return r.ok?{reads:r.value,node:r.value.root}:l(r.code,"that handle does not name a body",r.detail)}if("contentControl"in o){let r=ot(t.contentControl);return "control"in r?{reads:r.reads,node:r.node}:r}return l("invalid-handle","that is not a scope a control lives in","scope")},ot=o=>{let t=e.resolve(o,"contentControl");if(!t||t.kind!=="contentControl")return l("invalid-handle","that handle does not name a content control","contentControl");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Fn(r,t.nodeId),p=_n(r,t.nodeId);return !d||!p?l("invalid-handle","this document no longer holds that content control"):{reads:r,control:d,node:p}},eo=(o,t,r)=>{if(!Number.isInteger(r)||r<0||r>At)return l("invalid-offset",`a list level is 0 to ${String(At)}`,String(r));if(!Ct(o.reads,t))return l("unsupported-content","that paragraph is not in a list",t);let d=y(o);if(d)return d;let p=F(o,t,"paragraph");return p||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:t,level:r}],story:o.reads.story,answer:()=>E}},no=(o,t,r,d)=>{if(r!=="start"&&r!=="end")return l("unknown-operation","a list takes an item at its start or its end",String(r));let p=o.reads,f=r==="start"?t.paragraphIds[0]:t.paragraphIds[t.paragraphIds.length-1];if(f===void 0)return l("invalid-handle","that list holds no paragraph");let h={story:p.story,paragraphId:f,index:p.indexOf(f)};return z(o,h,r==="start"?"before":"after",d)},me=(o,t)=>{if(t.start.paragraphId!==t.end.paragraphId)return null;for(let r of Rn(o,t.start.paragraphId))if(r.start<=t.start.offset&&r.end>=t.end.offset)return r;return null},oo=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","a hyperlink target is a string","target");let d=o.reads,p=me(d,t),f=t.start.paragraphId===t.end.paragraphId&&t.start.offset===t.end.offset;if(r.length===0){if(!p)return l("unsupported-content","that text is not a link","no-link");let w=y(o);if(w)return w;let P=L(o,p.paragraphId);return P||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:p.id}],story:d.story,answer:()=>E}}let h={},x=null;if(r.startsWith("#")){let w=r.slice(1);if(w.length===0||!ie(d,w))return l("unsupported-content","this document declares no such bookmark",r);h={anchor:w};}else {if(chunkGWV65NQW_cjs.Ad(r)===null)return l("unsupported-content","this engine will not author that target","target");x=r;}let R=y(o);if(R)return R;let H=w=>x===null?{ok:true,kind:"command",ops:[w(h)],story:d.story,answer:()=>E}:{ok:true,kind:"command",ops:[],relate:{url:x,ops:P=>[w({relationshipId:P})]},story:d.story,answer:()=>E};if(p){let w=L(o,p.paragraphId);return w||H(P=>({op:"setHyperlinkTarget",linkId:p.id,...P}))}if(f)return l("unsupported-content","a link with no text has nothing to click","collapsed");if(t.start.paragraphId!==t.end.paragraphId)return l("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let j=L(o,t.start.paragraphId);if(j)return j;let D=d.styles().idOf("hyperlink");return H(w=>({op:"insertHyperlink",paragraphId:t.start.paragraphId,start:t.start.offset,end:t.end.offset,...w,...D===null?{}:{styleId:D}}))},fe=(o,t,r)=>{let d=o.reads;if(!s.selection||!n.select)return l("unsupported-capability","this host has no reader to move","selection");if(r!=="select"&&r!=="start"&&r!=="end")return l("unknown-operation","that is not a selection mode",String(r));let p=tt(t,d);for(let f of p)if(o.touched.has(f))return l("conflicting-operations","this batch edits a paragraph the selection covers",f);for(let f of p)o.selected.add(f);return c.push({range:t,mode:r}),{ok:true,kind:"command",ops:[],story:d.story,answer:()=>E}},ye=o=>{let t=e.resolve(o,"bookmark");if(!t||t.kind!=="bookmark")return l("invalid-handle","that handle does not name a bookmark","bookmark");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=ie(r,t.name);if(!d)return l("invalid-handle","this document no longer declares that bookmark",t.name);let p=f=>({story:r.story,paragraphId:f.paragraphId,index:r.indexOf(f.paragraphId),offset:f.offset});return {reads:r,range:{start:p(d.start),end:p(d.end)}}},ro=o=>{switch(o.op){case "getDocument":return I({kind:"handle",handle:e.document()});case "getBody":return e.resolve(o.document,"document")?a.body?I({kind:"handle",handle:e.body(ct)}):l("document-unavailable","this host holds no document right now"):l("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:t.value.paragraphIds.map(r=>e.paragraph(r,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getSpanParagraphs":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"handles",handles:tt(t.value,r.value).map(d=>e.paragraph(d,r.value.story))}):l(r.code,"that span is not a place",r.detail)}case "getText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");if(e.resolve(o.target,"body")){let p=K(o.target,"body",e,a);return p.ok?I({kind:"text",text:p.value.text(o.projection??"allMarkup")}):l(p.code,"that handle does not name a body",p.detail)}let r=Z(o.target,e,a);if(!r.ok)return l(r.code,"that handle does not name a body or a paragraph",r.detail);let d=a.story(r.value.story);return I({kind:"text",text:d?.paragraphText(r.value.paragraphId,o.projection??"allMarkup")??""})}case "getSpanText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"text",text:In(t.value,r.value,ne,o.projection??"allMarkup")}):l(r.code,"that span is not a place",r.detail)}case "getParagraphId":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let d=a.story(t.value.story)?.paragraph(t.value.paragraphId);return I({kind:"text",text:d?.paraId??""})}case "search":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that is not a scope to search",t.detail);let r=q(o.scope,e,a);return r.ok?nt(r.value,t.value,o.text,o.options):l(r.code,"that is not a scope to search",r.detail)}case "insertText":{let t=kt(o.at,e,a);if(!t.ok)return l(t.code,"that is not a place to insert at",t.detail);let r=a.story(t.value.story);return r?bt(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in o.span){let d=K(o.span.body,"body",e,a);return d.ok?pe(u(d.value),o.text):l(d.code,"that handle does not name a body",d.detail)}let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to write into","empty-story");let r=M(t.value);return r?Ot(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let t=K(o.body,"body",e,a);return t.ok?N(u(t.value),o.paragraphs):l(t.code,"that handle does not name a body",t.detail)}case "insertParagraph":{let t=Wt(o.anchor,e,a);if(!t.ok)return l(t.code,"that is not a paragraph to insert beside",t.detail);if(o.where!=="before"&&o.where!=="after")return l("unknown-operation","that is not a place to insert",String(o.where));let r=a.story(t.value.story);return r?z(u(r),t.value,o.where,o.text):l("invalid-handle","that story is not in this document")}case "splitParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?st(u(r),t.value,o.delimiters,o.trimDelimiters===true,o.trimSpacing===true):l("invalid-handle","that story is not in this document")}case "getFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=oe(t.value,r.value);return I({kind:"font",font:un(r.value.part,d,n.displayMode)})}case "setFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to format","empty-story");let r=M(t.value);return r?pt(u(r),t.value,o.font):l("invalid-handle","that story is not in this document")}case "getStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value.part,p=r.value.styles(),f=tt(t.value,r.value).map(x=>Ft(d,x,p)),h=f.length>0&&f.every(x=>x!==null&&x===f[0])?f[0]:null;return I({kind:"style",name:h})}case "setStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to style","empty-story");let r=M(t.value);return r?Qn(u(r),t.value,o.name):l("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let t=Wt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("document-unavailable","this host holds no document right now");let d=cn(r.part,t.value.paragraphId,r.styles());return d?I({kind:"paragraphFormat",format:d}):l("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let t=Wt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);return r?Zn(u(r),t.value,o.format):l("invalid-handle","that story is not in this document")}case "deleteParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?xt(u(r),t.value):l("invalid-handle","that story is not in this document")}case "getSections":return e.resolve(o.document,"document")?I({kind:"handles",handles:a.sections().map(t=>e.section(t.index))}):l("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");let r=a.sections()[t.index];return r?I({kind:"pageSetup",setup:r.pageSetup}):l("invalid-handle","that section is not in this document")}case "setPageSetup":{let t=e.resolve(o.section,"section");return !t||t.kind!=="section"?l("invalid-handle","that handle does not name a section","section"):qn(t.index,o.setup)}case "getFurniture":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");if(o.kind!=="header"&&o.kind!=="footer")return l("unknown-operation","that is not furniture",String(o.kind));let r={kind:o.kind,sectionIndex:t.index,variant:o.variant};return an(r)?a.story(r)?I({kind:"handle",handle:e.body(r)}):l("invalid-handle","this document declares no such header or footer",B(r)):l("unknown-operation","that is not a furniture variant",String(o.variant))}case "getNotes":{if(!e.resolve(o.document,"document"))return l("invalid-handle","that handle does not name a document","document");if(o.noteKind!=="footnote"&&o.noteKind!=="endnote")return l("unknown-operation","that is not a kind of note",String(o.noteKind));let t=o.noteKind,r=a.noteIds(t);return r.ok?I({kind:"handles",handles:r.ids.map(d=>e.note(t,d))}):l("ambiguous-document",`${t} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getNoteBody":case "getNoteText":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=t,d=a.story(r);return d?o.op==="getNoteText"?I({kind:"text",text:d.text(o.projection)}):I({kind:"handle",handle:e.body(r)}):l("invalid-handle","that note is not in this document",B(r))}case "getNoteKind":{let t=e.resolve(o.note,"note");return !t||t.kind!=="note"?l("invalid-handle","that handle does not name a note","note"):I({kind:"text",text:t.noteKind})}case "deleteNote":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=a.noteIds(t.noteKind);return r.ok?r.ids.includes(t.noteId)?to(t.noteKind,t.noteId):l("invalid-handle","that note is not in this document"):l("ambiguous-document",`${t.noteKind} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getLists":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:zt(t.value).map(r=>e.list(r.numId,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getListId":{let t=Vt(o.list);return "list"in t?I({kind:"number",value:Number(t.list.numId)}):t}case "getListById":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);if(!Number.isInteger(o.id)||o.id<=0)return l("unsupported-content","a list is numbered from one",String(o.id));let r=String(o.id),d=zt(t.value).find(p=>p.numId===r);return d?I({kind:"handle",handle:e.list(d.numId,t.value.story)}):l("invalid-handle","no list in that story carries that number",r)}case "getListParagraphs":{let t=Vt(o.list);if(!("list"in t))return t;let r=o.level;if(r!==void 0&&(!Number.isInteger(r)||r<0||r>At))return l("invalid-offset",`a list level is 0 to ${String(At)}`,String(r));let d=t.plan.reads,p=r===void 0?t.list.paragraphIds:t.list.paragraphIds.filter(f=>Ct(d,f)?.level===r);return I({kind:"handles",handles:p.map(f=>e.paragraph(f,d.story))})}case "getParagraphList":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Ct(r,t.value.paragraphId);return d?I({kind:"handle",handle:e.list(d.numId,r.story)}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "getListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Ct(r,t.value.paragraphId);return d?I({kind:"number",value:d.level}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "setListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?eo(u(r),t.value.paragraphId,o.level):l("invalid-handle","that story is not in this document")}case "insertListParagraph":{let t=Vt(o.list);return "list"in t?no(t.plan,t.list,o.where,o.text):t}case "getHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=a.package;if(!d||!t.value)return I({kind:"text",text:""});let p=me(r.value,t.value);if(!p)return I({kind:"text",text:""});let f=chunkGWV65NQW_cjs.Ca(r.value.part,p.id),h=f?Cn(d,r.value.part.name,f):null;return I({kind:"text",text:h??""})}case "setHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no text to link","empty-story");let r=M(t.value);return r?oo(u(r),t.value,o.target):l("invalid-handle","that story is not in this document")}case "getBookmarks":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value,p=t.value,f=p===null?null:new Set(tt(p,d)),h=se(d).filter(x=>{if(!f||!f.has(x.start.paragraphId)&&!f.has(x.end.paragraphId)||p===null)return false;let R=x.start.paragraphId===p.end.paragraphId&&x.start.offset>p.end.offset,H=x.end.paragraphId===p.start.paragraphId&&x.end.offset<p.start.offset;return !R&&!H});return I({kind:"handles",handles:h.map(x=>e.bookmark(x.name,d.story))})}case "getBookmarkName":{let t=e.resolve(o.bookmark,"bookmark");return !t||t.kind!=="bookmark"?l("invalid-handle","that handle does not name a bookmark","bookmark"):I({kind:"text",text:t.name})}case "getBookmarkRange":{let t=ye(o.bookmark);return "reads"in t?I({kind:"span",span:X(t.range)}):t}case "getComments":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that scope is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that scope names no story",r.detail);let d=r.value,p=k(d);if(!p)return l("document-unavailable","this host holds no document");let f=t.value,h=p.roots.filter(x=>{if(!f)return true;let R=x.range;if(!R)return false;let H=d.indexOf(R.start.paragraphId),j=d.indexOf(R.end.paragraphId),D=d.indexOf(f.start.paragraphId),w=d.indexOf(f.end.paragraphId);return j<D||H>w?false:j===D&&H===D&&w===D?R.end.offset>f.start.offset&&R.start.offset<f.end.offset:true});return I({kind:"handles",handles:h.map(x=>e.comment(x.id,d.story))})}case "getCommentReplies":{let t=S(o.comment);return t.ok?I({kind:"handles",handles:t.item.replyIds.map(r=>e.comment(r,t.reads.story))}):t.planned}case "getCommentId":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.id}):t.planned}case "getCommentAuthor":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.author}):t.planned}case "getCommentDate":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.date??""}):t.planned}case "getCommentText":{let t=S(o.comment);if(!t.ok)return t.planned;let r=k(t.reads);return I({kind:"text",text:r?.textOf(t.item.id)??""})}case "getCommentRange":{let t=S(o.comment);if(!t.ok)return t.planned;let r=t.item.range;if(!r||t.item.orphaned)return l("invalid-handle","that comment has no range in this document");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let t=S(o.comment);return t.ok?I({kind:"flag",value:t.item.resolved}):t.planned}case "insertComment":return Ln(o,e,a,v);case "setCommentResolved":{let t=S(o.comment);if(!t.ok)return t.planned;if(typeof o.resolved!="boolean")return l("unsupported-content","resolved is a yes or a no",String(o.resolved));let r=y(u(t.reads));return r||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:t.item.id,resolved:o.resolved},story:t.reads.story,answer:()=>E}}case "replyToComment":{let t=S(o.comment);if(!t.ok)return t.planned;let r=ue({author:o.author,text:o.text,date:o.date,kind:"reply"});if(r)return r;let d=t.item.range;if(!d||t.item.orphaned)return l("invalid-handle","that comment has no range to reply over");let p=y(u(t.reads));if(p)return p;let f=t.reads.story,h=ce(o.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:t.item.id,anchor:{paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,...d.end.paragraphId===d.start.paragraphId?{}:{endParagraphId:d.end.paragraphId}},text:o.text,author:o.author,...h===void 0?{}:{date:h}},story:t.reads.story,answer:(x,R)=>R===void 0?E:{kind:"handle",handle:e.comment(R,f)}}}case "deleteComment":{let t=S(o.comment);return t.ok?En(t.item,t.reads,r=>y(u(r))):t.planned}case "getRevisions":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);let r=t.value;return I({kind:"handles",handles:de(r).map(d=>e.revision(d.id,r.story))})}case "getRevisionType":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.type}):t.planned}case "getRevisionAuthor":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.author}):t.planned}case "getRevisionDate":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.date}):t.planned}case "getRevisionRange":{let t=A(o.revision);if(!t.ok)return t.planned;let[r]=t.item.item.ranges;if(!r)return l("invalid-handle","that change covers no characters");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let t=A(o.revision);if(!t.ok)return t.planned;let r=u(t.reads),d=y(r);if(d)return d;let p=o.op==="acceptRevision";return {ok:true,kind:"command",story:t.reads.story,ops:t.item.item.addresses.map(f=>p?{op:"acceptRevision",revision:f}:{op:"rejectRevision",revision:f}),answer:()=>E}}case "acceptAllRevisions":case "rejectAllRevisions":{let t=Nn(o,e,a);if(!t.ok)return l(t.code,t.message,t.detail);let r=u(t.reads),d=y(r);if(d)return d;let p=Hn(o,t.reads);return {ok:true,kind:"command",story:t.reads.story,ops:p,answer:()=>E}}case "selectSpan":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to select","empty-story");let r=M(t.value);return r?fe(u(r),t.value,o.mode):l("invalid-handle","that story is not in this document")}case "selectBookmark":{let t=ye(o.bookmark);return "reads"in t?fe(u(t.reads),t.range,o.mode):t}case "getContentControls":{let t=$t(o.scope);return "reads"in t?I({kind:"handles",handles:Bn(t.reads,t.node).map(r=>e.contentControl(r.nodeId,t.reads.story))}):t}case "getContentControlById":{let t=$t(o.scope);if(!("reads"in t))return t;if(!Number.isInteger(o.id))return l("unsupported-content","a control id is a whole number",String(o.id));let r=Gn(t.node).find(d=>chunkGWV65NQW_cjs.sf(d).id===o.id);return r?I({kind:"handle",handle:e.contentControl(r.id,t.reads.story)}):l("invalid-handle","no control in that scope carries that id",String(o.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let t=$t(o.scope);if(!("reads"in t))return t;let r=o.op==="getContentControlsByTag"?o.tag:o.title;if(typeof r!="string"||r.length===0)return l("unsupported-content","a tag or title to match is required",o.op);let d=Gn(t.node).filter(p=>{let f=chunkGWV65NQW_cjs.sf(p);return o.op==="getContentControlsByTag"?f.tag===r:f.alias===r});return I({kind:"handles",handles:d.map(p=>e.contentControl(p.id,t.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=t.control.properties;if(o.op==="getContentControlLock")return I({kind:"text",text:t.control.lock});if(o.op==="getContentControlSubtype")return I({kind:"text",text:r.type});if(o.op==="getContentControlFileId")return I({kind:"text",text:r.id===void 0?"":String(r.id)});let d=o.op==="getContentControlTag"?r.tag:r.alias;return I({kind:"text",text:d??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.op==="getContentControlIsBound"?t.control.properties.dataBinding!==void 0:o.op==="getContentControlPlaceholderShown"?t.control.properties.showingPlaceholder:t.control.properties.temporary;return I({kind:"flag",value:r})}case "getContentControlText":{let t=ot(o.contentControl);return "control"in t?I({kind:"text",text:Dn(t.reads,t.node,o.projection)}):t}case "getContentControlParagraphs":{let t=ot(o.contentControl);return "control"in t?I({kind:"handles",handles:t.control.paragraphIds.map(r=>e.paragraph(r,t.reads.story))}):t}case "getContentControlRange":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.location??"whole";if(!or.has(r))return l("unsupported-content","that is not a place in a control",r);let d=Kt(t.reads,t.node);if(!d)return l("unsupported-content","that control holds nothing addressable","empty");let p=r==="start"||r==="before"?d.start:d.end,f=r!=="whole"&&r!=="content",h=x=>({story:t.reads.story,paragraphId:x.paragraphId,index:t.reads.indexOf(x.paragraphId),offset:x.offset});return I({kind:"span",span:re(f?{start:h(p),end:h(p)}:{start:h(d.start),end:h(d.end)},e)})}case "setContentControlValue":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=sr(o.value);if(!r.ok)return l(r.code,r.message,r.detail);let d=u(t.reads),p=y(d);return p||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:r.value}],answer:()=>E}}case "setContentControlProperties":{let t=ot(o.contentControl);if(!("control"in t))return t;if(o.tag===void 0&&o.title===void 0&&o.lock===void 0)return l("unsupported-content","nothing to write","no-properties");if(o.lock!==void 0&&!nr.has(o.lock))return l("unsupported-content","that is not a lock this schema declares",o.lock);let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlProperties",controlId:t.control.nodeId,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title},...o.lock===void 0?{}:{lock:o.lock}}],answer:()=>E}}case "insertContentControlText":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.text!="string")return l("unsupported-content","text is required","text");if(o.at!=="replace"&&o.at!=="start"&&o.at!=="end")return l("unsupported-content","that is not a place to insert at",String(o.at));let r=u(t.reads),d=y(r);if(d)return d;let p=Kt(t.reads,t.node);if(!p)return l("unsupported-content","that control holds nothing addressable","empty");let f=o.at==="end"?p.end:p.start,h=()=>({kind:"span",span:X({start:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset},end:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset+o.text.length}})});return o.at==="replace"?{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:{kind:"text",text:o.text}}],answer:h}:{ok:true,kind:"command",story:t.reads.story,ops:o.text.length===0?[]:[{op:"insertText",paragraphId:f.paragraphId,offset:f.offset,text:o.text,inside:t.node.id}],answer:h}}case "deleteContentControl":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.keepContent!="boolean")return l("unsupported-content","keepContent is required","keepContent");let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"removeContentControl",controlId:t.control.nodeId,keepContent:o.keepContent}],answer:()=>E}}case "insertContentControl":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds nothing to wrap","empty-story");let r=M(t.value);if(!r)return l("invalid-handle","that story is not in this document");let d=t.value;if(d.start.paragraphId!==d.end.paragraphId)return l("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!rr.has(o.subtype))return l("unsupported-content","that control type cannot be inserted",o.subtype);let p=u(r),f=y(p);return f||{ok:true,kind:"command",story:r.story,ops:[{op:"insertContentControl",paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,type:o.subtype,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title}}],answer:()=>E}}case "insertCustomNode":{let t=$n(o);if(t)return l("unsupported-content",t.message,t.detail);let r=Vn(o.payload);if(!r.ok)return l("unsupported-content","that payload cannot be written",r.field);let d=Xn(o,e,a);if("code"in d)return l(d.code,d.message,d.detail);let{start:p,end:f}=d.range,h=M(d.range);if(!h)return l("invalid-handle","that story is not in this document");let x=y(u(h));return x||{ok:true,kind:"customNodeWrite",story:h.story,write:Un(o,p,f,r.value),answer:()=>E}}default:return l("unknown-operation","this host does not implement that operation",String(o.op))}};return {plan(o){let t=g.conflict(o);if(t)return l("conflicting-operations",t.message,t.detail);let r=ro(o);return r.ok&&g.note(o),r},get hasCommands(){return g.hasCommands},get writeScope(){return m?.reads.scope??null},settle(o){let t=m;if(t){let r=o.story(t.reads.story);if(!r)return {ok:false,detail:`the story this batch wrote is gone: ${B(t.reads.story)}`};let d=new Set(t.reads.paragraphIds),p=r.paragraphIds.filter(h=>!d.has(h));if(p.length!==t.created.length)return {ok:false,detail:`planned ${String(t.created.length)} new paragraphs, the transaction made ${String(p.length)}`};t.order.filter(h=>h.id===null).forEach((h,x)=>{h.id=p[x]??null;});for(let h of t.retargets)h.slot.id&&e.retarget(h.from,h.slot.id);}for(let r of c){let d=o.story(r.range.start.story);!d||!lr(r.range,d)||n.select?.(r.range,r.mode);}return {ok:true}}}}var cr=Object.freeze({status:"skipped"});function G(n,e,s){return Object.freeze(s===void 0?{code:n,message:e}:{code:n,message:e,detail:s})}function pr(n){let e=n==="unsupported-revision"||n.startsWith("unsupported-revision:");return G(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",n)}function et(n,e,s,a){return {ok:false,results:n.map((i,u)=>u===e?{status:"error",error:s}:cr),revision:a,changed:false}}function ns(n){let{port:e}=n,s=Object.freeze({...n.capabilities}),a=sn(),i=new Set,u=false,c=null,g=s.events?e.subscribe(()=>{if(u)return;let v=Object.freeze({revision:e.revision()});for(let k of [...i])k(v);}):()=>{},m=v=>{if(c&&c.pkg===v)return c.value;let k=bn(v);return c={pkg:v,value:k},k};return {capabilities:s,revision:()=>e.revision(),execute:v=>{let k=Array.isArray(v?.operations)?v.operations:[],S=e.revision();if(u)return et(k,0,G("disposed","this host was disposed"),S);if(!s.document)return et(k,0,G("unsupported-capability","this host has no document","document"),S);let A=e.currentPackage();if(!A)return et(k,0,G("document-unavailable","this host holds no document right now"),S);if(v.expectedRevision!==void 0&&v.expectedRevision!==S)return et(k,0,G("stale-revision","the document moved since that revision",`expected ${String(v.expectedRevision)}, at ${S}`),S);let b=Jn({handles:a,reads:m(A),capabilities:s,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.select?{select:e.select.bind(e)}:{}}),C=[],O=[],T=null,L=[],F=null,J,X=null,M=-1;for(let N=0;N<k.length;N+=1){let z=b.plan(k[N]);if(!z.ok)return et(k,N,z.error,S);if(C.push(z),z.kind==="command")if(M<0&&(M=N),z.lifecycle)T=z.ops[0]??null;else if(z.relate){let st=z.relate;O.push(xt=>{let pt=xt(st.url);return pt===null?null:st.ops(pt)});}else {let{ops:st}=z;O.push(()=>st);}else z.kind==="commentWrite"?(M<0&&(M=N),L.push(z.write),F=b.writeScope??{kind:"body"}):z.kind==="customNodeWrite"&&(M<0&&(M=N),X={write:z.write,scope:b.writeScope??{kind:"body"}});}let V=false;if(L.length>0){let N=e.applyCommentWrites(L,F??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the comment write",N.reason),S);V=N.changed,J=N.commentId;}if(X){let N=e.applyCustomNodeWrite(X.write,X.scope);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the custom-node write",N.reason),S);V=N.changed;}if(T){let N=e.applyLifecycle(T);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the transaction",N.reason),S);V=N.changed;}if(O.length>0){let N=e.apply(z=>{let st=[];for(let xt of O){let pt=xt(z);if(pt===null)return null;st.push(...pt);}return st},b.writeScope??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,pr(N.reason),S);V=N.changed;}let nt=e.currentPackage();if(!nt)return et(k,0,G("document-unavailable","this host holds no document right now"),S);let bt=m(nt),Ot=b.settle(bt);return Ot.ok?{ok:true,results:C.map(N=>({status:"ok",value:N.kind==="query"?N.value:N.kind==="customNodeWrite"?N.answer(bt):N.answer(bt,J)})),revision:e.revision(),changed:V}:et(k,M<0?0:M,G("transaction-refused","the transaction did not produce the document the batch planned",Ot.detail),e.revision())},save(){if(u)return {ok:false,error:G("disposed","this host was disposed")};if(!s.save)return {ok:false,error:G("unsupported-capability","this host cannot save","save")};let v=e.save();return v?{ok:true,bytes:v}:{ok:false,error:G("document-unavailable","this host holds no document right now")}},subscribe(v){return u||!s.events?()=>{}:(i.add(v),()=>{i.delete(v);})},dispose(){u||(u=true,i.clear(),g(),e.dispose(),c=null);}}}exports.a=Bt;exports.b=fr;exports.c=lo;exports.d=uo;exports.e=Zt;exports.f=qt;exports.g=ns;
@@ -1 +1 @@
1
- var t=class extends Error{name="EditorFontError";code;request;diagnostic;constructor(r,n,e={}){super(n,{cause:e.cause}),this.code=r,this.request=e.request,this.diagnostic=e.diagnostic;}};export{t as a};
1
+ var t=class extends Error{name="EditorFontError";code;request;diagnostic;constructor(r,o,e={}){super(o,{cause:e.cause}),this.code=r,this.request=e.request,this.diagnostic=e.diagnostic;}};export{t as a};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkGWV65NQW_cjs=require('./chunk-GWV65NQW.cjs');var Gt=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Kt=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,qt=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function ut(e){return Kt.test(e)||qt.test(e)}function oe(e,t){if(!ut(e))throw new Error(`invalid ${t??"registry"} id ${JSON.stringify(e)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var Yt=/^(\d+)\.(\d+)\.(\d+)$/;function M(e){let t=Yt.exec(e);if(!t)throw new Error(`invalid semantic version: ${JSON.stringify(e)}`);return {major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function re(e,t){return e.major!==t.major?e.major<t.major?-1:1:e.minor!==t.minor?e.minor<t.minor?-1:1:e.patch!==t.patch?e.patch<t.patch?-1:1:0}function ie(e,t){let n=M(e),o=t.trim();if(o==="*")return true;if(o.startsWith("^")){let r=M(o.slice(1));return re(n,r)<0?false:r.major>0?n.major===r.major:r.minor>0?n.major===0&&n.minor===r.minor:n.major===0&&n.minor===0}if(o.includes(" ")){let r=o.split(/\s+/);if(r.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let s=true;for(let i of r){let a=i.startsWith(">=")?">=":i.startsWith("<")?"<":null;if(!a)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=M(i.slice(a.length)),c=re(n,l);a===">="?s=s&&c>=0:s=s&&c<0;}return s}return re(n,M(o))===0}var b=class extends Error{constructor(n,o,r=[]){super(o);this.code=n;this.responsible=r;this.name="RegistryError";}code;responsible},we=(e,t)=>`${e}:${t}`;function Xt(e,t={}){let n=new Map;for(let c of e){if(oe(c.id,"extension"),ft(c.version,c.id),n.has(c.id))throw new b("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let p of c.contributions)oe(p.id,p.kind),ft(p.version,`${c.id} \u2192 ${p.id}`),p.replaces&&Zt(p.replaces.targetRange,`${c.id} \u2192 replaces ${p.replaces.targetId}`);}for(let c of e){for(let p of c.dependencies??[])if(!n.has(p))throw new b("missing-dependency",`${c.id} requires missing extension ${p}`,[c.id,p]);for(let p of c.conflicts??[])if(n.has(p)){let h=[c.id,p].sort();throw new b("conflict",`extensions ${h[0]} and ${h[1]} conflict`,h)}}Qt(n);let o=new Set(t.availablePorts??[]);for(let c of e)for(let p of c.contributions)p.kind==="runtimePort"&&o.add(p.id);for(let c of e)for(let p of c.requiredPorts??[])if(!o.has(p))throw new b("missing-port",`${c.id} requires unavailable port ${p}`,[c.id,p]);let r=new Map,s=new Map,i=new Map;for(let c of e)for(let p of c.contributions){let h=we(p.kind,p.id);if(p.replaces){let x=we(p.kind,p.replaces.targetId),R=i.get(x)??[];R.push({ext:c.id,c:p}),i.set(x,R);continue}if(s.has(h)){let x=[r.get(h),c.id].sort();throw new b("id-collision",`${p.kind} id ${p.id} registered by both ${x[0]} and ${x[1]}`,x)}s.set(h,p),r.set(h,c.id);}let a=new Map(s);for(let[c,p]of i){let h=s.get(c);if(!h){let v=p[0];throw new b("replacement-target-missing",`${v.ext} replaces missing target ${v.c.replaces.targetId}`,[v.ext,v.c.replaces.targetId])}let x=h.replaceable??{kind:"none"};for(let{ext:v,c:k}of p){if(!ie(h.version,k.replaces.targetRange))throw new b("replacement-version-mismatch",`${v} replaces ${k.replaces.targetId}@${h.version} outside range ${k.replaces.targetRange}`,[v,k.replaces.targetId]);if(x.kind==="none")throw new b("unauthorized-replacement",`${k.replaces.targetId} does not authorize replacement (attempted by ${v})`,[v,k.replaces.targetId])}let R=Jt(h,p);a.set(c,R);}return {extensions:n,contributions:a,get:(c,p)=>a.get(we(c,p))}}function Jt(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let r=[...t].sort((a,l)=>(l.c.replaces.priority??0)-(a.c.replaces.priority??0)),s=r[0].c.replaces.priority??0,i=r.filter(a=>(a.c.replaces.priority??0)===s);if(i.length>1){let a=i.map(l=>l.ext).sort();throw new b("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${s}: ${a.join(", ")}`,a)}return r[0].c}let o=t.map(r=>r.ext).sort();throw new b("ambiguous-replacement",`multiple replacers of ${e.id}: ${o.join(", ")}`,o)}function Qt(e){let r=new Map,s=[],i=a=>{r.set(a,1),s.push(a);let l=[...e.get(a)?.dependencies??[]].sort();for(let c of l){let p=r.get(c)??0;if(p===1){let h=s.indexOf(c),x=[...s.slice(h),c];throw new b("dependency-cycle",`dependency cycle: ${x.join(" -> ")}`,x)}p===0&&i(c);}s.pop(),r.set(a,2);};for(let a of [...e.keys()].sort())(r.get(a)??0)===0&&i(a);}function ft(e,t){try{M(e);}catch{throw new b("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Zt(e,t){try{ie("0.0.0",e);}catch{throw new b("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var L=class extends Error{constructor(t){super(t),this.name="BudgetError";}},K=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new chunkGWV65NQW_cjs.p(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,o=this;return {amount:t,get released(){return n},release(){n||(n=true,o.used.release(t),o.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let o=new e(t,n);return o.parent=this,o.carveAmount=n,this.children.add(o),o}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new L(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new L(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let t=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(o){t.push(o);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),t.length>0)throw new L(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new L(`${this.label}: budget already released`)}};var ae=class extends Error{constructor(n,o){super(o?`cancelled: ${o}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},q=class{_cancelled=false;_phase="pre-publication";_reason;cancel(t){this._cancelled=true,t!==void 0&&(this._reason=t);}markPublished(){this._phase="post-publication";}get isCancelled(){return this._cancelled}get phase(){return this._phase}get isPublished(){return this._phase==="post-publication"}get derivedOnly(){return this._cancelled&&this._phase==="post-publication"}get token(){let t=this;return {get isCancelled(){return t._cancelled},get phase(){return t._phase},get derivedOnly(){return t.derivedOnly},checkpoint(){if(t._cancelled)throw new ae(t.derivedOnly,t._reason)}}}};var se=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},ke=class{ports=new Map;provide(t,n){return this.ports.set(t,n),this}has(t){return this.ports.has(t)}resolve(t){if(!this.ports.has(t))throw new se(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(chunkGWV65NQW_cjs.f.clock)}identity(){return this.resolve(chunkGWV65NQW_cjs.f.identity)}},Ne=class{constructor(t=0,n=1){this.step=n;this.t=t;}step;t;now(){let t=this.t;return this.t+=this.step,t}},Te=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function en(e){let t=chunkGWV65NQW_cjs.k(e.limits),n=Object.freeze({...e.config??{}}),o=e.capacity??t.maxDecompressedBytes,r=e.id??"op",s={id:r,limits:t,config:n,ports:e.ports,budget:new K(`op:${r}`,o),cancellation:new q};return Object.freeze(s)}function tn(e){e.budget.dispose();}var _e=Object.freeze({maxRecursionDepth:{unit:"depth",phase:"xml-parse"},maxElementCount:{unit:"count",phase:"xml-parse"},maxPartCount:{unit:"count",phase:"package-read"},maxDecompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressedBytes:{unit:"bytes",phase:"package-read"},maxCompressionRatio:{unit:"ratio",phase:"package-read"},maxChunkBytes:{unit:"bytes",phase:"package-read"},maxPaginationPasses:{unit:"passes",phase:"layout"},maxQueueDepth:{unit:"count",phase:"output"}}),yt=Object.keys(_e);function nn(e,t){return new chunkGWV65NQW_cjs.p(`${_e[t].phase}:${t}`,e[t])}var Pe=class{counter;current=0;peak=0;constructor(t){this.counter=new chunkGWV65NQW_cjs.p("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function on(){for(let e of yt){let t=chunkGWV65NQW_cjs.j[e],n=chunkGWV65NQW_cjs.i[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function Y(e,t=new Set){let n=new WeakSet,o=r=>{if(r===null)return "null";let s=typeof r;if(s==="boolean")return r?"true":"false";if(s==="number"){let i=r;if(!Number.isFinite(i))throw new Error(`non-finite number is not comparable: ${i}`);return Object.is(i,-0)?"0":String(i)}if(s==="string")return JSON.stringify(r);if(s==="bigint")return `${r.toString()}n`;if(Array.isArray(r))return `[${r.map(o).join(",")}]`;if(s==="object"){let i=r;if(n.has(i))throw new Error("cannot canonicalize a cyclic structure");n.add(i);let l=Object.keys(i).filter(c=>!t.has(c)).sort().map(c=>`${JSON.stringify(c)}:${o(i[c])}`).join(",");return n.delete(i),`{${l}}`}throw new Error(`unsupported value type in comparator input: ${s}`)};return o(e)}function Ae(e,t){let n=Y(e,t),o=0xcbf29ce484222325n,r=0x100000001b3n,s=0xffffffffffffffffn;for(let i=0;i<n.length;i++)o^=BigInt(n.charCodeAt(i)),o=o*r&s;return o.toString(16).padStart(16,"0")}var w="dev.docx-editor.core.comparator",$e={authoredState:{id:`${w}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${w}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${w}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${w}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${w}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${w}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${w}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${w}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${w}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${w}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Me(e,t,n,o={}){let r=$e[e];switch(r.mode){case "sync-optimization-only":throw new Error(`${r.id} is not an equivalence basis (${r.note})`);case "tolerance":{if(o.epsilon===void 0)throw new Error(`${r.id} requires an explicit epsilon`);return {equal:ht(t,n,o.epsilon)}}case "exact":case "canonical-exact":{let s=r.mode==="canonical-exact"?new Set(r.ephemera):new Set,i=Y(t,s),a=Y(n,s);return i===a?{equal:true}:{equal:false,left:i,right:a}}}}function Le(e,t){let n=$e[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let o=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Ae(t,o)}function ht(e,t,n){return typeof e=="number"&&typeof t=="number"?Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e-t)<=n:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,r)=>ht(o,t[r],n)):false}var xt=new Set([...chunkGWV65NQW_cjs.c,...chunkGWV65NQW_cjs.d]),gt=/^[0-9a-f]{16}$/,rn=/^[0-9a-f]*$/;function Fe(e){let t=[],n=r=>t.push(r);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let o=-1;e.steps.forEach((r,s)=>{let i=`step[${s}]`;xt.has(r.origin)||n(`${i}: unknown origin ${r.origin}`),(!Number.isInteger(r.baseRevision)||r.baseRevision<0)&&n(`${i}: baseRevision must be a non-negative integer`),r.baseRevision<o&&n(`${i}: baseRevision regressed below ${o}`);let a=r.expect;a.outcome==="applied"?(a.committedRevision===void 0?n(`${i}: applied step needs committedRevision`):a.committedRevision<=r.baseRevision?n(`${i}: committedRevision ${a.committedRevision} must exceed baseRevision ${r.baseRevision}`):o=a.committedRevision,a.modelChange&&an(a.modelChange,i,n)):(a.committedRevision!==void 0&&n(`${i}: ${a.outcome} step must not commit a revision`),a.authoredStateHash!==void 0&&n(`${i}: ${a.outcome} step must not change authored state`)),a.authoredStateHash!==void 0&&!gt.test(a.authoredStateHash)&&n(`${i}: authoredStateHash must be 16-hex`),a.outputHash!==void 0&&!gt.test(a.outputHash)&&n(`${i}: outputHash must be 16-hex`);});for(let r of [...e.snapshots??[],...e.updates??[]])r.documentId!==e.documentId&&n(`envelope documentId ${r.documentId} != ${e.documentId}`),rn.test(r.bytesHex)||n("envelope bytesHex must be hex"),r.bytesHex.length!==r.byteLength*2&&n(`envelope byteLength ${r.byteLength} disagrees with ${r.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function an(e,t,n){xt.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function sn(e,t){let n=Fe(e);if(!n.valid)return {ok:false,mismatches:n.errors};let o=[];return t.init(e),e.steps.forEach((r,s)=>{let i=`step[${s}]`,a=t.applyStep(r),l=r.expect;if(a.outcome!==l.outcome){o.push(`${i}: outcome ${a.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(a.committedRevision!==l.committedRevision&&o.push(`${i}: revision ${a.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(a.authoredState===void 0)o.push(`${i}: store returned no authored state to hash`);else {Me("authoredState",a.authoredState,a.authoredState).equal||o.push(`${i}: authored state is not self-consistent`);let p=Rt(a.authoredState);p!==l.authoredStateHash&&o.push(`${i}: authoredStateHash ${p} != expected ${l.authoredStateHash}`);}}),{ok:o.length===0,mismatches:o}}function Rt(e){return Le("authoredState",e)}var F="http://schemas.openxmlformats.org/officeDocument/2006/relationships",ln="http://schemas.openxmlformats.org/package/2006/relationships",cn="http://schemas.openxmlformats.org/drawingml/2006/main",Et="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",vt="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",St="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",It="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",Ct="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",wt="application/vnd.openxmlformats-package.relationships+xml",De=`${F}/styles`,Be=`${F}/numbering`,kt=`${F}/footnotes`,Nt=`${F}/endnotes`,Tt=`${F}/officeDocument`,dn=`${F}/theme`;function I(e){return e.kind!=="textValue"}function Ot(e,t){return {...e,children:t}}function P(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)P(n,t);}var pn=new Set(["pStyle","rStyle","tblStyle"]);function Ue(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue"&&pn.has(o.localName)&&o.namespaceUri===chunkGWV65NQW_cjs.ca){let r=chunkGWV65NQW_cjs.we(o,"val");r&&t.add(r);}});}function Ve(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue"&&o.localName==="numId"&&o.namespaceUri===chunkGWV65NQW_cjs.ca){let r=chunkGWV65NQW_cjs.we(o,"val");r&&t.add(r);}});}function ce(e,t){for(let n of e)P(n,o=>{if(o.kind!=="textValue")for(let r of o.attributes)r.namespaceUri===F&&r.value.length>0&&t.add(r.value);});}function je(e,t){let n=new Set;for(let o of e)P(o,r=>{if(r.kind!=="textValue"&&r.kind==="noteReference"&&r.localName===t){let s=chunkGWV65NQW_cjs.we(r,"id");s!==void 0&&n.add(s);}});return n}function mn(e,t){for(let n of chunkGWV65NQW_cjs.Wb(e,t)){if(n.type!==De||n.targetMode==="External")continue;let o=chunkGWV65NQW_cjs.w(n.ownerPart,n.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return e.parts.get("/word/styles.xml")??null}function Pt(e,t,n){for(let o of chunkGWV65NQW_cjs.Wb(e,t)){if(o.type!==n||o.targetMode==="External")continue;let r=chunkGWV65NQW_cjs.w(o.ownerPart,o.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return null}function _t(e,t){let n=mn(e,t),o=new Map,r=[],s=null;if(n&&I(n.root))for(let i of n.root.children){if(!I(i))continue;if(i.localName==="docDefaults"&&i.namespaceUri===chunkGWV65NQW_cjs.ca){s=i;continue}if(i.localName!=="style"||i.namespaceUri!==chunkGWV65NQW_cjs.ca)continue;let a=chunkGWV65NQW_cjs.we(i,"styleId");a&&o.set(a,i),(chunkGWV65NQW_cjs.we(i,"default")==="1"||chunkGWV65NQW_cjs.we(i,"default")==="true")&&r.push(i);}return {part:n,byId:o,defaults:r,docDefaults:s}}var un=new Set(["basedOn","link","next"]);function ze(e,t){let n=new Set,o=[...t];for(let i of e.defaults){let a=chunkGWV65NQW_cjs.we(i,"styleId");a&&o.push(a);}let r=[];for(;o.length>0;){let i=o.pop();if(n.has(i))continue;n.add(i);let a=e.byId.get(i);if(a){r.push(a);for(let l of a.children)if(I(l)&&un.has(l.localName)&&l.namespaceUri===chunkGWV65NQW_cjs.ca){let c=chunkGWV65NQW_cjs.we(l,"val");c&&o.push(c);}}}if(!e.part||!I(e.part.root))return r;let s=new Map;return e.part.root.children.forEach((i,a)=>s.set(i,a)),r.sort((i,a)=>(s.get(i)??0)-(s.get(a)??0))}function At(e,t,n){let o=Pt(e,t,Be)??e.parts.get("/word/numbering.xml")??null;if(!o||!I(o.root)||n.size===0)return {part:o,nums:[],abstracts:[]};let r=[],s=new Set;for(let a of o.root.children){if(!I(a)||a.localName!=="num"||a.namespaceUri!==chunkGWV65NQW_cjs.ca)continue;let l=chunkGWV65NQW_cjs.we(a,"numId");if(!(!l||!n.has(l))){r.push(a);for(let c of a.children)if(I(c)&&c.localName==="abstractNumId"){let p=chunkGWV65NQW_cjs.we(c,"val");p&&s.add(p);}}}let i=[];for(let a of o.root.children){if(!I(a)||a.localName!=="abstractNum"||a.namespaceUri!==chunkGWV65NQW_cjs.ca)continue;let l=chunkGWV65NQW_cjs.we(a,"abstractNumId");l&&s.has(l)&&i.push(a);}return {part:o,nums:r,abstracts:i}}var le={latin:null,eastAsia:null,cs:null};function $t(e,t){let n=Pt(e,t,dn);if(!n)return {major:le,minor:le};let o={major:{...le},minor:{...le}};return P(n.root,r=>{if(r.kind==="textValue"||r.namespaceUri!==cn||r.localName!=="majorFont"&&r.localName!=="minorFont")return;let s=r.localName==="majorFont"?o.major:o.minor;for(let i of r.children){if(!I(i))continue;let a=chunkGWV65NQW_cjs.we(i,"typeface");a&&(i.localName==="latin"?s.latin=a:i.localName==="ea"?s.eastAsia=a:i.localName==="cs"&&(s.cs=a));}}),{major:o.major,minor:o.minor}}function fn(e,t){let n=t.startsWith("major")?e.major:e.minor;return t.endsWith("EastAsia")?n.eastAsia??n.latin:t.endsWith("Bidi")?n.cs??n.latin:n.latin}var yn=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],bt=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function _(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===chunkGWV65NQW_cjs.ca){let s=[],i=new Map;for(let a of e.attributes){let l=yn.find(([c])=>c===a.localName);if(l&&a.namespaceUri===chunkGWV65NQW_cjs.ca){let c=fn(t,a.value);c&&i.set(l[1],c);continue}s.push(a);}for(let[a,l]of i)s.some(c=>c.localName===a)||s.push({kind:"genericExtension",namespaceUri:chunkGWV65NQW_cjs.ca,localName:a,prefix:"w",value:l});n=s;}else e.attributes.some(s=>bt.has(s.localName)&&s.namespaceUri===chunkGWV65NQW_cjs.ca&&e.attributes.some(i=>i.localName==="val"))&&(n=e.attributes.filter(s=>!(bt.has(s.localName)&&s.namespaceUri===chunkGWV65NQW_cjs.ca)));let o=e.children.map(s=>_(s,t)),r=o.some((s,i)=>s!==e.children[i]);return n===e.attributes&&!r?e:{...e,attributes:n,children:o}}function Mt(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Lt(e,t){if(e.root.kind==="document"){let o=e.root.children.find(s=>s.kind==="body"),r=o&&I(o)?Ot(o,t):{id:"fragment#body",kind:"body",namespaceUri:chunkGWV65NQW_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return Ot(e.root,[r])}let n={id:"fragment#body",kind:"body",namespaceUri:chunkGWV65NQW_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:chunkGWV65NQW_cjs.ca,localName:"document",prefix:"w",namespaceBindings:I(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function X(e){let t=e.map(n=>{let o=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${chunkGWV65NQW_cjs.N(n.id)}" Type="${chunkGWV65NQW_cjs.N(n.type)}" Target="${chunkGWV65NQW_cjs.N(n.rawTarget)}"${o}/>`}).join("");return `<Relationships xmlns="${ln}">${t}</Relationships>`}function Ft(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Dt(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}var hn="http://schemas.openxmlformats.org/package/2006/content-types",gn=5e4;function A(e){return e.kind!=="textValue"}function z(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)z(n,t);return t}function de(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let o=de(n,t);if(o)return o}return null}function S(e,t){return {...e,children:t}}function H(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunkGWV65NQW_cjs.ca}function xn(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&A(t)?t:null}return A(e.root)?e.root:null}function Rn(e,t){return z(e).some(n=>t.has(n))}function On(e){let t=o=>{if(o.kind==="textValue")return o;if(H(o,"vMerge")){if(chunkGWV65NQW_cjs.we(o,"val")==="restart")return o;let r=[...o.attributes.filter(s=>!(s.localName==="val"&&s.namespaceUri===chunkGWV65NQW_cjs.ca)),{kind:"wmlVal",namespaceUri:chunkGWV65NQW_cjs.ca,localName:"val",prefix:"w",value:"restart"}];return {...o,attributes:r}}if(H(o,"tc")||H(o,"tcPr")){let r=o.children.map(t);return S(o,r)}return o},n=e.children.map(t);return S(e,n)}function bn(e,t,n){let o=e.children.filter(l=>l.kind!=="textValue"&&H(l,"tr")),r=new Set(z(e).filter(l=>t.inRange.has(l)));if(r.size===0)return;let s=o.filter(l=>{let c=z(l);return c.length>0&&c.every(p=>t.covered.has(p))}),i=new Set(s.flatMap(l=>z(l)));if(s.length>0&&r.size===i.size&&[...r].every(l=>i.has(l))){let l=true,c=[];for(let p of e.children){if(!H(p,"tr")){c.push(p);continue}s.includes(p)&&(c.push(l?On(p):p),l=false);}n.push(S(e,c));return}for(let l of z(e)){if(!t.inRange.has(l))continue;let c=de(e,l);c&&n.push(c);}}function He(e,t,n){for(let o of e)if(A(o)){if(o.kind==="paragraph"){t.inRange.has(o.id)&&n.push(o);continue}if(t.fullBlocks.has(o.id)){n.push(o);continue}if(o.kind==="table"){bn(o,t,n);continue}if(o.kind==="contentControl"){let r=o.children.find(s=>s.kind==="contentControlContent");r&&A(r)&&He(r.children,t,n);continue}Rn(o,t.inRange)&&He(o.children,t,n);}}var En=new Set(["commentRangeStart","commentRangeEnd"]);function vn(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function We(e){if(e.kind==="textValue")return e;if(En.has(e.localName)&&e.namespaceUri===chunkGWV65NQW_cjs.ca||vn(e)||H(e,"sectPr"))return null;let t=false,n=[];for(let o of e.children){let r=We(o);if(r===null){t=true;continue}r!==o&&(t=true),n.push(r);}return t?S(e,n):e}function Sn(e){if(e.kind!=="run")return null;for(let t of e.children)if(t.kind==="fldChar"){let n=chunkGWV65NQW_cjs.we(t,"fldCharType");return n==="begin"||n==="separate"||n==="end"?n:"begin"}return null}function In(e){return e.kind==="run"&&e.children.some(t=>t.kind==="instrText")}function Cn(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){let c=Sn(l);c?t.push({nodeId:l.id,type:c}):In(l)&&t.push({nodeId:l.id,type:"instr"});return}for(let c of l.children)n(c);}};for(let l of e)n(l);if(t.length===0)return e;let o=new Set,r=[],s=null,i=[];for(let l of t){if(l.type==="begin"){r.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let p=r[r.length-1];p?p.separateId=l.nodeId:s=l.nodeId;continue}if(l.type==="instr"){let p=r[r.length-1];p?p.instrIds.push(l.nodeId):s===null&&i.push(l.nodeId);continue}if(!r.pop()){o.add(l.nodeId),s!==null&&o.add(s);for(let p of i)o.add(p);s=null,i=[];}}for(let l of r){o.add(l.beginId),l.separateId!==null&&o.add(l.separateId);for(let c of l.instrIds)o.add(c);}s!==null&&o.add(s);for(let l of i)o.add(l);if(o.size===0)return e;let a=l=>{if(l.kind==="textValue")return l;if(o.has(l.id))return null;let c=[],p=false;for(let h of l.children){let x=a(h);if(x===null){p=true;continue}x!==h&&(p=true),c.push(x);}return p?S(l,c):l};return e.map(l=>a(l)).filter(l=>l!==null)}function Ge(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=Ge(n);return t}function wn(e,t){let n=[];for(let o of e.children){if(o.kind!=="contentControl"){n.push(o);continue}let r=t.get(o.id),s=Ge(o);if(r===void 0||s>=r){n.push(o);continue}if(s===0)continue;let i=o.children.find(a=>a.kind==="contentControlContent");i&&A(i)?n.push(...i.children):n.push(o);}return S(e,n)}function kn(e){let t=new Set,n=new Set,o=i=>{if(i.kind!=="textValue"){if(i.kind==="bookmarkStart"){let a=chunkGWV65NQW_cjs.we(i,"id");a!==void 0&&t.add(a);}if(i.kind==="bookmarkEnd"){let a=chunkGWV65NQW_cjs.we(i,"id");a!==void 0&&n.add(a);}for(let a of i.children)o(a);}};for(let i of e)o(i);let r=new Set([...t].filter(i=>n.has(i)));if(r.size===t.size&&r.size===n.size)return e;let s=i=>{if(i.kind==="textValue")return i;if(i.kind==="bookmarkStart"||i.kind==="bookmarkEnd"){let c=chunkGWV65NQW_cjs.we(i,"id");return c!==void 0&&r.has(c)?i:null}let a=[],l=false;for(let c of i.children){let p=s(c);if(p===null){l=true;continue}p!==c&&(l=true),a.push(p);}return l?S(i,a):i};return e.map(i=>s(i)??i)}function Nn(e,t,n){let o=e.parts.get(t.partName);if(!o)return {ok:false,reason:"unknown-part"};if(t.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let r=t.paragraphIds[0],s=t.paragraphIds[t.paragraphIds.length-1],i=new Map;for(let d of [r,s]){let m=de(o.root,d);if(!m)return {ok:false,reason:"empty-range"};for(let u of m.children)u.kind==="contentControl"&&i.set(u.id,Ge(u));}let a=o,l=de(a.root,s);if(!l)return {ok:false,reason:"empty-range"};let c=chunkGWV65NQW_cjs.Ge(l);if(t.endOffset<c){let d=chunkGWV65NQW_cjs.Wg(a,{op:"deleteText",paragraphId:s,start:t.endOffset,end:c},{deferValidation:true});if(!d.ok)return {ok:false,reason:"trim-refused"};a=d.part;}if(t.startOffset>0){let d=chunkGWV65NQW_cjs.Wg(a,{op:"deleteText",paragraphId:r,start:0,end:t.startOffset},{deferValidation:true});if(!d.ok)return {ok:false,reason:"trim-refused"};a=d.part;}let p=xn(a);if(!p)return {ok:false,reason:"unknown-part"};let h={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},x=[];if(He(p.children,h,x),x.length===0)return {ok:false,reason:"empty-range"};if(x.length>gn)return {ok:false,reason:"resource-limit"};let R=x.map(d=>We(d)).filter(d=>d!==null).map(d=>d.kind!=="paragraph"||d.id!==r&&d.id!==s?d:wn(d,i));R=[...Cn(R)],R=[...kn(R)];let v=je(R,"footnoteReference"),k=je(R,"endnoteReference"),J=v.size>0?chunkGWV65NQW_cjs.Me(e,"footnote"):null,Q=k.size>0?chunkGWV65NQW_cjs.Me(e,"endnote"):null,Ke=(d,m)=>{if(!d||!A(d.root))return [];let u=[];for(let O of d.root.children){if(!A(O)||O.kind!=="note")continue;let E=chunkGWV65NQW_cjs.we(O,"id"),g=chunkGWV65NQW_cjs.we(O,"type");if(g==="separator"||g==="continuationSeparator"){u.push(O);continue}if(E!==void 0&&m.has(E)){let U=We(O);U&&A(U)&&u.push(U);}}return u},qe=Ke(J,v),Ye=Ke(Q,k),Bt=[...qe,...Ye],Xe=[...R,...Bt],Je=new Set;Ue(Xe,Je);let D=_t(e,e.mainDocumentPart),pe=ze(D,Je),me=new Set;Ve(Xe,me),Ve(pe,me);let C=At(e,e.mainDocumentPart,me),ue=new Set;Ue([...C.nums,...C.abstracts],ue);for(let d of [...C.nums,...C.abstracts])P(d,m=>{if(m.kind!=="textValue"&&(m.localName==="styleLink"||m.localName==="numStyleLink")&&m.namespaceUri===chunkGWV65NQW_cjs.ca){let u=chunkGWV65NQW_cjs.we(m,"val");u&&ue.add(u);}});let Ut=ze(D,ue).filter(d=>!pe.includes(d)),Vt=[...pe,...Ut],B=$t(e,e.mainDocumentPart),Qe=Vt.map(d=>_(d,B)),fe=D.docDefaults?_(D.docDefaults,B):null;R=R.map(d=>_(d,B));let ye=qe.map(d=>_(d,B)),he=Ye.map(d=>_(d,B)),Ze=new Set;ce(R,Ze);let et=chunkGWV65NQW_cjs.Wb(e,o.name).filter(d=>Ze.has(d.id)),tt=new Map,nt=0,ot=d=>{let m=new Set;for(let u of d){if(u.targetMode==="External")continue;let O=chunkGWV65NQW_cjs.w(u.ownerPart,u.rawTarget);if(!O.ok){m.add(u.id);continue}if((chunkGWV65NQW_cjs.Xb(e,O.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let g=e.partBytes.get(O.partName)??e.partBytes.get(O.partName.replace(/^\//,""));g?(tt.set(O.partName,g),nt+=g.byteLength):m.add(u.id);continue}m.add(u.id);}return m},ge=ot(et),xe=(d,m)=>{if(d.kind==="textValue")return d;if(d.kind==="drawing"){let E=new Set;ce([d],E);for(let g of E)if(m.has(g))return null;return d}let u=[],O=false;for(let E of d.children){let g=xe(E,m);if(g===null){O=true;continue}g!==E&&(O=true),u.push(g);}return O?S(d,u):d};ge.size>0&&(R=R.map(d=>xe(d,ge)).filter(d=>d!==null));let jt=et.filter(d=>!ge.has(d.id)),rt=(d,m)=>{if(!d)return [];let u=new Set;ce(m,u);let O=chunkGWV65NQW_cjs.Wb(e,d.name).filter(g=>u.has(g.id)),E=ot(O);if(E.size>0)for(let g=0;g<m.length;g+=1){let U=xe(m[g],E);U!==null&&(m[g]=U);}return O.filter(g=>!E.has(g.id))},it=rt(J,ye),at=rt(Q,he),T=new Map,st=[],W=(d,m,u)=>{T.set(d.slice(1),chunkGWV65NQW_cjs.Ja(chunkGWV65NQW_cjs.ma(Mt(d,m,u)))),st.push([d,m]);},Z=[...jt],lt=new Set(Z.map(d=>d.id)),ct=9001,ee=(d,m)=>{let u=Ft(lt,ct);ct+=1,lt.add(u),Z.push({ownerPart:"/word/document.xml",id:u,type:d,rawTarget:m,targetMode:"Internal",order:Z.length});},zt=Lt(a,R);if(W("/word/document.xml",Et,zt),D.part&&(Qe.length>0||fe)){let d=S(D.part.root,[...fe?[fe]:[],...Qe]);W("/word/styles.xml",vt,d),ee(De,"styles.xml");}if(C.part&&(C.nums.length>0||C.abstracts.length>0)){let d=S(C.part.root,[...C.abstracts.map(m=>_(m,B)),...C.nums]);W("/word/numbering.xml",St,d),ee(Be,"numbering.xml");}J&&ye.length>0&&(W("/word/footnotes.xml",It,S(J.root,ye)),ee(kt,"footnotes.xml"),it.length>0&&T.set("word/_rels/footnotes.xml.rels",chunkGWV65NQW_cjs.Ja(X(it)))),Q&&he.length>0&&(W("/word/endnotes.xml",Ct,S(Q.root,he)),ee(Nt,"endnotes.xml"),at.length>0&&T.set("word/_rels/endnotes.xml.rels",chunkGWV65NQW_cjs.Ja(X(at))));let Re=new Map;for(let[d,m]of tt){T.set(d.slice(1),m);let u=Dt(d);u&&!Re.has(u)&&Re.set(u,chunkGWV65NQW_cjs.Xb(e,d)??"application/octet-stream");}T.set("word/_rels/document.xml.rels",chunkGWV65NQW_cjs.Ja(X(Z))),T.set("_rels/.rels",chunkGWV65NQW_cjs.Ja(X([{ownerPart:"/",id:"rId1",type:Tt,rawTarget:"word/document.xml",targetMode:"Internal",order:0}])));let Ht=[`<Default Extension="rels" ContentType="${wt}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...Re].map(([d,m])=>`<Default Extension="${chunkGWV65NQW_cjs.N(d)}" ContentType="${chunkGWV65NQW_cjs.N(m)}"/>`)].join(""),Wt=st.map(([d,m])=>`<Override PartName="${chunkGWV65NQW_cjs.N(d)}" ContentType="${chunkGWV65NQW_cjs.N(m)}"/>`).join("");return T.set("[Content_Types].xml",chunkGWV65NQW_cjs.Ja(`<Types xmlns="${hn}">${Ht}${Wt}</Types>`)),{ok:true,bytes:chunkGWV65NQW_cjs.Ma(T),lastMarkCovered:t.lastMarkCovered,blockCount:R.length,mediaBytes:nt}}
2
+ exports.A=Me;exports.B=Le;exports.C=Fe;exports.D=sn;exports.E=Rt;exports.F=Nn;exports.a=Gt;exports.b=ut;exports.c=oe;exports.d=M;exports.e=re;exports.f=ie;exports.g=b;exports.h=Xt;exports.i=L;exports.j=K;exports.k=ae;exports.l=q;exports.m=se;exports.n=ke;exports.o=Ne;exports.p=Te;exports.q=en;exports.r=tn;exports.s=_e;exports.t=yt;exports.u=nn;exports.v=Pe;exports.w=on;exports.x=Y;exports.y=Ae;exports.z=$e;