@docx-editor.dev/core 2.30.0 → 2.31.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 (106) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.ts +16 -25
  3. package/dist/automation.js +1 -1
  4. package/dist/binding.cjs +1 -1
  5. package/dist/binding.d.ts +15 -16
  6. package/dist/binding.js +1 -1
  7. package/dist/bookmark-names-DDuAra_V.d.ts +37 -0
  8. package/dist/{chrome-print-BM3Js-6X.d.ts → chrome-print-BWvaVEhD.d.ts} +318 -33
  9. package/dist/chunk-243W4WW2.cjs +2 -0
  10. package/dist/{chunk-RJCQGJR7.js → chunk-2E2RPEKX.js} +1 -1
  11. package/dist/chunk-4S24UOPG.js +30 -0
  12. package/dist/chunk-5JPIEN54.cjs +3 -0
  13. package/dist/{chunk-KJRTNY2Q.cjs → chunk-5SO5QDMV.cjs} +1 -1
  14. package/dist/{chunk-WF7JZ755.cjs → chunk-6IDOVU6L.cjs} +1 -1
  15. package/dist/chunk-DBOOTED4.cjs +30 -0
  16. package/dist/chunk-EOTAXOJY.cjs +5 -0
  17. package/dist/chunk-FDAKJ2SJ.cjs +30 -0
  18. package/dist/chunk-FNNOJNGY.js +3 -0
  19. package/dist/chunk-FT33HRZP.js +5 -0
  20. package/dist/{chunk-HYASLE2G.cjs → chunk-HC6YNKUI.cjs} +1 -1
  21. package/dist/chunk-HZ66UCIS.js +2 -0
  22. package/dist/{chunk-5RRAZMBU.cjs → chunk-IBRBNT37.cjs} +1 -1
  23. package/dist/chunk-IVIN7X43.js +30 -0
  24. package/dist/chunk-LZY6B6IV.js +4 -0
  25. package/dist/chunk-MOYYRVFV.cjs +2 -0
  26. package/dist/{chunk-YZGUBCHP.js → chunk-N6B3BXCL.js} +1 -1
  27. package/dist/chunk-Q5K2GGNG.js +2 -0
  28. package/dist/chunk-R2XINWVE.js +7 -0
  29. package/dist/chunk-SUEXVBPR.js +1 -0
  30. package/dist/chunk-T2QQHG5C.js +18 -0
  31. package/dist/{chunk-T32MGBJS.js → chunk-VWIJKH4A.js} +1 -1
  32. package/dist/chunk-WO4V6PNS.cjs +18 -0
  33. package/dist/chunk-XMJKFURD.cjs +4 -0
  34. package/dist/{chunk-FLBEJC6X.cjs → chunk-XSTGE3NI.cjs} +1 -1
  35. package/dist/chunk-YQWMI6J5.cjs +7 -0
  36. package/dist/{chunk-WPDD2Y32.js → chunk-ZCJS7D7S.js} +1 -1
  37. package/dist/collaboration/replication.cjs +1 -1
  38. package/dist/collaboration/replication.d.ts +4 -5
  39. package/dist/collaboration/replication.js +1 -1
  40. package/dist/collaboration.d.ts +3 -4
  41. package/dist/contracts/document.d.ts +3 -3
  42. package/dist/contracts/editor.d.ts +8 -9
  43. package/dist/contracts/interaction.d.ts +2 -2
  44. package/dist/contracts/modules.d.ts +12 -13
  45. package/dist/contracts/types.d.ts +2 -2
  46. package/dist/{custom-node-writes-0v0Kgw1T.d.ts → custom-node-writes-TeUvMP13.d.ts} +2 -2
  47. package/dist/{diagnostic-context-CcAO4q1s.d.ts → diagnostic-context-DJ0P1uZE.d.ts} +3 -2
  48. package/dist/{diagnostic-hints-2Bke6H_w.d.ts → diagnostic-hints-C9JlLz1L.d.ts} +1 -1
  49. package/dist/{document-protection-8eyMWIJ0.d.ts → document-protection-C8x3P2J6.d.ts} +1 -1
  50. package/dist/{editor-DaEJd2so.d.ts → editor-B2ShlO23.d.ts} +292 -50
  51. package/dist/{editor-scope-7o9xweiJ.d.ts → editor-scope-C7ke1KJG.d.ts} +57 -4
  52. package/dist/editor.cjs +1 -1
  53. package/dist/editor.css +5 -3
  54. package/dist/editor.d.ts +602 -31
  55. package/dist/editor.js +1 -1
  56. package/dist/export.cjs +2 -2
  57. package/dist/export.d.ts +13 -14
  58. package/dist/export.js +2 -2
  59. package/dist/{font-resolver-CL9BVKZo.d.ts → font-resolver-CWh40DYp.d.ts} +1 -1
  60. package/dist/{headless-document-view-DZQN8Bnx.d.ts → headless-document-view-qOpaCF82.d.ts} +2 -2
  61. package/dist/index.cjs +1 -1
  62. package/dist/index.d.ts +22 -23
  63. package/dist/index.js +1 -1
  64. package/dist/{layout-shaping-cEnVrhWg.d.ts → layout-shaping-CWS3j0Xr.d.ts} +1 -1
  65. package/dist/layout.cjs +1 -1
  66. package/dist/layout.d.ts +87 -22
  67. package/dist/layout.js +1 -1
  68. package/dist/{note-properties-9FH8zAeG.d.ts → note-properties-QsKh24sM.d.ts} +1 -1
  69. package/dist/{omml-equation-DP2WpUbK.d.ts → omml-equation-BsLAa2lX.d.ts} +27 -9
  70. package/dist/output.cjs +1 -1
  71. package/dist/output.d.ts +20 -10
  72. package/dist/output.js +1 -1
  73. package/dist/{protocol-CZ1uUlPO.d.ts → protocol-COZJUKUY.d.ts} +94 -2
  74. package/dist/{review-paragraph-order-CqVelc5A.d.ts → review-paragraph-order-C_QbCKcH.d.ts} +1 -1
  75. package/dist/{semantic-cell-selection-Dr9yxFZt.d.ts → semantic-cell-selection-Cub9FDa8.d.ts} +2 -2
  76. package/dist/{semantic-interaction-Dc3pf3hr.d.ts → semantic-interaction-dApRIYpt.d.ts} +1 -1
  77. package/dist/{semantic-paint-Bz3FBAoH.d.ts → semantic-paint-DLzA8sjP.d.ts} +3 -3
  78. package/dist/{semantic-record-queries-Bx0pl6kL.d.ts → semantic-record-queries-3yp9o11g.d.ts} +1 -1
  79. package/dist/{semantic-records-CjcF26ZL.d.ts → semantic-records-B-akgRch.d.ts} +130 -87
  80. package/dist/store.cjs +1 -1
  81. package/dist/store.d.ts +48 -22
  82. package/dist/store.js +1 -1
  83. package/dist/{tree-package-store-DKhdEVym.d.ts → tree-package-store-B8l8DX3Z.d.ts} +675 -645
  84. package/dist/{tree-session-contract-CwnTEVLF.d.ts → tree-session-contract-DeLRqohz.d.ts} +26 -13
  85. package/dist/{types-barrel-CA0xB8kH.d.ts → types-barrel-CkF2JbU4.d.ts} +1146 -745
  86. package/package.json +2 -2
  87. package/dist/chunk-2PV5L5NJ.js +0 -5
  88. package/dist/chunk-5OTS2EJ7.js +0 -7
  89. package/dist/chunk-5P4223J4.cjs +0 -27
  90. package/dist/chunk-5SPITS5F.js +0 -18
  91. package/dist/chunk-7ATNKARV.js +0 -2
  92. package/dist/chunk-BGCUTKWE.cjs +0 -5
  93. package/dist/chunk-EBCXSH2W.js +0 -3
  94. package/dist/chunk-ERECKTIR.cjs +0 -2
  95. package/dist/chunk-JC47NRJC.cjs +0 -3
  96. package/dist/chunk-NKPUH3QJ.js +0 -1
  97. package/dist/chunk-PF5NJWS3.js +0 -2
  98. package/dist/chunk-PWTRJSES.cjs +0 -18
  99. package/dist/chunk-QFKGI242.cjs +0 -30
  100. package/dist/chunk-RPPV4S6T.cjs +0 -4
  101. package/dist/chunk-UM26GH5B.js +0 -30
  102. package/dist/chunk-VRCZBFLH.js +0 -27
  103. package/dist/chunk-WK5X2MMA.cjs +0 -7
  104. package/dist/chunk-YBMWBXST.cjs +0 -2
  105. package/dist/chunk-ZOS2PM4A.js +0 -4
  106. package/dist/image-resources-Bipz8toD.d.ts +0 -211
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docx-editor.dev/core",
3
- "version": "2.30.0",
3
+ "version": "2.31.0",
4
4
  "description": "Framework-agnostic core for docx-editor.dev: OOXML parse/serialize, the canonical document tree, layout and paint, and the Editor contract the adapters render.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -105,7 +105,7 @@
105
105
  "directory": "packages/core"
106
106
  },
107
107
  "dependencies": {
108
- "@docx-editor.dev/i18n": "^2.30.0",
108
+ "@docx-editor.dev/i18n": "^2.31.0",
109
109
  "bidi-js": "1.1.0",
110
110
  "emf-converter": "2.0.2",
111
111
  "fast-xml-parser": "^5.10.1",
@@ -1,5 +0,0 @@
1
- import {d,f,c}from'./chunk-RJCQGJR7.js';import {d as d$1}from'./chunk-WPDD2Y32.js';import {a as a$1}from'./chunk-T32MGBJS.js';import {T,ua,ja,na,ma,ea,da,ca,aa,ba,Aa,ka,sa,Ba}from'./chunk-PF5NJWS3.js';import {b,a}from'./chunk-YZGUBCHP.js';import {ub,tb,g,nd,Oc,Ta,Ce,Eb,ml,if as _if,ch,Na,Bg,Ag,bd,$j,lj,Hg,og,Ig,hi,gf,Vi,Sc,la,mb,nf,J as J$1,ef,df,rb,dh,Xi,lb,Cd,ki,li,Mg,Th,wa,ya,va,xa,jh,Uc,Wc,Ua,yj,Bj,kk,wb,vb,Rc,Ee,mi,jg,vf,$c,ob,Jd,od,fb,Qc,bf,Kc,yc,Ac,oc}from'./chunk-5SPITS5F.js';import {Schema}from'prosemirror-model';import {EditorState,TextSelection}from'prosemirror-state';import {EditorView}from'prosemirror-view';import {keymap}from'prosemirror-keymap';import {joinBackward,deleteSelection,joinForward,splitBlock,selectTextblockEnd,selectTextblockStart,baseKeymap}from'prosemirror-commands';function J(t){return t.attributes?.val}function W(t){let e=J(t);return e===void 0||!(e==="0"||e==="false"||e==="off")}var Co=/^[0-9A-Fa-f]{6}$/,Do=/^\d{1,6}$/;function Je(t){return t===void 0||t==="auto"?null:Co.test(t)?`#${t}`:null}var Ao={single:"solid",words:"solid",thick:"solid",double:"double",dotted:"dotted",dottedHeavy:"dotted",dash:"dashed",dashedHeavy:"dashed",dashLong:"dashed",dashLongHeavy:"dashed",dotDash:"dashed",dashDotHeavy:"dashed",dotDotDash:"dashed",dashDotDotHeavy:"dashed",wave:"wavy",wavyHeavy:"wavy",wavyDouble:"wavy"},Fo={black:"#000000",blue:"#0000ff",cyan:"#00ffff",darkBlue:"#000080",darkCyan:"#008080",darkGray:"#808080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",green:"#00ff00",lightGray:"#c0c0c0",magenta:"#ff00ff",red:"#ff0000",yellow:"#ffff00",white:"#ffffff"};function Bo(t){return !t||!/^[\w \-.+]{1,64}$/.test(t)?null:`"${t}"`}function Mn(t,e=false){let n=nd(t);return n===null||Math.abs(n)>999999||!e&&n<0?null:n}function Q(t,e=false){let n=Mn(t,e);return n===null?null:`${n/20}pt`}function wn(t){let e=[],n=[],r=null,a=null;for(let o of t)switch(o.localName){case "b":e.push(`font-weight:${W(o)?"bold":"normal"}`);break;case "i":e.push(`font-style:${W(o)?"italic":"normal"}`);break;case "u":{let i=J(o)??"single";if(i==="none"||!W(o))break;n.push("underline"),r=Ao[i]??"solid",a=Je(o.attributes?.color);break}case "strike":W(o)&&n.push("line-through");break;case "dstrike":W(o)&&n.push("line-through");break;case "caps":W(o)&&e.push("text-transform:uppercase");break;case "smallCaps":W(o)&&e.push("font-variant:small-caps");break;case "vertAlign":{let i=J(o);i==="superscript"?e.push("vertical-align:super","font-size:0.75em"):i==="subscript"&&e.push("vertical-align:sub","font-size:0.75em");break}case "color":{let i=Je(J(o));i&&e.push(`color:${i}`);break}case "highlight":{let i=Fo[J(o)??""];i&&e.push(`background-color:${i}`);break}case "sz":{let i=J(o);i!==void 0&&Do.test(i)&&e.push(`font-size:${Number(i)/2}pt`);break}case "rFonts":{let i=Bo(o.attributes?.ascii??o.attributes?.hAnsi);i&&e.push(`font-family:${i}`);break}case "spacing":{let i=Q(J(o),true);i&&e.push(`letter-spacing:${i}`);break}}return n.length>0&&(e.push(`text-decoration-line:${[...new Set(n)].join(" ")}`),r&&e.push(`text-decoration-style:${r}`),a&&e.push(`text-decoration-color:${a}`)),e.join(";")}var Lo={left:"left",start:"left",right:"right",end:"right",center:"center",both:"justify",distribute:"justify"};function Cn(t){let e=[];for(let n of t)switch(n.localName){case "jc":{let r=Lo[J(n)??""];r&&e.push(`text-align:${r}`);break}case "ind":{let r=Q(n.attributes?.left??n.attributes?.start,true),a=Q(n.attributes?.right??n.attributes?.end,true),o=Q(n.attributes?.firstLine),i=Q(n.attributes?.hanging);r&&e.push(`margin-left:${r}`),a&&e.push(`margin-right:${a}`),o?e.push(`text-indent:${o}`):i&&e.push(`text-indent:-${i}`);break}case "spacing":{let r=Q(n.attributes?.before),a=Q(n.attributes?.after);r&&e.push(`margin-top:${r}`),a&&e.push(`margin-bottom:${a}`);let o=Mn(n.attributes?.line),i=n.attributes?.lineRule;o!==null&&i!=="exact"&&i!=="atLeast"?e.push(`line-height:${(o/240).toFixed(3)}`):o!==null&&e.push(`line-height:${o/20}pt`);break}case "shd":{let r=Je(n.attributes?.fill);r&&e.push(`background-color:${r}`);break}case "pageBreakBefore":W(n)&&e.push("break-before:page");break;}return e.join(";")}var M=new Schema({nodes:{doc:{content:"paragraph+"},paragraph:{content:"inline*",group:"block",attrs:{nodeId:{default:null},props:{default:[]}},toDOM:t=>{let e=Cn(t.attrs.props??[]);return ["p",{"data-node-id":String(t.attrs.nodeId??""),...e?{style:e}:{}},0]},parseDOM:[{tag:"p",getAttrs:t=>typeof t=="string"?null:{nodeId:t.getAttribute("data-node-id")||null,props:[]}}]},text:{group:"inline"},tab:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"tab",class:"docx-tab"},"\u2192"],parseDOM:[{tag:'span[data-token="tab"]'}]},hardBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["br"],parseDOM:[{tag:"br"}]},pageBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"page-break",class:"docx-page-break"}],parseDOM:[{tag:'span[data-token="page-break"]'}]},unknownInline:{inline:true,group:"inline",atom:true,selectable:false,draggable:false,attrs:{nodeId:{default:null},label:{default:""}},toDOM:t=>["span",{"data-token":"unknown","data-node-id":String(t.attrs.nodeId??""),contenteditable:"false",class:"docx-unknown-inline",title:String(t.attrs.label||"Content this editor cannot edit yet. It is preserved.")}],parseDOM:[{tag:'span[data-token="unknown"]',getAttrs:t=>typeof t=="string"?false:{nodeId:t.getAttribute("data-node-id")||null,label:""}}]}},marks:{runProps:{attrs:{props:{default:[]}},excludes:"runProps",toDOM:t=>{let e=t.attrs.props??[],n=wn(e);return ["span",{"data-run-props":jo(e),...n?{style:n}:{}},0]},parseDOM:[{tag:"span[data-run-props]",getAttrs:t=>{if(typeof t=="string")return false;let e=Ho(t.getAttribute("data-run-props"));return e?{props:e}:false}}]}}});function jo(t){return JSON.stringify(Array.isArray(t)?t:[])}function Ho(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let n=[];for(let r of e){if(typeof r!="object"||r===null)return null;let a=r;if(typeof a.localName!="string"||a.attributes!==void 0&&(typeof a.attributes!="object"||a.attributes===null))return null;n.push(a.attributes===void 0?{localName:a.localName}:{localName:a.localName,attributes:a.attributes});}return n}catch{return null}}function Ye(t){for(let e of t.marks)if(e.type.name==="runProps")return e.attrs.props??[];return []}function ve(t,e){return JSON.stringify(Te(t))===JSON.stringify(Te(e))}function Te(t){return [...t].map(e=>({localName:e.localName,attributes:Object.fromEntries(Object.entries(e.attributes??{}).sort(([n],[r])=>n<r?-1:1))})).sort((e,n)=>e.localName<n.localName?-1:1)}function Ge(t){if(!t||t.kind==="textValue")return [];let e=[];for(let n of t.children){if(n.kind==="textValue"||n.namespaceUri!==la||n.localName==="rPrChange"||n.localName==="pPrChange")continue;let r={};for(let a of n.attributes)a.namespaceUri===la&&(r[a.localName]=a.value);e.push(Object.keys(r).length>0?{localName:n.localName,attributes:r}:{localName:n.localName});}return e}function Dn(t){return t.kind==="textValue"?"":`${{drawing:"Picture",pict:"Picture",object:"Embedded object",fldSimple:"Field",hyperlink:"Hyperlink",sdt:"Content control",tbl:"Table"}[t.localName]??t.localName} \u2014 preserved, not editable yet`}function B(t){if(t.kind==="textValue")return [];let e=[],n=o=>{if(o.kind!=="run")return;let i=o.children.find(d=>d.kind==="runProperties"),l=Ge(i);for(let d of o.children)if(d.kind!=="runProperties"){if(d.kind==="tab"){e.push({kind:"tab"});continue}if(d.kind==="hardBreak"){e.push(ob(d)?{kind:"pageBreak"}:{kind:"hardBreak"});continue}if(d.kind==="text"){let u="";for(let h of d.children)h.kind==="textValue"&&(u+=h.value);u.length>0&&e.push({kind:"text",text:u,props:l});continue}e.push({kind:"unknown",nodeId:d.id,label:Dn(d),modelLength:d.kind==="drawing"||Jd(d)||od(d)||fb(d)!==null?1:0});}},r=o=>{if(o.kind==="run"){n(o);return}e.push({kind:"unknown",nodeId:o.id,label:Dn(o),modelLength:0});},a=(o,i)=>{for(let l of o)if(!(l.kind==="textValue"||l.kind==="paragraphProperties")&&!(i>=wa)){if(ya(l)&&!va(l.kind)&&i<wa){a(l.children.filter(d=>!jh(l,d)),xa(l,i));continue}if(Uc(l)){let d=Wc(l);d&&a(d,xa(l,i));continue}r(l);}};return a(t.children,0),e}function ae(t){let e=[],n=r=>{if(r.kind!=="textValue"){if(r.kind==="body"){for(let a of r.children)a.kind==="paragraph"&&e.push(a);return}for(let a of r.children)n(a);}};return n(t.root),e}var An=ub(16),Fn=tb();function $o(t,e){let n=Fn.get(t);if(!n){let r=[];Sc([t],r,0),n=Object.freeze(r),Fn.set(t,n,n.length);}for(let r of n)e.push(r);}function L(t){let e=An.get(t);if(e)return e;let n=[];for(let r of Oc(t))if(r.root.kind!=="textValue")for(let a of r.root.children)$o(a,n);return An.set(t,n),n}function V(t){let e=ae(t).map(n=>{let r=n.kind==="textValue"?void 0:n.children.find(o=>o.kind==="paragraphProperties"),a=B(n).map(o=>{switch(o.kind){case "text":return M.text(o.text,o.props.length>0?[M.marks.runProps.create({props:o.props})]:[]);case "tab":return M.node("tab");case "hardBreak":return M.node("hardBreak");case "pageBreak":return M.node("pageBreak");default:return M.node("unknownInline",{nodeId:o.nodeId,label:o.label})}});return M.node("paragraph",{nodeId:n.id,props:Ge(r)},a)});return M.node("doc",null,e.length>0?e:[M.node("paragraph")])}function zo(t,e){let n=[];return t.forEach(r=>{if(r.isText&&r.text){n.push({kind:"text",text:r.text,props:Ye(r)});return}r.type.name==="tab"?n.push({kind:"tab"}):r.type.name==="hardBreak"?n.push({kind:"hardBreak"}):r.type.name==="pageBreak"?n.push({kind:"pageBreak"}):r.type.name==="unknownInline"&&n.push({kind:"unknown",nodeId:String(r.attrs.nodeId??""),label:String(r.attrs.label??""),modelLength:e.has(String(r.attrs.nodeId??""))?1:0});}),n}function D(t){let e="";for(let n of t)n.kind==="text"?e+=n.text:n.kind==="tab"?e+=" ":n.kind==="hardBreak"?e+=`
2
- `:n.kind==="pageBreak"?e+=mb:n.modelLength===1&&(e+=nf);return e}function j(t){let e=[],n=0;for(let r of t)r.kind==="text"?n+=r.text.length:r.kind==="tab"||r.kind==="hardBreak"||r.kind==="pageBreak"?n+=1:(e.push(`${r.nodeId}@${n}`),n+=r.modelLength);return e}function Uo(t,e){if(t===e)return null;let n=0,r=Math.min(t.length,e.length);for(;n<r&&t[n]===e[n];)n+=1;let a=t.length,o=e.length;for(;a>n&&o>n&&t[a-1]===e[o-1];)a-=1,o-=1;return {start:n,endBefore:a,endAfter:o}}function Bn(t){let e=[];for(let n of t)if(n.kind==="text")for(let r=0;r<n.text.length;r+=1)e.push(n.props);else n.kind==="tab"||n.kind==="hardBreak"||n.kind==="pageBreak"?e.push(e[e.length-1]??[]):n.kind==="unknown"&&n.modelLength===1&&e.push([]);return e}function Wo(t,e,n,r,a){let o=[],i=D(e),l=D(n),d=Uo(i,l),u=[],h=0,m=false;for(let y of e){if(y.kind!=="unknown"){h+=y.kind==="text"?y.text.length:1;continue}let p=h;y.modelLength===1&&d&&(d.start<h+1&&d.endBefore>h&&(m=true),d.endBefore<=h&&(p+=d.endAfter-d.endBefore)),u.push(`${y.nodeId}@${p}`),h+=y.modelLength;}if(m||JSON.stringify(u)!==JSON.stringify(j(n)))return {ok:false,reason:"unknown-content-moved",detail:t};if(ve(r,a)||o.push({op:"setParagraphProperties",paragraphId:t,properties:Te(a)}),d&&(d.endBefore>d.start&&o.push({op:"deleteText",paragraphId:t,start:d.start,end:d.endBefore}),d.endAfter>d.start)){let y=l.slice(d.start,d.endAfter),p=d.start,g="",P=()=>{g.length!==0&&(o.push({op:"insertText",paragraphId:t,offset:p,text:g}),p+=g.length,g="");};for(let O of y)O===" "?(P(),o.push({op:"insertTab",paragraphId:t,offset:p}),p+=1):O===`
3
- `?(P(),o.push({op:"insertHardBreak",paragraphId:t,offset:p}),p+=1):O===mb?(P(),o.push({op:"insertPageBreak",paragraphId:t,offset:p}),p+=1):g+=O;P();}if(!d){let y=Bn(e),p=Bn(n),g=0;for(;g<p.length;){if(ve(y[g]??[],p[g])){g+=1;continue}let P=g,O=p[g];for(;g<p.length&&ve(p[g],O)&&!ve(y[g]??[],p[g]);)g+=1;o.push({op:"setRunProperties",paragraphId:t,start:P,end:g,properties:Te(O)});}}return {ok:true,ops:o}}function Ke(t,e){let n=ae(t),r=new Set;for(let l of n)for(let d of B(l))d.kind==="unknown"&&d.modelLength===1&&r.add(d.nodeId);let a=l=>zo(l,r),o=[];if(e.forEach(l=>{l.type.name==="paragraph"&&o.push(l);}),o.length!==e.childCount)return {ok:false,reason:"unsupported-node"};let i=o.length-n.length;if(i===0){let l=[];for(let[d,u]of o.entries()){let h=n[d];if(u.attrs.nodeId!==h.id)return {ok:false,reason:"paragraph-reordered",detail:String(u.attrs.nodeId)};let m=Wo(h.id,B(h),a(u),Ge(h.kind==="textValue"?void 0:h.children.find(y=>y.kind==="paragraphProperties")),u.attrs.props??[]);if(!m.ok)return m;l.push(...m.ops);}return {ok:true,ops:l}}return i===1?Jo(n,o,a):i===-1?Yo(n,o,a):{ok:false,reason:"paragraph-count-unexplained",detail:String(i)}}function Jo(t,e,n){for(let r=0;r<t.length;r+=1){let a=t[r],o=e[r],i=e[r+1];if(!o||!i||o.attrs.nodeId!==a.id)continue;let l=i.attrs.nodeId;if(l!==null&&l!==a.id)continue;let d=n(o),u=n(i),h=B(a),m=D(d);if(m+D(u)===D(h)&&JSON.stringify(j([...d,...u]))===JSON.stringify(j(h))&&Ln(t,e,r,n)&&_n(t,e,r+1,r+2,n))return {ok:true,ops:[{op:"splitParagraph",paragraphId:a.id,offset:m.length}]}}return {ok:false,reason:"split-not-clean"}}function Yo(t,e,n){for(let r=0;r+1<t.length;r+=1){let a=t[r],o=t[r+1],i=e[r];if(!i||i.attrs.nodeId!==a.id)continue;let l=[...B(a),...B(o)],d=n(i);if(D(d)===D(l)&&JSON.stringify(j(d))===JSON.stringify(j(l))&&Ln(t,e,r,n)&&_n(t,e,r+2,r+1,n))return {ok:true,ops:[{op:"joinParagraphs",firstId:a.id,secondId:o.id}]}}return {ok:false,reason:"join-not-clean"}}function Ln(t,e,n,r){for(let a=0;a<n;a+=1){let o=e[a],i=t[a];if(!o||o.attrs.nodeId!==i.id||D(r(o))!==D(B(i))||JSON.stringify(j(r(o)))!==JSON.stringify(j(B(i))))return false}return true}function _n(t,e,n,r,a){for(let o=0;n+o<t.length;o+=1){let i=t[n+o],l=e[r+o];if(!l||l.attrs.nodeId!==i.id||D(a(l))!==D(B(i))||JSON.stringify(j(a(l)))!==JSON.stringify(j(B(i))))return false}return true}function Go(t,e){return Ta(t,e)!==null}function Xe(t,e,n){if(!n||n.created.length>0||n.deleted.length>0||n.splitJoin.length>0)return V(e);let r=new Map;t.forEach(d=>{let u=d.attrs.nodeId;typeof u=="string"&&r.set(u,d);});let a=new Set(n.dirty),o=ae(e);if(o.length!==t.childCount)return V(e);let i=V(e),l=[];for(let[d,u]of o.entries()){let h=r.get(u.id);l.push(h&&!a.has(u.id)?h:i.child(d));}return M.node("doc",null,l)}var Ko=8*1024*1024;function jn(){let t=new WeakMap;return e=>{let n=t.get(e);if(n)return n.slice();let r=Ee(e);return t=new WeakMap,r.byteLength<=Ko&&t.set(e,r.slice()),r}}function $n(t){return L(t).map(e=>Vi(t,e.id)??"").join(`
4
- `)}var Xo=64,Hn=new WeakMap;function Qe(t,e=0){if(e>Xo)return false;let n=Hn.get(t);if(n!==void 0)return n;let r=false;for(let a of t.children)if(a.kind!=="textValue"&&(a.kind==="commentRangeStart"||a.kind==="commentReference"||Qe(a,e+1))){r=true;break}return rb(t)&&Hn.set(t,r),r}var Qo="/word/numbering.xml";function Vo(t,e,n){if(t.relationships!==e.relationships||t.contentTypes!==e.contentTypes||t.parts.size!==e.parts.size)return false;for(let[r,a]of e.parts)if(!(r===n||r===Qo)&&t.parts.get(r)!==a)return false;return true}function qo(t,e){let n=t.kind==="revision"?t.ranges[0]??null:t.range;if(!n)return null;let r=e.get(n.start.paragraphId);return r===void 0?null:r}function zn(t,e,n){for(let a of e)if(a.ranges.length===0)return false;let r=new Set;for(let a of t)a.kind!=="revision"||a.ranges.length>0||Wn(a,n)||r.add(yj(a));for(let a of e)if(r.has(yj(a)))return false;return true}function Un(t,e,n,r){let a=e.get(n);if(a===void 0)return [...t];let o=[],i=null;for(let l of t){if(l.kind==="revision"&&Wn(l,n)){i===null&&(i=o.length);continue}if(i===null){let d=qo(l,e);d!==null&&d>a&&(i=o.length);}o.push(l);}if(i===null&&(i=o.length),r.length>0){let l=r.length<2?[...r]:[...r].sort((d,u)=>Bj(d,e)-Bj(u,e));o.splice(i,0,...l);}return kk(o)}function Wn(t,e){return t.ranges.length>0&&t.ranges.every(n=>n.start.paragraphId===e&&n.end.paragraphId===e)}function Zo(t,e){return t.range?t.range.start.paragraphId===e||t.range.end.paragraphId===e:false}function er(t,e){return t.revisionKind==="structural"&&t.ranges.some(n=>n.start.paragraphId===e||n.end.paragraphId===e)}function tr(t,e){return t.ranges.length===0||!t.ranges.some(r=>r.start.paragraphId===e||r.end.paragraphId===e)?false:!t.ranges.every(r=>r.start.paragraphId===e&&r.end.paragraphId===e)}function Jn(t,e,n){return t.fromRevision!==e.bodyRevision||n.currentPackageRevision!==e.packageRevision+1&&(n.changePackage!==n.currentPackage||!Vo(e.pkg,n.currentPackage,n.part.name))||t.story!==void 0&&t.story.kind!=="body"||t.impact==="global"?false:e.commentsPart===n.commentsPart&&e.commentsExtendedPart===n.commentsExtendedPart}function Yn(t,e){let n=Ua(t,e);if(!n)return false;let r=n.children.findIndex(o=>o.id===e),a=n.children[r-1];return a?.kind==="paragraph"&&$j({...t,root:a}).some(o=>o.paragraphMark)}function Gn(t,e,n,r){if(!Jn(t,e,r)||t.splitJoin.length!==1)return false;let a=t.splitJoin[0],o,i;if("split"in a){if(t.deleted.length>0||t.created.length!==1||t.created[0]!==a.split.tail)return false;o=i=[a.split.from,a.split.tail];}else {if(t.created.length>0||t.deleted.length!==1||t.deleted[0]!==a.join.removed)return false;o=[a.join.kept,a.join.removed],i=[a.join.kept];}for(let d of i){let u=Ta(r.part,d);if(!u||u.kind!=="paragraph"||$j({...r.part,root:u}).length>0)return false}if(Yn(r.part,i[0]))return false;let l=d=>d!==void 0&&o.includes(d);for(let d of n){let u=d.kind==="revision"?d.ranges:d.range?[d.range]:[];for(let h of u)if(l(h.start.paragraphId)||l(h.end.paragraphId))return false}return true}function Kn(t,e,n,r){if(!Jn(t,e,r)||t.dirty.length!==1||t.created.length>0||t.deleted.length>0||t.splitJoin.length>0)return null;let{part:a}=r,o=t.dirty[0],i=Ta(a,o);if(!i||i.kind!=="paragraph"||t.impact!=="text-local"&&($j({...a,root:i}).length>0||t.impact==="flow-structural"&&Ua(a,o)?.localName!=="body")||Yn(a,o))return null;for(let l of n){if(l.kind==="comment"){if(Zo(l,o))return null;continue}if(l.kind==="custom"){if(l.range?.start.paragraphId===o)return null;continue}if(er(l,o)||tr(l,o))return null}return o}var Vn=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u,nr=["ascii","hAnsi","cs","eastAsia"],or=["asciiTheme","hAnsiTheme","cstheme","eastAsiaTheme"],rr=128,ar=/[\u0000-\u001F\u007F-\u009F]/;function A(t){return t.kind!=="textValue"}function q(t,e){return t.attributes.find(n=>n.localName===e)?.value}function qn(t,e){let n=new Map;for(let a of t)for(let o of a.children)if(A(o))for(let[i,l]of to(o,e))n.has(i)||n.set(i,l);let r=[...n.values()];return r.sort((a,o)=>a<o?-1:a>o?1:0),r}var Ve=new WeakMap,Zn=16,eo=32;function to(t,e,n=0){let r=e?.major??null,a=e?.minor??null,o=e?.majorEastAsia??null,i=e?.minorEastAsia??null,l=e?.majorBidi??null,d=e?.minorBidi??null,u=Ve.get(t);if(u&&u.major===r&&u.minor===a&&u.majorEastAsia===o&&u.minorEastAsia===i&&u.majorBidi===l&&u.minorBidi===d)return u.byFold;if(t.children.length>=Zn&&n<eo&&t.localName!=="rFonts"){let p=new Map;for(let g of t.children)if(A(g))for(let[P,O]of to(g,e,n+1))p.has(P)||p.set(P,O);return Ve.set(t,{major:r,minor:a,majorEastAsia:o,minorEastAsia:i,majorBidi:l,minorBidi:d,byFold:p}),p}let h=new Map,m=p=>{if(!p||!Vn.test(p))return;let g=p.toLowerCase();h.has(g)||h.set(g,p);},y=[t];for(;y.length>0;){let p=y.pop();if(A(p)){if(p.localName==="rFonts"){for(let g of nr)m(q(p,g));if(e)for(let g of or)m(Ba(q(p,g),e));}for(let g=p.children.length-1;g>=0;g-=1)y.push(p.children[g]);}}return Ve.set(t,{major:r,minor:a,majorEastAsia:o,minorEastAsia:i,majorBidi:l,minorBidi:d,byFold:h}),h}function no(t){let e=new Map;for(let r of t)for(let a of r.children)if(A(a))for(let[o,i]of oo(a))e.has(o)||e.set(o,i);let n=[...e.values()];return n.sort((r,a)=>r<a?-1:r>a?1:0),n}var Xn=new WeakMap,sr=new Map;function oo(t,e=0){let n=Xn.get(t);if(n)return n;let r=i=>{let l=i.size===0?sr:i;return Xn.set(t,l),l},a=new Map;if(t.children.length>=Zn&&e<eo&&t.localName!=="sym"){for(let i of t.children)if(A(i))for(let[l,d]of oo(i,e+1))a.has(l)||a.set(l,d);return r(a)}let o=[t];for(;o.length>0;){let i=o.pop();if(A(i)){if(i.localName==="sym"&&i.namespaceUri===la){let l=i.attributes.find(u=>u.localName==="font"&&(u.namespaceUri===la||u.namespaceUri===""))?.value,d=c(l);d!==null&&!a.has(d.toLowerCase())&&a.set(d.toLowerCase(),d);}for(let l=i.children.length-1;l>=0;l-=1)o.push(i.children[l]);}}return r(a)}function ro(t){let e=[...t];for(;e.length>0;){let n=e.pop();if(A(n)){if(n.localName==="t"&&n.namespaceUri===la){for(let r of n.children)if(!A(r)&&r.value.length>0)return true;continue}for(let r of n.children)e.push(r);}}return false}var ir=new Set(["paragraph","character","table","numbering"]),lr=/^[0-9A-Fa-f]{6}$/,cr=16,Qn=new Map([["normal",0],["title",1],["subtitle",2],["heading 1",11],["heading 2",12],["heading 3",13],["heading 4",14],["heading 5",15],["heading 6",16],["heading 7",17],["heading 8",18],["heading 9",19]]);function ao(t){return t.children}function qe(t,e){for(let n of ao(t))if(A(n)&&n.localName===e)return n}function dr(t){return Qn.get(t.name.toLowerCase())??Qn.get(t.styleId.toLowerCase())??Number.MAX_SAFE_INTEGER}function Ze(t){return t===void 0||t.length===0||t.length>rr||ar.test(t)?null:t}function so(t,e){if(!t)return [];let n=new Map;for(let o of t.children){if(!A(o)||o.localName!=="style")continue;let i=Ze(q(o,"styleId"));i!==null&&!n.has(i)&&n.set(i,o);}let r=o=>{let i=false,l=false,d=null,u=false,h=false,m=new Set,y=o;for(let P=0;P<cr&&y!==null&&!m.has(y);P+=1){m.add(y);let O=n.get(y);if(!O)break;let b=qe(O,"rPr");for(let v of b?ao(b):[]){if(!A(v))continue;let T=q(v,"val"),E=T!=="0"&&T!=="false"&&T!=="off";v.localName==="b"&&!u?(i=E,u=true):v.localName==="i"&&!h?(l=E,h=true):v.localName==="color"&&d===null&&T&&lr.test(T)&&(d=T);}let R=qe(O,"basedOn");y=R?Ze(q(R,"val")):null;}let p=e?.(o),g=p?.fontFamily??null;return {fontFamily:g!==null&&Vn.test(g)?g:null,fontSizePt:p?.fontSizeHalfPoints!=null&&p.fontSizeHalfPoints>0?p.fontSizeHalfPoints/2:null,bold:i,italic:l,color:d}},a=[];for(let[o,i]of n){let l=q(i,"type");if(l===void 0||!ir.has(l))continue;let d=qe(i,"name"),u=Ze(d?q(d,"val"):void 0);a.push({styleId:o,name:u??o,type:l,preview:r(o)});}return a.map((o,i)=>({entry:o,index:i,rank:dr(o)})).sort((o,i)=>o.rank-i.rank||o.index-i.index).map(o=>o.entry)}var ur=128,pr=/[\u0000-\u001F\u007F-\u009F]/,fr=/[\u0000-\u001F\u007F-\u009F]/g,mr=200;function tt(t){return t.kind!=="textValue"}function io(t,e){for(let n of t.children)if(tt(n)&&n.localName===e)return n}function et(t,e){return t.attributes.find(n=>n.localName===e)?.value}function gr(t){let e=new Map;if(!t)return e;for(let n of t.children){if(!tt(n)||n.localName!=="style"||et(n,"type")!=="paragraph")continue;let r=et(n,"styleId");if(r===void 0||r.length===0||r.length>ur||pr.test(r))continue;let a=a$1(n);a!==null&&e.set(r,a);}return e}function nt(t){let e=io(t,"pPr"),n=e?io(e,"pStyle"):void 0;return n?et(n,"val"):void 0}function lo(t,e){let n=gr(e);if(n.size===0)return [];let r=[];for(let a of ae(t)){if(!tt(a))continue;let o=nt(a);if(o===void 0)continue;let i=n.get(o);if(i===void 0)continue;let l=Vi(t,a.id)??"",d=a.kind==="paragraph"?Xi(a,l):l,u=lb(d).replace(fr," ").trim().slice(0,mr);u.length!==0&&r.push({text:u,level:i,blockId:a.id});}return r}function yr(t,e,n){let r=new Map,a=n(t);for(let o of a){let i=r.get(o.hostParagraphId);i?i.push(o):r.set(o.hostParagraphId,[o]);}return r}function hr(t,e,n){let r=[];for(let a of Rc(t.root)){let o=e.get(a.id);if(o)for(let i of o)r.push(i);}return r}function co(t,e,n=mi){let r=[],a=new Map;for(let o of t){if(r.push(o),o.scope?.kind==="note")continue;let i=a.get(o.part);i||(i=yr(o.part,e,n),a.set(o.part,i));for(let l of hr(o,i)){let d=o.scope;r.push({part:o.part,root:l.root,scope:{kind:"frame",id:l.root.id,drawingNodeId:l.drawingNodeId,hostParagraphId:l.hostParagraphId,...d?.kind==="headerFooter"?{owner:d}:{}}});}}return r}var Ie=48,xr=/[\u0000-\u001F\u007F-\u009F]/g;function kr(t){let e=[],n=jg(t),r=new Map;for(let a of n.segments)vf(a.node)&&r.set(a.node.id,a.formatRunIds??[]);return $c(t.children,0,a=>{if(a.kind==="run"){e.push({id:a.id,start:n.spanOf(a)?.start??0});return}if(vf(a))for(let o of r.get(a.id)??[]){let i=n.spanOf(o);i&&e.push({id:o,start:i.start});}},{descendRevisions:true}),e}function Pr(t){let e=Qc(t);return e?[{part:t,root:e}]:[]}function Or(t,e){let n=[];for(let r of ["header","footer"])for(let a of t){let o=r==="header"?a.headers:a.footers;for(let[i,l]of o){if(!bf(a,i)||e.has(l.part))continue;e.add(l.part);let d=Oc(l.part).find(u=>u.kind===r);d&&n.push({part:l.part,root:d.root,scope:{kind:"headerFooter",rId:l.rId}});}}return n}function uo(t,e,n){if(!t)return [];let r=[];for(let a of Kc(t.root)){let o=yc(a);!Ac(a)||o===null||!n.has(o)||r.push({part:t,root:a,scope:{kind:"note",id:oc(e,o)}});}return r}function Sr(t,e){let n=Pr(t);if(e){let r=new Set;for(let a of Or(e.headerFooterBySection,r))n.push(a);for(let a of uo(e.footnotes,"footnote",e.referencedNoteIds.footnote))n.push(a);for(let a of uo(e.endnotes,"endnote",e.referencedNoteIds.endnote))n.push(a);}return co(n)}function po(t,e){if(t.length===0)return {index:0,offset:e};for(let n=t.length-1;n>=0;n-=1){let r=t[n].start;if(e>=r)return {index:n,offset:e-r}}return {index:0,offset:e}}function br(t,e,n){let r=t.findIndex(a=>a.id===e);return r<0?null:{index:r,offset:n}}function ot(t,e){return lb(t).replace(xr," ").slice(0,e)}var Rr=1e3;function fo(t,e,n={},r){let a=n.limit!==void 0&&Number.isInteger(n.limit)&&n.limit>0?Math.min(n.limit,2e3):2e3,o={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.wholeWord===void 0?{}:{wholeWord:n.wholeWord}},i=e.slice(0,Rr),l=i.map(()=>({matches:[],truncated:false})),d=i.map((h,m)=>sa(h)?m:-1);if(d=d.filter(h=>h>=0),d.length===0)return l;let u=n.stories==="body"?void 0:r;for(let h of Sr(t,u)){let m=0;for(let y of Rc(h.root)){if(y.kind!=="paragraph")continue;let p=m;m+=1;let g=Vi(h.part,y.id)??"",P=d$1(y,g);if(P.text.length===0)continue;let O=null,b=false;for(let R of d){let v=l[R],T=a-v.matches.length,E=P.findOccurrences(i[R],Math.max(T,1),o);if(T===0&&E.matches.length>0){v.truncated=true,b=true;continue}for(let I of E.matches){let w=I.start+I.length;O??=kr(y);let _=P.resultRunAddressAt(I.start),Z=_?br(O,_.runId,_.offset)??po(O,I.rawStart):po(O,I.rawStart);v.matches.push({blockId:y.id,start:I.rawStart,length:I.rawEnd-I.rawStart,paragraphIndex:p,runIndex:Z.index,runOffset:Z.offset,...h.scope?{scope:h.scope}:{},text:ot(P.displaySlice(I.start,w),256),contextBefore:ot(P.displaySlice(Math.max(0,I.start-Ie),I.start),Ie),contextAfter:ot(P.displaySlice(w,w+Ie),Ie)});}E.truncated&&(v.truncated=true,b=true);}if(b&&(d=d.filter(R=>!l[R].truncated)),d.length===0)return l}}return l}var vr=32;function mo(t){let e=null;return((n,r)=>{let a=t.revision(),o=typeof n!="string",i=`${r?.matchCase===true?"c":""}${r?.wholeWord===true?"w":""}`,l=`${r?.limit??""}:${r?.stories??"all"}`,d=JSON.stringify([i,l,n]);e?.revision!==a&&(e={revision:a,results:new Map});let u=e.results.get(d);if(u)return u;let h=t.bodyPart(),m=t.currentPackage(),y={footnote:new Set,endnote:new Set};for(let P of dh(h))y[P.noteKind].add(P.noteId);let p=fo(h,o?n:[n],r,{headerFooterBySection:t.headerFooterBySection(),footnotes:ch(m,"footnote")??null,endnotes:ch(m,"endnote")??null,referencedNoteIds:y}),g=o?p:p[0];return e.results.size>=vr&&e.results.delete(e.results.keys().next().value),e.results.set(d,g),g})}var Tr=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"];function se(t,e=null,n=null){return Aa(t,e,n)}function go(t){let e=Cd(t),n=[];for(let r of Tr){let a=e.get(r);if(!a)return [];n.push({slot:r,hex:a});}return n}var yo=new WeakMap;function at(t){let e=yo.get(t);if(e!==void 0)return e;let n=wb(t),r=n===null||!vb(n)?null:n;return yo.set(t,r),r}var rt=class{#e;#t;constructor(e,n){this.#e=e,this.#t=n;}get size(){return this.#e.size}get(e){if(this.#e.has(e))return this.#t.find(n=>e.startsWith(`${n.name}#`))}has(e){return this.get(e)!==void 0}*entries(){for(let e of this.#e.keys()){let n=this.get(e);n&&(yield [e,n]);}}keys(){return this.#e.keys()}*values(){for(let[,e]of this.entries())yield e;}[Symbol.iterator](){return this.entries()}forEach(e,n){for(let[r,a]of this.entries())e.call(n,a,r,this);}};function ho(t,e){return Object.freeze({...t,partByNode:new rt(t.ordinalByNode,e)})}function xo(t){let e=new Map,n=new Map,r=new Map,a=new Set,o=new Map,i=new Map,l=0;for(let d of t)for(let u of L(d)){r.set(u.id,l),o.set(u.id,d),l+=1;let h=at(u);if(h===null)continue;e.set(u.id,h);let m=h.toUpperCase(),y=i.get(m);y?(y.push(u.id),a.add(m)):(i.set(m,[u.id]),n.set(m,u.id));}return Object.freeze({paraIdByNode:e,nodeByParaId:n,ordinalByNode:r,ambiguousParaIds:a,partByNode:o,claimantsByParaId:i})}function ko(t,e){let n=t.indexOf("#");if(n<=0)return null;let r=t.slice(0,n),a=e.body.name===r?e.body:void 0;a??=e.openStories.find(l=>l.name===r);let o=a?void 0:e.otherStories.find(l=>l.name===r);if(a??=o?e.normalize(o):void 0,!a)return null;let i=Ta(a,t);return i?.kind==="paragraph"?at(i):null}var Po={committed:false,rejected:false,opCount:0};function H(t,e){return e===void 0?{committed:false,rejected:true,opCount:t}:{committed:false,rejected:true,opCount:t,reason:e}}function Oo(t,e,n={}){let r=e.filter(h=>h.ops.length>0),a=n.partOps??[],o=[...r,...a].reduce((h,m)=>h+m.ops.length,0);if(o===0)return n.packageEdits?.length?H(0,"invalidArgs"):Po;if([...r,...a].some(h=>h.ops.some(Mg))||[...r,...a].some(h=>h.ops.some(Th)))return H(o,"invalidArgs");let[i,...l]=r,d=[];for(let h of l){let m=t.partFor(h.scope);if(!m)return H(o,"unknown-part");d.push({partName:m.name,ops:h.ops});}let u=t.transact(i?.scope??{kind:"body"},h=>{for(let m of n.packageEdits??[])h.applyPackage(m);for(let m of i?.ops??[])h.apply(m);for(let m of d)for(let y of m.ops)h.applyTo(m.partName,y);for(let m of a)for(let y of m.ops)h.applyTo(m.partName,y);},n);return u.ok?{committed:true,rejected:false,opCount:o}:H(o,u.reason)}function So(t,e,n,r,a$1,o){let i=o.partOps??[],l=e.length+i.reduce((m,y)=>m+y.ops.length,0);if(l===0&&!o.packageEdits?.length)return Po;if(i.some(m=>m.ops.some(y=>Mg(y)||Th(y))))return H(l,"invalidArgs");let d=e.filter(m=>Mg(m)||Th(m)).length;if(d>0){if(i.length||o.packageEdits?.length||d!==e.length||e.length!==1)return H(e.length,"invalidArgs");let m=t.applyLifecycleOp(e[0],{actorId:o.actorId});return m.ok?{committed:true,rejected:false,opCount:1}:H(1,m.detail??m.reason)}let u=o.recordsHistory===false&&o.actorId&&o.operationId?t.partFor(a$1)?.name:void 0,h=t.transact(a$1,m=>{n!==void 0&&m.selectionBefore(n),r!==void 0&&m.selectionAfter(r);for(let y of o.packageEdits??[])m.applyPackage(y);for(let y of e)m.apply(y);for(let y of i)for(let p of y.ops)m.applyTo(y.partName,p);u&&m.applyPackage(y=>a(y,u,e));},o);return h.ok?{committed:true,rejected:false,opCount:l}:H(l,h.reason)}var Ir=Object.freeze([]);function Nr(t,e={}){return Er(Ce(t),e)}function Er(t,e={}){if(!t.ok)return t;let n=t.package,r=n.parts.get(n.mainDocumentPart);if(!r)return {ok:false,reason:"no-main-document-tree",detail:n.mainDocumentPart};let a=Eb(r),o=new T(n,ua(n,a),e.contentLockPolicy?{contentLockPolicy:e.contentLockPolicy}:{}),i=null,l=null,d$1=null,u=null,h=null;o.subscribe(s=>{u=s,h=o.currentPackage();});let m=()=>o.bodyStore(),y=()=>o.currentPackage(),p=jn(),g=Object.freeze({kind:"body"}),P=(s,c)=>{let f=c?.find(k=>k.type==="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");if(!f)return;let x=J$1(f);return x.mode==="Internal"&&x.target.ok?s.parts.get(x.target.partName):void 0},O=(s,c,f)=>{if(s.mainRelationships!==f||s.settingsPart!==P(c,f))return false;for(let x of s.resolution)for(let k of [x.headers,x.footers])for(let S of k.values())if(c.parts.get(S.partName)!==S.part)return false;return true},b$1=()=>{let s=y(),c=s.relationships.get(s.mainDocumentPart);if(i&&u&&h===s&&O(i,s,c)&&i.packageRevision===u.fromRevision&&o.packageRevision===u.toRevision&&u.story?.kind==="body"&&u.impact==="text-local"&&u.created.length===0&&u.deleted.length===0&&u.splitJoin.length===0&&(i={...i,packageRevision:o.packageRevision,pkg:s,mainRelationships:c,settingsPart:P(s,c)}),!i||i.packageRevision!==o.packageRevision||i.pkg!==s){let f=ef(s);i={packageRevision:o.packageRevision,pkg:s,mainRelationships:c,settingsPart:P(s,c),resolution:f,parts:df(f)};}return i},R="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",v="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",T$1=null,E=()=>{let s=y(),c=(s.relationships.get(s.mainDocumentPart)??[]).find(k=>k.type===R),f;if(c){let k=J$1(c);k.mode==="Internal"&&k.target.ok&&(f=s.parts.get(k.target.partName));}f??=s.parts.get("/word/styles.xml");let x=f?.root??null;return x!==T$1&&(T$1=x,de=null,G=null),T$1},I=null,w=null,_=()=>{let s=y();if(I===s)return w;I=s;let c=(s.relationships.get(s.mainDocumentPart)??[]).find(x=>x.type===v),f;if(c){let x=J$1(c);x.mode==="Internal"&&x.target.ok&&(f=s.parts.get(x.target.partName));}return f??=s.parts.get("/word/numbering.xml"),w=f?.root??null,w},Z="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",st=null,ge=null,Y=()=>{let s=y();if(st===s)return ge;st=s;let c=(s.relationships.get(s.mainDocumentPart)??[]).find(k=>k.type===Z),f;if(c){let k=J$1(c);k.mode==="Internal"&&k.target.ok&&(f=s.parts.get(k.target.partName));}f??=s.parts.get("/word/settings.xml");let x=f?.root??null;return x!==ge&&(ge=x,he=null,de=null,G=null),ge},Ro="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",vo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",it=(s,c)=>{let f=y(),x=(f.relationships.get("/")??[]).find(S=>S.type===s),k;if(x){let S=J$1(x);S.mode==="Internal"&&S.target.ok&&(k=f.parts.get(S.target.partName));}return k??f.parts.get(c)},lt=null,Ne=ki,To=()=>{let s=y();if(lt===s)return Ne;lt=s;let c=it(Ro,"/docProps/core.xml"),f=it(vo,"/docProps/app.xml");return Ne=li(c?.root??null,f?.root??null),Ne},Io="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",ct=null,ye=null,ee=()=>{let s=y();if(ct===s)return ye;ct=s;let c=(s.relationships.get(s.mainDocumentPart)??[]).find(k=>k.type===Io),f;if(c){let k=J$1(c);k.mode==="Internal"&&k.target.ok&&(f=s.parts.get(k.target.partName));}f??=s.parts.get("/word/theme/theme1.xml");let x=f?.root??null;return x!==ye&&(ye=x,he=null,Ee=null,de=null,G=null),ye},No="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",dt=null,ut=()=>{let s=y(),c=(s.relationships.get(s.mainDocumentPart)??[]).find(k=>k.type===No),f=c?J$1(c):null;return (f?.mode==="Internal"&&f.target.ok?s.parts.get(f.target.partName):void 0)??s.parts.get("/word/fontTable.xml")},Eo=()=>(dt??=Object.freeze(_if(y(),ut())),dt),ie=null,te=null,le=null,ce=null,de=null,Ee=null,he=null,pt=()=>{let s=[m().part.root],c=new Set;for(let f of $())c.has(f)||(c.add(f),s.push(f.root));return s},Me=()=>{let s=pt(),c=E();return c&&s.splice(1,0,c),s},G=null,xe=null,ue=null,ne=null,ft=new WeakMap,ke=null,mt=s=>{let c=ft.get(s);if(c)return c;let f=Eb(s);return ft.set(s,f),f},gt=()=>{let s=o.packageRevision,c=o.openStoryToken();if(!ne||ne.revision!==s||ne.openStories!==c){let f=o.openStoryParts(),x=new Set(f.map(F=>F.name)),k=$().filter(F=>!x.has(F.name)).map(mt),S=[m().part,...f,...k],N=ne,C=N!==null&&u!==null&&N.openStories===c&&N.revision===u.fromRevision&&s===u.toRevision&&u.impact==="text-local"&&u.created.length===0&&u.deleted.length===0&&u.splitJoin.length===0&&N.parts.length===S.length&&N.parts.every((F,oe)=>F.name===S[oe]?.name);ne={revision:s,openStories:c,parts:S,index:C&&N?ho(N.index,S):xo(S)};}return ne.index},Mo=()=>{let s=m().part.name,c=new Map;for(let f of [m().part,...$()])for(let[x,k]of ka(y(),f.name,s))c.set(x,k);return c},wo=()=>[m().part,...$()],$=()=>{let s=[],c=new Set;for(let x of b$1().parts)for(let k of [x.headers,x.footers])for(let S of k.values())c.has(S)||(c.add(S),s.push(S));let f=y();for(let x of ["footnote","endnote"]){let k=ch(f,x);!k||c.has(k)||(c.add(k),s.push(k));}return s},yt={ok:true,session:{editable:L(m().part).length>0,paragraphIds:()=>L(m().part).map(s=>s.id),paragraphIdsIn(s=g){let c=o.partFor(s);return c?L(c).map(f=>f.id):[]},part:()=>m().part,partFor:s=>o.partFor(s),currentPackage:y,collaborationPort:s=>b(o,{documentId:s}),applyTreeOps(s,c,f,x=g,k={}){return So(o,s,c,f,x,k)},applyTreeOpsAtomic(s,c={}){return Oo(o,s,c)},projectDoc:()=>V(m().part),reconcile:s=>Xe(s,m().part,u),lastCommitWasStructural:()=>u!==null&&(u.created.length>0||u.deleted.length>0||u.splitJoin.length>0||u.impact==="global"),applyPmDoc(s){let c=m(),f=Ke(c.part,s);if(!f.ok)return {committed:false,rejected:true,opCount:0,reason:f.reason};if(f.ops.length===0)return {committed:false,rejected:false,opCount:0};let x=o.transact(g,k=>{for(let S of f.ops)k.apply(S);});return x.ok?{committed:true,rejected:false,opCount:f.ops.length}:{committed:false,rejected:true,opCount:f.ops.length,reason:x.reason}},storyParts:wo,bodyText:()=>$n(m().part),storyText(s){let c=o.partFor(s);return c?L(c).map(f=>Vi(c,f.id)??"").join(`
5
- `):null},revision:()=>m().revision,revisionFor:s=>o.revisionFor(s),packageRevision:()=>o.packageRevision,canUndo:()=>o.canUndo,canRedo:()=>o.canRedo,undo:()=>{let s=o.selectionForUndo();return o.undo()===null?null:s},redo:()=>{let s=o.selectionForRedo();return o.redo()===null?null:s},beginComposition:(s=g)=>{o.beginComposition(s);},endComposition:()=>o.endComposition(),subscribe(s){return o.subscribe(s)},save(){return p(y())},headerFooterParts:()=>{let s=b$1().parts;return s[s.length-1]??gf(y())},headerFooterPartsBySection:()=>b$1().parts,headerFooterResolutionBySection:()=>b$1().resolution,documentFonts(){return ie&&ie.revision===o.packageRevision||(ie={revision:o.packageRevision,fonts:qn(Me(),se(ee(),Y()))}),ie.fonts},symbolFontFamilies(){return le&&le.revision===o.packageRevision||(le={revision:o.packageRevision,fonts:no(Me())}),le.fonts},renderedFontFamilies(){let s=E();return te&&te.revision===o.packageRevision&&te.styles===s||(te={revision:o.packageRevision,styles:s,families:f(pt(),s,se(ee(),Y()))}),te.families},rendersText(){return ce&&ce.revision===o.packageRevision||(ce={revision:o.packageRevision,rendersText:ro(Me())}),ce.rendersText},documentStyles(){let s=E(),c=ee(),f=Y();G??=d(s,se(c,f));let x=G;return de??=so(s,k=>x(k)),de},stylesRoot:()=>E(),documentThemeFonts(){let s=ee(),c=Y();return he??=se(s,c,ut()?.root??null),he},numberingRoot:()=>_(),settingsRoot:()=>Y(),documentProperties:()=>To(),trackingSettings:()=>hi(Y()),documentThemeColors(){let s=ee();return Ee??=go(s),Ee},effectiveRunDefaults(s,c){let f=E(),x=ee(),k=Y();G??=d(f,se(x,k));let S=m();if(!xe||xe.revision!==S.revision){let N=new Map;for(let C of L(S.part))C.kind!=="textValue"&&N.set(C.id,nt(C)??null);xe={revision:S.revision,byId:N};}return G(xe.byId.get(s)??null,c)},documentOutline(){let s=m();return ue&&ue.revision===s.revision||(ue={revision:s.revision,outline:lo(s.part,E())}),ue.outline},findText:mo({revision:()=>o.packageRevision,bodyPart:()=>m().part,currentPackage:y,headerFooterBySection:()=>b$1().resolution}),embeddedFonts:Eo,paragraphAnchors:gt,paraIdOf:s=>ko(s,{body:m().part,openStories:o.openStoryParts(),otherStories:$(),normalize:mt}),nodeIdOf:s=>gt().nodeByParaId.get(s.toUpperCase())??null,relationshipTarget:(s,c=g)=>{let f=y(),x=o.partFor(c);return x?Ig(f,x.name,s):null},bookmarks:()=>{let s=o.packageRevision;if(!ke||ke.revision!==s){let c=new Map(og(m().part));for(let f of $())for(let[x,k]of og(f))c.has(x)||c.set(x,k);ke={revision:s,index:c};}return ke.index},ensureHyperlinkRelationship(s,c=g){let f=o.partFor(c);return f?Na(o,()=>{let x=y(),k=Hg(x,s,f.name);return k?(k.pkg!==x&&o.replacePackageShell(k.pkg),k.relationshipId):null},x=>x!==null):null},reviewItems(){let s=e.reviewModel;if(!s)return Ir;let c=m(),f=`${o.packageRevision}:${c.revision}`;if(l&&l.revisionKey===f)return l.items;let x=y(),k=x.parts.get(aa(x,c.part.name)),S=x.parts.get(ba(x,c.part.name)),N=()=>s.collectReviewItems({storyPart:c.part,furnitureParts:$(),stylesPart:bd(x),commentsPart:k,commentsExtendedPart:S,customNodePayloads:Mo()}),C={part:c.part,commentsPart:k,commentsExtendedPart:S,currentPackageRevision:o.packageRevision,currentPackage:x,changePackage:h},F,oe=null;if(l&&u&&Gn(u,l,l.items,C))F=l.items;else {let pe=l&&u?Kn(u,l,l.items,C):null,we=pe&&l?s.revisionItemsOfParagraph(c.part,pe):null;pe&&l&&we&&zn(l.items,we,pe)?(oe=l.paragraphOrder??lj(c.part),F=Un(l.items,oe,pe,we)):(oe=lj(c.part),F=N());}return l={revisionKey:f,bodyRevision:c.revision,packageRevision:o.packageRevision,items:F,paragraphOrder:oe,commentsPart:k,commentsExtendedPart:S,pkg:x},l.items},hasReviewContent(){let s=o.packageRevision;if(!d$1||d$1.revision!==s){let c=bd(y()),f=[m().part,...$(),...c?[c]:[]];d$1={revision:s,present:f.some(x=>$j(x).length>0||Qe(x.root))};}return d$1.present},replyToComment(s,c,f,x,k,S=g,N){let C=ca(o,{anchor:{paragraphId:c.paragraphId,start:c.start,end:c.end,...c.endParagraphId===void 0?{}:{endParagraphId:c.endParagraphId}},author:x,text:f,...k===void 0?{}:{date:k},...s===null?{}:{replyToCommentId:s},...N===void 0?{}:{actorId:N}},S);return C.ok?C.commentId:null},setCommentResolved(s,c){return da(o,s,c).ok},deleteComment(s,c=g,f){return this.deleteComments([{commentId:s}],c,f)},deleteComments(s,c=g,f){return ea(o,s,c,f)},insertCustomNode(s,c=g){return ma(o,s,c)},removeCustomNode(s,c=g){return na(o,s,c)},sweepCustomNodePayloads(s){return Na(o,()=>{let c=m(),f=ja(o.currentPackage(),c.part.name,s);return f.ok?f.removed.length===0?{ok:true,removed:[]}:(o.replacePackageShell(f.pkg),{ok:true,removed:f.removed}):{ok:false,reason:f.reason}},c=>c.ok&&c.removed.length>0)},ensureListDefinition(s){return Na(o,()=>{let c=Ag(y(),s);return c?(o.replacePackageShell(c.pkg),I=null,w=null,c.numId):null},c=>c!==null)},ensureNumberingLevel(s,c,f){return Na(o,()=>{let x=y(),k=Bg(x,s,c,f);return k?k!==x?(o.replacePackageShell(k),I=null,w=null,{ok:true,changed:true}):{ok:true,changed:false}:{ok:false,changed:false}},x=>x.changed).ok},insertImage(s,c){return o.insertImage(s,c)},replaceImage(s,c,f,x,k,S){return o.replaceImage(s,c,f,x,k,S)},deleteImage(s,c){return o.deleteImage(s,c)},deleteImageTracked(s,c,f){return o.deleteImageTracked(s,c,f)},applyImageProperties(s,c){return o.applyImageProperties(s,c)},applyFragmentPaste(s,c){return o.applyFragmentPaste(s,c)}}};return ml(yt.session,o),yt}var Mr=g.projection;function $r(t,e,n){let r=t.filter(a=>a.localName!==e);return r.length!==t.length?r:[...r,n?{localName:e,attributes:n}:{localName:e}]}function zr(t,e,n={}){let r=null,a=false,o=()=>n.onChange?.(i()),i=()=>({revision:e.revision(),canUndo:e.canUndo(),canRedo:e.canRedo(),lastRejection:r}),l=p=>{a=true;let g=u.state.tr.replaceWith(0,u.state.doc.content.size,p.content);g.setMeta("addToHistory",false),u.dispatch(g),a=false;},d=p=>()=>(p()&&(l(e.projectDoc()),o()),true),u=new EditorView(t,{state:EditorState.create({doc:e.projectDoc(),plugins:[keymap({...baseKeymap,Home:selectTextblockStart,End:selectTextblockEnd,"Mod-z":d(()=>e.undo()!==null),"Mod-y":d(()=>e.redo()!==null),"Shift-Mod-z":d(()=>e.redo()!==null),"Mod-b":(p,g)=>y(p,g,"b"),"Mod-i":(p,g)=>y(p,g,"i"),"Mod-u":(p,g)=>y(p,g,"u",{val:"single"})})]}),editable:()=>e.editable,handleDOMEvents:{keydown:p=>(h(p),false),beforeinput:(p,g)=>{let P=g;if(p.composing)return false;h(p);let O=P.inputType;if(O==="insertText"&&P.data!=null){P.preventDefault();let{from:b,to:R}=p.state.selection;return p.dispatch(p.state.tr.insertText(P.data,b,R)),true}if(O==="deleteContentBackward"){P.preventDefault();let{from:b,empty:R}=p.state.selection;return R?b>0?p.dispatch(p.state.tr.delete(b-1,b)):joinBackward(p.state,p.dispatch):deleteSelection(p.state,p.dispatch),true}if(O==="deleteContentForward"){P.preventDefault();let{from:b,to:R,empty:v}=p.state.selection;return v?R<p.state.doc.content.size?p.dispatch(p.state.tr.delete(b,b+1)):joinForward(p.state,p.dispatch):deleteSelection(p.state,p.dispatch),true}return O==="insertParagraph"?(P.preventDefault(),splitBlock(p.state,p.dispatch),true):false},compositionstart:()=>(e.beginComposition(),false),compositionend:()=>(e.endComposition(),o(),false)},dispatchTransaction(p){let g=u.state.apply(p);if(a||!p.docChanged){u.updateState(g);return}let P=e.applyPmDoc(g.doc);if(P.rejected){r=String(P.reason??"rejected"),u.updateState(g),l(e.projectDoc()),o();return}r=null,u.updateState(P.committed&&e.lastCommitWasStructural()?m(g):g),o();}});function h(p){if(p.composing||a)return;let g=p.dom.ownerDocument.getSelection(),P=g?.anchorNode,O=g?.focusNode;if(!(!g||!P||!O)&&!(!p.dom.contains(P)||!p.dom.contains(O)))try{let b=p.posAtDOM(P,g.anchorOffset),R=p.posAtDOM(O,g.focusOffset),v=p.state.selection;if(v.anchor===b&&v.head===R)return;let T=TextSelection.create(p.state.doc,b,R);p.dispatch(p.state.tr.setSelection(T).setMeta("addToHistory",!1));}catch{}}function m(p){let g=e.paragraphIds(),P=p.tr,O=false,b=0;return p.doc.forEach((R,v)=>{let T=g[b];b+=1,!(R.type.name!=="paragraph"||T===void 0)&&R.attrs.nodeId!==T&&(P=P.setNodeMarkup(v,void 0,{...R.attrs,nodeId:T}),O=true);}),O?p.apply(P.setMeta("addToHistory",false)):p}function y(p,g,P,O){let b=M.marks.runProps;if(!g)return true;let{from:R,to:v,empty:T}=p.selection;if(T)return true;let I=p.doc.resolve(R).marks().find(Z=>Z.type===b)?.attrs.props??[],w=$r(I,P,O),_=p.tr;return _.removeMark(R,v,b),w.length>0&&_.addMark(R,v,b.create({props:w})),g(_),true}return {view:u,state:i,undo:()=>d(()=>e.undo()!==null)(),redo:()=>d(()=>e.redo()!==null)(),toggleRunProperty(p,g){y(u.state,u.dispatch.bind(u),p,g);},destroy:()=>u.destroy()}}export{M as a,Ye as b,ae as c,L as d,V as e,Ke as f,Go as g,Xe as h,nt as i,Nr as j,Er as k,Mr as l,zr as m};