@docx-editor.dev/core 2.27.0 → 2.29.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 (124) hide show
  1. package/dist/automation.cjs +1 -1
  2. package/dist/automation.d.ts +76 -16
  3. package/dist/automation.js +1 -1
  4. package/dist/binding.cjs +1 -1
  5. package/dist/binding.d.ts +31 -12
  6. package/dist/binding.js +1 -1
  7. package/dist/{index-CkQVRJtJ.d.ts → chrome-print-CAs51cpq.d.ts} +248 -115
  8. package/dist/chunk-236O4YQW.js +2 -0
  9. package/dist/chunk-4HENIAFG.js +1 -0
  10. package/dist/chunk-6JPL6ZAS.cjs +5 -0
  11. package/dist/chunk-6ZQP4HQ7.js +3 -0
  12. package/dist/{chunk-2GK7YQB2.cjs → chunk-7WQ7AAHW.cjs} +1 -1
  13. package/dist/chunk-BCXH4BXB.js +5 -0
  14. package/dist/chunk-BY2ACZZ6.cjs +1 -0
  15. package/dist/chunk-CAJEXXVG.cjs +4 -0
  16. package/dist/chunk-CPWLFPWC.js +30 -0
  17. package/dist/chunk-D7ZMDMPX.cjs +3 -0
  18. package/dist/chunk-DOHF6FA7.cjs +30 -0
  19. package/dist/chunk-DVX32P2P.js +27 -0
  20. package/dist/chunk-E4LOMDNL.js +1 -0
  21. package/dist/chunk-EKLM7NWB.cjs +7 -0
  22. package/dist/chunk-G3K63G7P.cjs +27 -0
  23. package/dist/chunk-G4HOFIKJ.js +1 -0
  24. package/dist/chunk-JLVBDYVQ.cjs +2 -0
  25. package/dist/chunk-LQX36Z5P.js +7 -0
  26. package/dist/chunk-LSZ6KPKK.js +1 -0
  27. package/dist/chunk-MM5QBMTE.cjs +1 -0
  28. package/dist/chunk-OMCG63ZF.js +1 -0
  29. package/dist/chunk-OSFOJTHU.cjs +18 -0
  30. package/dist/chunk-RCLZXP3B.js +2 -0
  31. package/dist/chunk-T6K2QYNZ.cjs +2 -0
  32. package/dist/chunk-TRGAVV2Y.js +4 -0
  33. package/dist/chunk-U4JZVSOE.js +2 -0
  34. package/dist/chunk-UHHYFIDT.cjs +1 -0
  35. package/dist/chunk-V3N4SOAK.cjs +1 -0
  36. package/dist/chunk-W35WTWAO.cjs +1 -0
  37. package/dist/chunk-YQ5G6LC7.js +18 -0
  38. package/dist/collaboration/replication.cjs +1 -1
  39. package/dist/collaboration/replication.d.ts +42 -6
  40. package/dist/collaboration/replication.js +1 -1
  41. package/dist/collaboration.cjs +1 -1
  42. package/dist/collaboration.d.ts +99 -7
  43. package/dist/collaboration.js +1 -1
  44. package/dist/contracts/document.d.ts +18 -3
  45. package/dist/contracts/editor.d.ts +19 -10
  46. package/dist/contracts/interaction.d.ts +31 -2
  47. package/dist/contracts/modules.cjs +1 -1
  48. package/dist/contracts/modules.d.ts +56 -8
  49. package/dist/contracts/modules.js +1 -1
  50. package/dist/contracts/types.d.ts +11 -2
  51. package/dist/{custom-node-writes-Vzpq9I8_.d.ts → custom-node-writes-Bn6uciLb.d.ts} +2 -2
  52. package/dist/diagnostic-context-B8M79cfK.d.ts +30 -0
  53. package/dist/diagnostic-hints-BeVjfNOv.d.ts +113 -0
  54. package/dist/{document-protection-9zpIHWTE.d.ts → document-protection-CUb55pl_.d.ts} +2 -2
  55. package/dist/{editor-B3OBYNrF.d.ts → editor-CZQZmTIU.d.ts} +770 -141
  56. package/dist/{editor-scope-OHPwVQ5l.d.ts → editor-scope-7o9xweiJ.d.ts} +1 -1
  57. package/dist/editor.cjs +1 -1
  58. package/dist/editor.css +5 -5
  59. package/dist/editor.d.ts +439 -33
  60. package/dist/editor.js +1 -1
  61. package/dist/export.cjs +2 -2
  62. package/dist/export.d.ts +23 -14
  63. package/dist/export.js +2 -2
  64. package/dist/failure-NS2lsya4.d.ts +115 -0
  65. package/dist/{font-resolver-DN0xNOf_.d.ts → font-resolver-lSBLirLR.d.ts} +3 -3
  66. package/dist/{headless-document-view-ICYqNkQ1.d.ts → headless-document-view-pp3q7wIh.d.ts} +2 -2
  67. package/dist/{image-resources-BDFxcu7W.d.ts → image-resources-tXLQShoC.d.ts} +10 -10
  68. package/dist/index.cjs +1 -1
  69. package/dist/index.d.ts +92 -20
  70. package/dist/index.js +1 -1
  71. package/dist/{layout-shaping-BvZD_VKP.d.ts → layout-shaping-BD-dF_rn.d.ts} +1 -1
  72. package/dist/layout.cjs +1 -1
  73. package/dist/layout.d.ts +168 -79
  74. package/dist/layout.js +1 -1
  75. package/dist/{note-properties-CkAk7g-n.d.ts → note-properties-qQUjO1GQ.d.ts} +3 -3
  76. package/dist/{omml-equation-DuczgG5o.d.ts → omml-equation-BUbU0utM.d.ts} +1 -1
  77. package/dist/output.cjs +1 -1
  78. package/dist/output.d.ts +18 -9
  79. package/dist/output.js +1 -1
  80. package/dist/{protocol-aKYr8r3u.d.ts → protocol-DYzzz2ej.d.ts} +44 -4
  81. package/dist/{review-paragraph-order-Ddj5d6rp.d.ts → review-paragraph-order-CN_0l2Cb.d.ts} +5 -2
  82. package/dist/{semantic-cell-selection-DoqYCz_F.d.ts → semantic-cell-selection-eYag3P47.d.ts} +8 -213
  83. package/dist/{semantic-interaction-G0bjmmmk.d.ts → semantic-interaction-kR_QB845.d.ts} +25 -34
  84. package/dist/{semantic-paint-CsMzF8-O.d.ts → semantic-paint-ZayFF3tD.d.ts} +17 -5
  85. package/dist/{semantic-record-queries-1du6lQqS.d.ts → semantic-record-queries-Bsgth6lv.d.ts} +1 -1
  86. package/dist/{semantic-records-B9OolWGN.d.ts → semantic-records-DQmumPgL.d.ts} +1367 -884
  87. package/dist/store.cjs +1 -1
  88. package/dist/store.d.ts +1611 -1586
  89. package/dist/store.js +1 -1
  90. package/dist/{tree-package-fragment-DYZIk1rY.d.ts → tree-package-store-CovjNARF.d.ts} +157 -137
  91. package/dist/{tree-session-contract-DQVJOOkv.d.ts → tree-session-contract-CZVAGl51.d.ts} +8 -6
  92. package/dist/{types-barrel-BFKR8Pzp.d.ts → types-barrel-DuC5QBNC.d.ts} +352 -231
  93. package/package.json +3 -3
  94. package/dist/chunk-4KZ6L5YF.cjs +0 -15
  95. package/dist/chunk-55AT3MOU.cjs +0 -25
  96. package/dist/chunk-6ZQMII6V.js +0 -1
  97. package/dist/chunk-7IGCWG4H.js +0 -2
  98. package/dist/chunk-7MYITTAH.js +0 -5
  99. package/dist/chunk-AVKVRU7Z.cjs +0 -5
  100. package/dist/chunk-CWRBFNK5.cjs +0 -5
  101. package/dist/chunk-DGPA3TST.cjs +0 -27
  102. package/dist/chunk-DNXVNQEO.js +0 -1
  103. package/dist/chunk-FQN4KSFL.cjs +0 -7
  104. package/dist/chunk-GVUOWHTO.cjs +0 -1
  105. package/dist/chunk-GWQJ5774.js +0 -5
  106. package/dist/chunk-HAQ72KD7.js +0 -1
  107. package/dist/chunk-HO5XFO32.cjs +0 -3
  108. package/dist/chunk-IGR23DV2.js +0 -1
  109. package/dist/chunk-JSIX2EOH.js +0 -3
  110. package/dist/chunk-K246T47S.cjs +0 -1
  111. package/dist/chunk-KAXOGCGA.js +0 -1
  112. package/dist/chunk-LZLTN5A3.cjs +0 -1
  113. package/dist/chunk-NBCVVZOM.cjs +0 -1
  114. package/dist/chunk-O5INAWZQ.js +0 -1
  115. package/dist/chunk-OHAXVTWG.cjs +0 -1
  116. package/dist/chunk-S74GRBNE.js +0 -7
  117. package/dist/chunk-UBLUVNZR.js +0 -27
  118. package/dist/chunk-UMRSBLO7.js +0 -15
  119. package/dist/chunk-VIPMGGUT.js +0 -25
  120. package/dist/chunk-WG4KMSX2.cjs +0 -2
  121. package/dist/chunk-WRLKVNNR.cjs +0 -1
  122. package/dist/chunk-ZU7IVN6G.js +0 -2
  123. package/dist/failure-BIPVQbRm.d.ts +0 -65
  124. package/dist/revision-projection-CSNFudZY.d.ts +0 -242
@@ -1,5 +0,0 @@
1
- import {c,d,Gh,p,f,k,j,i,fa,Li,Uf,dk,Lg,re,Ed as Ed$1,se,N,x,Dd as Dd$1,ck,Ef,Eh,Ma,pe,Aa,ze as ze$1,ye,xe,ne,Fa,Ga,tb,b,Ag,vj,wj,ya,Ae as Ae$1,nk,Dh,ok,lk,Qh,Bh,Ch,tg,ug,E,qb,O,Hf,ub,wb,rb,kb,Oa,Hd as Hd$1,Id as Id$1,Fh,Kd,Oh,Ph,Mb,ji,ei,oi,ii,hi,ci,ri,di,qi as qi$1,ki,gi,bb,Ui,Wi,Si,Kh,Lh,Ia,lb,nb,pb,Jf,vb,Hj,Bj,Gj,Ij,Cf,Na,ej,Vi,hj,_i,Xi as Xi$1,La,cj,$i,aj,Ka,gj,bj,Zi as Zi$1,Ri,ij,pg,Qe as Qe$1,Re,Wh,Vh,uj,Ih,w,ta as ta$1,og,a,fe as fe$1,ve,Fj,xj,zj,Bi,Hi,kg,bk,_j,Pf,Mh,Oc as Oc$1,Pa,he,ce as ce$1,ee,ie,ke,Mj,le,id as id$1,Jd as Jd$1,bi,mb,ja,hb,Wa,Xa,fb,$e as $e$1,Qd as Qd$1,be,Yi as Yi$1,xb,sb,ak,yd as yd$1,qd as qd$1,rd as rd$1,td as td$1,F,wa,g,xa,u,_c as _c$1,Ti,$g,Bf,Df,Kb,Ej,Dj,Rf,Xg,Yg,ud as ud$1,va,P,Tf,X,$j,qg,Vj,Wj,ga,$d as $d$1,ae as ae$1,_d as _d$1}from'./chunk-UMRSBLO7.js';import {strFromU8,strToU8}from'fflate';var Xd=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],Yd=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Jd=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Gi(e){return Yd.test(e)||Jd.test(e)}function Dn(e,t){if(!Gi(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 qd=/^(\d+)\.(\d+)\.(\d+)$/;function st(e){let t=qd.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 _n(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 Fn(e,t){let n=st(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=st(r.slice(1));return _n(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let i=true;for(let a of o){let s=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=st(a.slice(s.length)),d=_n(n,l);s===">="?i=i&&d>=0:i=i&&d<0;}return i}return _n(n,st(r))===0}var fe=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Kr=(e,t)=>`${e}:${t}`;function Qd(e,t={}){let n=new Map;for(let d of e){if(Dn(d.id,"extension"),Ki(d.version,d.id),n.has(d.id))throw new fe("duplicate-extension",`duplicate extension id ${d.id}`,[d.id]);n.set(d.id,d);for(let c of d.contributions)Dn(c.id,c.kind),Ki(c.version,`${d.id} \u2192 ${c.id}`),c.replaces&&tc(c.replaces.targetRange,`${d.id} \u2192 replaces ${c.replaces.targetId}`);}for(let d of e){for(let c of d.dependencies??[])if(!n.has(c))throw new fe("missing-dependency",`${d.id} requires missing extension ${c}`,[d.id,c]);for(let c of d.conflicts??[])if(n.has(c)){let u=[d.id,c].sort();throw new fe("conflict",`extensions ${u[0]} and ${u[1]} conflict`,u)}}ec(n);let r=new Set(t.availablePorts??[]);for(let d of e)for(let c of d.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let d of e)for(let c of d.requiredPorts??[])if(!r.has(c))throw new fe("missing-port",`${d.id} requires unavailable port ${c}`,[d.id,c]);let o=new Map,i=new Map,a=new Map;for(let d of e)for(let c of d.contributions){let u=Kr(c.kind,c.id);if(c.replaces){let f=Kr(c.kind,c.replaces.targetId),x=a.get(f)??[];x.push({ext:d.id,c}),a.set(f,x);continue}if(i.has(u)){let f=[o.get(u),d.id].sort();throw new fe("id-collision",`${c.kind} id ${c.id} registered by both ${f[0]} and ${f[1]}`,f)}i.set(u,c),o.set(u,d.id);}let s=new Map(i);for(let[d,c]of a){let u=i.get(d);if(!u){let m=c[0];throw new fe("replacement-target-missing",`${m.ext} replaces missing target ${m.c.replaces.targetId}`,[m.ext,m.c.replaces.targetId])}let f=u.replaceable??{kind:"none"};for(let{ext:m,c:g}of c){if(!Fn(u.version,g.replaces.targetRange))throw new fe("replacement-version-mismatch",`${m} replaces ${g.replaces.targetId}@${u.version} outside range ${g.replaces.targetRange}`,[m,g.replaces.targetId]);if(f.kind==="none")throw new fe("unauthorized-replacement",`${g.replaces.targetId} does not authorize replacement (attempted by ${m})`,[m,g.replaces.targetId])}let x=Zd(u,c);s.set(d,x);}return {extensions:n,contributions:s,get:(d,c)=>s.get(Kr(d,c))}}function Zd(e,t){let n=e.replaceable??{kind:"none"};if(t.length===1)return t[0].c;if(n.kind==="priority"){let o=[...t].sort((s,l)=>(l.c.replaces.priority??0)-(s.c.replaces.priority??0)),i=o[0].c.replaces.priority??0,a=o.filter(s=>(s.c.replaces.priority??0)===i);if(a.length>1){let s=a.map(l=>l.ext).sort();throw new fe("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${i}: ${s.join(", ")}`,s)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new fe("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function ec(e){let o=new Map,i=[],a=s=>{o.set(s,1),i.push(s);let l=[...e.get(s)?.dependencies??[]].sort();for(let d of l){let c=o.get(d)??0;if(c===1){let u=i.indexOf(d),f=[...i.slice(u),d];throw new fe("dependency-cycle",`dependency cycle: ${f.join(" -> ")}`,f)}c===0&&a(d);}i.pop(),o.set(s,2);};for(let s of [...e.keys()].sort())(o.get(s)??0)===0&&a(s);}function Ki(e,t){try{st(e);}catch{throw new fe("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function tc(e,t){try{Fn("0.0.0",e);}catch{throw new fe("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var lt=class extends Error{constructor(t){super(t),this.name="BudgetError";}},Ht=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new 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,r=this;return {amount:t,get released(){return n},release(){n||(n=true,r.used.release(t),r.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let r=new e(t,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new lt(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new lt(`${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(r){t.push(r);}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 lt(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new lt(`${this.label}: budget already released`)}};var Ln=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},Vt=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 Ln(t.derivedOnly,t._reason)}}}};var $n=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Xr=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 $n(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(f.clock)}identity(){return this.resolve(f.identity)}},Yr=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}},Jr=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function nc(e){let t=k(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",i={id:o,limits:t,config:n,ports:e.ports,budget:new Ht(`op:${o}`,r),cancellation:new Vt};return Object.freeze(i)}function rc(e){e.budget.dispose();}var Qr=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"}}),Xi=Object.keys(Qr);function oc(e,t){return new p(`${Qr[t].phase}:${t}`,e[t])}var qr=class{counter;current=0;peak=0;constructor(t){this.counter=new 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 ac(){for(let e of Xi){let t=j[e],n=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 zt(e,t=new Set){let n=new WeakSet,r=[],o=i=>{if(i===null)return "null";let a=typeof i;if(a==="boolean")return i?"true":"false";if(a==="number"){let l=i;if(!Number.isFinite(l))throw new Error(`non-finite number is not comparable: ${l}`);return Object.is(l,-0)?"0":String(l)}if(a==="string")return JSON.stringify(i);if(a==="bigint")return `${i.toString()}n`;if(Array.isArray(i))return `[${i.map((l,d)=>{r.push(d);try{return o(l)}finally{r.pop();}}).join(",")}]`;if(a==="object"){let l=i;if(n.has(l))throw new Error("cannot canonicalize a cyclic structure");n.add(l);let c=Object.keys(l).filter(u=>!t.has(u)).sort().map(u=>{r.push(u);try{return `${JSON.stringify(u)}:${o(l[u])}`}finally{r.pop();}}).join(",");return n.delete(l),`{${c}}`}let s=r.length>0?` at ${r.map(String).join(".")}`:"";throw new Error(`unsupported value type in comparator input: ${a}${s}`)};return o(e)}function Zr(e,t){return ic(zt(e,t))}function ic(e){let t=3421674724,n=2216829733;for(let r=0;r<e.length;r++){n=(n^e.charCodeAt(r))>>>0;let o=n*435,i=Math.floor(o/4294967296);t=Math.imul(t,435)+Math.imul(n,256)+i>>>0,n=o>>>0;}return t.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var $e="dev.docx-editor.core.comparator",eo={authoredState:{id:`${$e}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${$e}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${$e}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${$e}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${$e}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${$e}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${$e}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${$e}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${$e}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${$e}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function to(e,t,n,r={}){let o=eo[e];switch(o.mode){case "sync-optimization-only":throw new Error(`${o.id} is not an equivalence basis (${o.note})`);case "tolerance":{if(r.epsilon===void 0)throw new Error(`${o.id} requires an explicit epsilon`);return {equal:Yi(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let i=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=zt(t,i),s=zt(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function no(e,t){let n=eo[e];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return Zr(t,r)}function Yi(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((r,o)=>Yi(r,t[o],n)):false}var qi=new Set([...c,...d]),Ji=/^[0-9a-f]{16}$/,sc=/^[0-9a-f]*$/;function ro(e){let t=[],n=o=>t.push(o);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 r=-1;e.steps.forEach((o,i)=>{let a=`step[${i}]`;qi.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&lc(s.modelChange,a,n)):(s.committedRevision!==void 0&&n(`${a}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${a}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!Ji.test(s.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!Ji.test(s.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),sc.test(o.bytesHex)||n("envelope bytesHex must be hex"),o.bytesHex.length!==o.byteLength*2&&n(`envelope byteLength ${o.byteLength} disagrees with ${o.bytesHex.length/2} decoded bytes`);return {valid:t.length===0,errors:t}}function lc(e,t,n){qi.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function dc(e,t){let n=ro(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,i)=>{let a=`step[${i}]`,s=t.applyStep(o),l=o.expect;if(s.outcome!==l.outcome){r.push(`${a}: outcome ${s.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(s.committedRevision!==l.committedRevision&&r.push(`${a}: revision ${s.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {to("authoredState",s.authoredState,s.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=Qi(s.authoredState);c!==l.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function Qi(e){return no("authoredState",e)}function Wt(e){let t=[...e];for(;t.length;){let n=t.pop();if(n.kind!=="textValue"){if(n.namespaceUri===fa&&n.localName==="object")return true;for(let r of n.children)t.push(r);}}return false}var Zi=24,Bn=Object.freeze([Object.freeze({localName:"kern",attributes:Object.freeze({val:"2"})}),Object.freeze({localName:"sz",attributes:Object.freeze({val:String(Zi)})}),Object.freeze({localName:"szCs",attributes:Object.freeze({val:String(Zi)})})]),jn=Object.freeze([Object.freeze({localName:"spacing",attributes:Object.freeze({after:"160",line:"278",lineRule:"auto"})})]),ts=Object.freeze({run:true,paragraph:true}),ns=Object.freeze({run:false,paragraph:false});function rs(e){if(!e)return ts;let t=n=>e.children.some(r=>r.kind!=="textValue"&&r.namespaceUri===fa&&r.localName===n);return {run:!t("rPrDefault"),paragraph:!t("pPrDefault")}}function oo(e,t){return e&&e.namespaceUri!==fa?ns:rs(t)}function Xp(e){return e?e.namespaceUri!==fa?ns:rs(cc(e)):ts}function Un(e,t,n,r){return {id:n,kind:e,namespaceUri:fa,localName:t,prefix:"w",namespaceBindings:[],attributes:[],children:r}}function es(e,t){let n=e==="rPr"?Bn:jn;return Un(e==="rPr"?"runProperties":"paragraphProperties",e,`${t}-${e}`,n.map(r=>Li(r,`${t}-${e}-${r.localName}`)))}function cc(e){let t=e.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===fa&&n.localName==="docDefaults");return t&&t.kind!=="textValue"?t:void 0}function os(e,t,n){let r=oo(e,t);if(!r.run&&!r.paragraph)return t;let o=[];r.run&&o.push(Un("generic","rPrDefault",`${n}-rPrDefault`,[es("rPr",n)])),r.paragraph&&o.push(Un("generic","pPrDefault",`${n}-pPrDefault`,[es("pPr",n)]));let i=r.run?[...o,...t?.children??[]]:[...t?.children??[],...o];return t?{...t,children:i}:Un("generic","docDefaults",`${n}-docDefaults`,i)}var dt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",mc="http://schemas.openxmlformats.org/package/2006/relationships",uc="http://schemas.openxmlformats.org/drawingml/2006/main",ss="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",ls="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",ds="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",cs="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",ms="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",ao="application/vnd.openxmlformats-package.relationships+xml",io=`${dt}/styles`,so=`${dt}/numbering`,us=`${dt}/footnotes`,ps=`${dt}/endnotes`,fs=`${dt}/officeDocument`,pc=`${dt}/theme`;function Me(e){return e.kind!=="textValue"}function as(e,t){return {...e,children:t}}function qe(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)qe(n,t);}var fc=new Set(["pStyle","rStyle","tblStyle"]);function lo(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue"&&fc.has(r.localName)&&r.namespaceUri===fa){let o=Ef(r,"val");o&&t.add(o);}});}function co(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===fa){let o=Ef(r,"val");o&&t.add(o);}});}function mo(e){let t=new Set;return Gt(e,t),t}function Gt(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===dt&&o.value.length>0&&t.add(o.value);});}function Ne(e){return /^\d+$/.test(e)?e.replace(/^0+(?=\d)/,""):e}function Vn(e,t){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)qe(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",d=Ef(s,"id");if(d===void 0)return;let c=Ne(d);n[l].has(c)||(n[l].add(c),r.push({kind:l,id:c}));});};for(o(e);r.length>0;){let i=r.pop(),a=t(i.kind,i.id);a!==null&&o([a]);}return n}function uo(e,t,n){if(e.kind==="textValue")return e;let r=[],o=false;for(let i of e.children){if(i.kind!=="textValue"&&i.namespaceUri===fa&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?t:n,d=Ef(i,"id");if(i.kind!=="noteReference"||d===void 0||!l.has(Ne(d))){o=true;continue}}let s=uo(i,t,n);s!==i&&(o=true),r.push(s);}return o?{...e,children:r}:e}function gc(e,t){for(let n of re(e,t)){if(n.type!==io||n.targetMode==="External")continue;let r=w(n.ownerPart,n.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return e.parts.get("/word/styles.xml")??null}function gs(e,t,n){for(let r of re(e,t)){if(r.type!==n||r.targetMode==="External")continue;let o=w(r.ownerPart,r.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return null}function hs(e,t){let n=gc(e,t),r=new Map,o=[],i=null;if(n&&Me(n.root))for(let a of n.root.children){if(!Me(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===fa){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==fa)continue;let s=Ef(a,"styleId");s&&r.set(s,a),(Ef(a,"default")==="1"||Ef(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var hc=new Set(["basedOn","link","next"]);function ys(e,t){let n=new Set,r=[...t];for(let a of e.defaults){let s=Ef(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=e.byId.get(a);if(s){o.push(s);for(let l of s.children)if(Me(l)&&hc.has(l.localName)&&l.namespaceUri===fa){let d=Ef(l,"val");d&&r.push(d);}}}if(!e.part||!Me(e.part.root))return o;let i=new Map;return e.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function po(e,t,n){let r=gs(e,t,so)??e.parts.get("/word/numbering.xml")??null;if(!r||!Me(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!Me(s)||s.localName!=="num"||s.namespaceUri!==fa)continue;let l=Ef(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let d of s.children)if(Me(d)&&d.localName==="abstractNumId"){let c=Ef(d,"val");c&&i.add(c);}}}let a=[];for(let s of r.root.children){if(!Me(s)||s.localName!=="abstractNum"||s.namespaceUri!==fa)continue;let l=Ef(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var Hn={latin:null,eastAsia:null,cs:null};function xs(e,t){let n=gs(e,t,pc);if(!n)return {major:Hn,minor:Hn};let r={major:{...Hn},minor:{...Hn}};return qe(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==uc||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!Me(a))continue;let s=Ef(a,"typeface");s&&(a.localName==="latin"?i.latin=s:a.localName==="ea"?i.eastAsia=s:a.localName==="cs"&&(i.cs=s));}}),{major:r.major,minor:r.minor}}function yc(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 xc=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],is=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Qe(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===fa){let i=[],a=new Map;for(let s of e.attributes){let l=xc.find(([d])=>d===s.localName);if(l&&s.namespaceUri===fa){let d=yc(t,s.value);d&&a.set(l[1],d);continue}i.push(s);}for(let[s,l]of a)i.some(d=>d.localName===s)||i.push({kind:"genericExtension",namespaceUri:fa,localName:s,prefix:"w",value:l});n=i;}else e.attributes.some(i=>is.has(i.localName)&&i.namespaceUri===fa&&e.attributes.some(a=>a.localName==="val"))&&(n=e.attributes.filter(i=>!(is.has(i.localName)&&i.namespaceUri===fa)));let r=e.children.map(i=>Qe(i,t)),o=r.some((i,a)=>i!==e.children[a]);return n===e.attributes&&!o?e:{...e,attributes:n,children:r}}function ks(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Ps(e,t){if(e.root.kind==="document"){let r=e.root.children.find(i=>i.kind==="body"),o=r&&Me(r)?as(r,t):{id:"fragment#body",kind:"body",namespaceUri:fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return as(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:fa,localName:"document",prefix:"w",namespaceBindings:Me(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function Kt(e){let t=e.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${N(n.id)}" Type="${N(n.type)}" Target="${N(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${mc}">${t}</Relationships>`}function Rs(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Os(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function zn(e,t){return {...e,children:t}}function Wn(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function Xt(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)Xt(n,t);return t}function vs(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=vs(n,t);if(r)return r}return null}function kc(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&Wn(n,"vMerge")){if(Ef(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===fa)),{kind:"wmlVal",namespaceUri:fa,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||Wn(n,"tc");return zn(n,n.children.map(i=>t(i,o)))};return zn(e,e.children.map(n=>t(n,false)))}function Is(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(Wn(e,"tr")){t.push(e);return}for(let n of e.children)Is(n,t);}}function bs(e,t,n){if(e.kind==="textValue"||e.kind==="table")return {node:e,hadRows:false,keptRows:false};if(Wn(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let a=n.value?kc(e):e;return n.value=false,{node:a,hadRows:true,keptRows:true}}let r=false,o=false,i=[];for(let a of e.children){let s=bs(a,t,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&i.push(s.node);}return r?{node:o?zn(e,i):null,hadRows:true,keptRows:o}:{node:e,hadRows:false,keptRows:false}}function Ss(e,t,n){let r=[];for(let l of e.children)Is(l,r);let o=new Set(Xt(e).filter(l=>t.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let d=Xt(l);return d.length>0&&d.every(c=>t.covered.has(c))}),a=new Set(i.flatMap(l=>Xt(l)));if(i.length>0&&o.size===a.size&&[...o].every(l=>a.has(l))){let l={value:true},d=new Set(i),c=[];for(let u of e.children){let f=bs(u,d,l);f.node!==null&&c.push(f.node);}n.push(zn(e,c));return}for(let l of Xt(e)){if(!t.inRange.has(l))continue;let d=vs(e,l);d&&n.push(d);}}var Pc="http://schemas.openxmlformats.org/package/2006/content-types",Rc=5e4;function Ue(e){return e.kind!=="textValue"}function Ns(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)Ns(n,t);return t}function fo(e,t){if(e.kind==="textValue")return null;if(e.kind==="paragraph"&&e.id===t)return e;for(let n of e.children){let r=fo(n,t);if(r)return r}return null}function Oc(){return {id:"fragment#styles",kind:"generic",namespaceUri:fa,localName:"styles",prefix:"w",namespaceBindings:[{prefix:"w",namespaceUri:fa}],attributes:[],children:[]}}function ze(e,t){return {...e,children:t}}function vc(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function Ic(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&Ue(t)?t:null}return Ue(e.root)?e.root:null}function bc(e,t){return Ns(e).some(n=>t.has(n))}function go(e,t,n){for(let r of e)if(Ue(r)){if(r.kind==="paragraph"){t.inRange.has(r.id)&&n.push(r);continue}if(t.fullBlocks.has(r.id)){n.push(r);continue}if(r.kind==="table"){Ss(r,t,n);continue}if(r.kind==="contentControl"){let o=r.children.find(i=>i.kind==="contentControlContent");o&&Ue(o)&&go(o.children,t,n);continue}bc(r,t.inRange)&&go(r.children,t,n);}}var Sc=new Set(["commentRangeStart","commentRangeEnd"]);function Nc(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function ho(e){if(e.kind==="textValue")return e;if(Sc.has(e.localName)&&e.namespaceUri===fa||Nc(e)||vc(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=ho(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?ze(e,n):e}function wc(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let d of l.children)if(d.kind==="fldChar"){let c=Ef(d,"fldCharType");t.push({nodeId:d.id,type:c==="separate"||c==="end"?c:"begin"});}else d.kind==="instrText"&&t.push({nodeId:d.id,type:"instr"});return}for(let d of l.children)n(d);}};for(let l of e)n(l);if(t.length===0)return e;let r=new Set,o=[],i=null,a=[];for(let l of t){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let c=o[o.length-1];c?c.separateId=l.nodeId:i=l.nodeId;continue}if(l.type==="instr"){let c=o[o.length-1];c?c.instrIds.push(l.nodeId):i===null&&a.push(l.nodeId);continue}if(!o.pop()){r.add(l.nodeId),i!==null&&r.add(i);for(let c of a)r.add(c);i=null,a=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let d of l.instrIds)r.add(d);}i!==null&&r.add(i);for(let l of a)r.add(l);if(r.size===0)return e;let s=l=>{if(l.kind==="textValue")return l;if(r.has(l.id))return null;let d=[],c=false;for(let u of l.children){let f=s(u);if(f===null){c=true;continue}f!==u&&(c=true),d.push(f);}return c?ze(l,d):l};return e.map(l=>s(l)).filter(l=>l!==null)}function yo(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=yo(n);return t}function Ec(e,t){let n=[];for(let r of e.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=t.get(r.id),i=yo(r);if(o===void 0||i>=o){n.push(r);continue}if(i===0)continue;let a=r.children.find(s=>s.kind==="contentControlContent");a&&Ue(a)?n.push(...a.children):n.push(r);}return ze(e,n)}function Tc(e){let t=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=Ef(a,"id");s!==void 0&&t.add(s);}if(a.kind==="bookmarkEnd"){let s=Ef(a,"id");s!==void 0&&n.add(s);}for(let s of a.children)r(s);}};for(let a of e)r(a);let o=new Set([...t].filter(a=>n.has(a)));if(o.size===t.size&&o.size===n.size)return e;let i=a=>{if(a.kind==="textValue")return a;if(a.kind==="bookmarkStart"||a.kind==="bookmarkEnd"){let d=Ef(a,"id");return d!==void 0&&o.has(d)?a:null}let s=[],l=false;for(let d of a.children){let c=i(d);if(c===null){l=true;continue}c!==d&&(l=true),s.push(c);}return l?ze(a,s):a};return e.map(a=>i(a)??a)}function Cc(e,t,n){let r=e.parts.get(t.partName);if(!r)return {ok:false,reason:"unknown-part"};if(t.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o=t.paragraphIds[0],i=t.paragraphIds[t.paragraphIds.length-1],a=new Map;for(let w of [o,i]){let B=fo(r.root,w);if(!B)return {ok:false,reason:"empty-range"};for(let G of B.children)G.kind==="contentControl"&&a.set(G.id,yo(G));}let s=r,l=fo(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let d=Uf(l);if(t.endOffset<d){let w=dk(s,{op:"deleteText",paragraphId:i,start:t.endOffset,end:d},{deferValidation:true});if(!w.ok)return {ok:false,reason:"trim-refused"};s=w.part;}if(t.startOffset>0){let w=dk(s,{op:"deleteText",paragraphId:o,start:0,end:t.startOffset},{deferValidation:true});if(!w.ok)return {ok:false,reason:"trim-refused"};s=w.part;}let c=Ic(s);if(!c)return {ok:false,reason:"unknown-part"};let u={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},f=[];if(go(c.children,u,f),f.length===0)return {ok:false,reason:"empty-range"};if(f.length>Rc)return {ok:false,reason:"resource-limit"};let x$1=f.map(w=>ho(w)).filter(w=>w!==null).map(w=>w.kind!=="paragraph"||w.id!==o&&w.id!==i?w:Ec(w,a));x$1=[...wc(x$1)],x$1=[...Tc(x$1)];let m=Lg(e,"footnote"),g=Lg(e,"endnote"),y=(w,B)=>Ue(w)&&w.namespaceUri===fa&&w.localName===B,P=Vn(x$1,(w,B)=>{let G=w==="footnote"?m:g;if(!G||!Ue(G.root))return null;for(let Y of G.root.children){if(!y(Y,w))continue;let ne=Ef(Y,"id");if(ne!==void 0&&Ne(ne)===B)return Y}return null}),p=P.footnote,k=P.endnote;p.size===0&&(m=null),k.size===0&&(g=null);let v=(w,B,G)=>{if(!w||!Ue(w.root))return [];let Y=[];for(let ne of w.root.children){if(!y(ne,B))continue;let re=Ef(ne,"id"),_e=Ef(ne,"type");if(_e==="separator"||_e==="continuationSeparator"){Y.push(ne);continue}if(re!==void 0&&G.has(Ne(re))){let Fe=ho(ne);Fe&&Ue(Fe)&&Y.push(Fe);}}return Y},R=v(m,"footnote",p),h=v(g,"endnote",k),C=[...R,...h];if(Wt(x$1)||Wt(C))return {ok:false,reason:"unsupported-content"};let I=[...x$1,...C],j=new Set;lo(I,j);let _=hs(e,e.mainDocumentPart),J=new Set;co(I,J);let H=[],T=po(e,e.mainDocumentPart,J);for(;;){let w=j.size,B=J.size;H=ys(_,j),co(H,J),T=po(e,e.mainDocumentPart,J);let G=[...T.nums,...T.abstracts];lo(G,j);for(let Y of G)qe(Y,ne=>{if(ne.kind!=="textValue"&&(ne.localName==="styleLink"||ne.localName==="numStyleLink")&&ne.namespaceUri===fa){let re=Ef(ne,"val");re&&j.add(re);}});if(j.size===w&&J.size===B)break}let V=xs(e,e.mainDocumentPart),ie=H.map(w=>Qe(w,V)),se$1=_.part&&Ue(_.part.root)?_.part.root:null,M=os(se$1,_.docDefaults,"fragment#doc-defaults"),$=M?Qe(M,V):null;x$1=x$1.map(w=>Qe(w,V));let K=R.map(w=>Qe(w,V)),S=h.map(w=>Qe(w,V)),b=new Set;Gt(x$1,b);let A=re(e,r.name).filter(w=>b.has(w.id)),X=new Map,ee=0,le=w$1=>{let B=new Set;for(let G of w$1){if(G.targetMode==="External")continue;let Y=w(G.ownerPart,G.rawTarget);if(!Y.ok){B.add(G.id);continue}if((se(e,Y.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let re=e.partBytes.get(Y.partName)??e.partBytes.get(Y.partName.replace(/^\//,""));re?(X.set(Y.partName,re),ee+=re.byteLength):B.add(G.id);continue}B.add(G.id);}return B},z=le(A),De=(w,B)=>{if(w.kind==="textValue")return w;if(w.kind==="drawing"||w.namespaceUri===fa&&(w.localName==="pict"||w.localName==="object")){let ne=new Set;Gt([w],ne);for(let re of ne)if(B.has(re))return null;return w}let G=[],Y=false;for(let ne of w.children){let re=De(ne,B);if(re===null){Y=true;continue}re!==ne&&(Y=true),G.push(re);}return Y?ze(w,G):w};z.size>0&&(x$1=x$1.map(w=>De(w,z)).filter(w=>w!==null));let pe=A.filter(w=>!z.has(w.id)),At=(w,B)=>{if(!w)return [];let G=new Set;Gt(B,G);let Y=re(e,w.name).filter(re=>G.has(re.id)),ne=le(Y);if(ne.size>0)for(let re=0;re<B.length;re+=1){let _e=De(B[re],ne);_e!==null&&(B[re]=_e);}return Y.filter(re=>!ne.has(re.id))},an=At(m,K),sn=At(g,S),Ie=new Map,ln=[],dn=new Map,N$1=(w,B,G)=>{let Y=ks(w,B,G);Ie.set(w.slice(1),Ed$1(ta$1(Y))),ln.push([w,B]),dn.set(w,Y);},D=(w$1,B)=>w$1.map(G=>{if(G.targetMode==="External")return {...G,ownerPart:B};let Y=w(G.ownerPart,G.rawTarget);return {...G,ownerPart:B,rawTarget:Y.ok?Y.partName:G.rawTarget}}),F=D(pe,"/word/document.xml"),U=D(an,"/word/footnotes.xml"),W=D(sn,"/word/endnotes.xml"),q=new Set(F.map(w=>w.id)),de=9001,ye=(w,B)=>{let G=Rs(q,de);de+=1,q.add(G),F.push({ownerPart:"/word/document.xml",id:G,type:w,rawTarget:B,targetMode:"Internal",order:F.length});},xe=Ps(s,x$1);if(N$1("/word/document.xml",ss,xe),ie.length>0||$){let w=ze(se$1??Oc(),[...$?[$]:[],...ie]);N$1("/word/styles.xml",ls,w),ye(io,"styles.xml");}if(T.part&&(T.nums.length>0||T.abstracts.length>0)){let w=ze(T.part.root,[...T.abstracts.map(B=>Qe(B,V)),...T.nums]);N$1("/word/numbering.xml",ds,w),ye(so,"numbering.xml");}m&&K.length>0&&(N$1("/word/footnotes.xml",cs,ze(m.root,K)),ye(us,"footnotes.xml"),U.length>0&&Ie.set("word/_rels/footnotes.xml.rels",Ed$1(Kt(U)))),g&&S.length>0&&(N$1("/word/endnotes.xml",ms,ze(g.root,S)),ye(ps,"endnotes.xml"),W.length>0&&Ie.set("word/_rels/endnotes.xml.rels",Ed$1(Kt(W))));let be=new Map;for(let[w,B]of X){Ie.set(w.slice(1),B);let G=Os(w);G&&!be.has(G)&&be.set(G,se(e,w)??"application/octet-stream");}let Ke={ownerPart:"/",id:"rId1",type:fs,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Ie.set("word/_rels/document.xml.rels",Ed$1(Kt(F))),Ie.set("_rels/.rels",Ed$1(Kt([Ke])));let Xe=[`<Default Extension="rels" ContentType="${ao}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...be].map(([w,B])=>`<Default Extension="${N(w)}" ContentType="${N(B)}"/>`)].join(""),ur=ln.map(([w,B])=>`<Override PartName="${N(w)}" ContentType="${N(B)}"/>`).join("");Ie.set("[Content_Types].xml",Ed$1(`<Types xmlns="${Pc}">${Xe}${ur}</Types>`));let oe=new Map;oe.set("/",[Ke]),oe.set("/word/document.xml",F),U.length>0&&oe.set("/word/footnotes.xml",U),W.length>0&&oe.set("/word/endnotes.xml",W);let me=[];for(let w of oe.values())for(let B of w)B.targetMode==="External"&&me.push({ownerPart:B.ownerPart,id:B.id,type:B.type,rawTarget:B.rawTarget,sinkSafe:x(B.rawTarget).ok});let we=new Map;we.set("rels",ao),we.set("xml","application/xml");for(let[w,B]of be)we.set(w,B);let cn={defaults:we,overrides:new Map(ln)},Dt=new Map;for(let[w,B]of Ie)Dt.set(w.startsWith("/")?w:`/${w}`,B);return {ok:true,bytes:Dd$1(Ie),package:Object.freeze({parts:dn,partBytes:Dt,relationships:oe,externalTargets:me,contentTypes:cn,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t.lastMarkCovered,blockCount:x$1.length,mediaBytes:ee}}function ae(e){return e.kind!=="textValue"}function Q(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function Ae(e,t){for(let n of e)t(n),n.kind!=="textValue"&&Ae(n.children,t);}function Ze(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===fa&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===ja&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(Ze).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function Jt(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(Ze).join("")}`}function Xn(e){let t=[],n=new Map,r=new Set,o=null;if(e&&ae(e.root))for(let i of e.root.children){if(!ae(i))continue;if(Q(i,"docDefaults")){o=i;continue}if(!Q(i,"style"))continue;t.push(i);let a=Ef(i,"styleId");a&&n.set(a,i);let s=i.children.find(d=>Q(d,"name")),l=s?Ef(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function Gn(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(a=>Q(a,t));if(!o||!ae(o))return r;let i=o.children.find(a=>Q(a,n));if(!i||!ae(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function Es(e){let t=e.part?.root;return t&&ae(t)?t:null}function ws(e){return oo(Es(e),e.docDefaults)}function Kn(e){return new Map(e.map(t=>[t.localName,Li(t,`fragment#application-${t.localName}`)]))}function Mc(e,t){let n=new Set,r=t;for(let o=0;o<16&&r;o+=1){let i=e.byId.get(r);if(!i)break;let s=Yt(i,"pPr")?.children.find(d=>Q(d,"spacing"));if(s&&ae(s))for(let d of s.attributes)n.add(d.localName);let l=i.children.find(d=>Q(d,"basedOn"));r=l?Ef(l,"val"):void 0;}return n}function xo(e,t,n,r){let o=t;for(let i=0;i<16&&o;i+=1){let a=e.byId.get(o);if(!a)return false;let s=a.children.find(d=>Q(d,n));if(s&&ae(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=a.children.find(d=>Q(d,"basedOn"));o=l?Ef(l,"val"):void 0;}return false}function Ac(e,t){for(let n of e.styles){if(Ef(n,"type")!==t)continue;let r=Ef(n,"default");if(r==="1"||r==="true")return Ef(n,"styleId")}}function Yt(e,t){let n=e.children.find(r=>Q(r,t));return n&&ae(n)?n:null}var Dc=new Map(["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"].map((e,t)=>[e,t])),_c=new Map(["rStyle","rFonts","b","bCs","i","iCs","caps","smallCaps","strike","dstrike","outline","shadow","emboss","imprint","noProof","snapToGrid","vanish","webHidden","color","spacing","w","kern","position","sz","szCs","highlight","u","effect","bdr","shd","fitText","vertAlign","rtl","cs","em","lang","eastAsianLayout","specVanish","oMath","rPrChange"].map((e,t)=>[e,t]));function ko(e,t,n){let r=Es(t)?ws(t):null,o=ws(n),i=r?.run?Kn(Bn):Gn(t.docDefaults,"rPrDefault","rPr"),a=o.run?Kn(Bn):Gn(n.docDefaults,"rPrDefault","rPr"),s=r?.paragraph?Kn(jn):Gn(t.docDefaults,"pPrDefault","pPr"),l=o.paragraph?Kn(jn):Gn(n.docDefaults,"pPrDefault","pPr"),d=(p,k,v)=>{let R=Ac(p,"paragraph"),h=R?p.byId.get(R):void 0;if(!h)return R;for(let[C,I]of [["rPr",k],["pPr",v]]){let j=Yt(h,C);if(j)for(let _ of j.children)_.kind!=="textValue"&&I.set(_.localName,_);}return R};d(t,i,s),d(n,a,l);let c=new Map;for(let[p,k]of i){let v=a.get(p);(!v||Ze(v)!==Ze(k))&&c.set(p,k);}let u=new Map;for(let[p,k]of s){if(p==="sectPr")continue;let v=l.get(p);(!v||Ze(v)!==Ze(k))&&u.set(p,k);}if(c.size===0&&u.size===0)return e;let f=0,x=()=>`fragment#materialized-${f++}`,m=p=>{let k=v=>v.kind==="textValue"?{id:x(),kind:"textValue",value:v.value}:{...v,id:x(),children:v.children.map(k)};return k(p)},g=(p,k,v)=>{if(v.length===0)return p;let R=Yt(p,k);if(R){let C=k==="rPr"?_c:Dc,I=[...R.children];for(let _ of v){let J=_.kind==="textValue"?Number.MAX_SAFE_INTEGER:C.get(_.localName)??Number.MAX_SAFE_INTEGER,H=I.length;for(let T=0;T<I.length;T+=1){let V=I[T];if(V.kind==="textValue")continue;let ie=C.get(V.localName);if(ie!==void 0&&ie>J){H=T;break}}I.splice(H,0,_);}let j={...R,children:I};return {...p,children:p.children.map(_=>_===R?j:_)}}let h={id:x(),kind:k==="rPr"?"runProperties":"paragraphProperties",namespaceUri:fa,localName:k,prefix:"w",namespaceBindings:[],attributes:[],children:v};return {...p,children:[h,...p.children]}},y=(p,k,v,R,h)=>{let C=Mc(t,h),I=k.children.find(T=>Q(T,"spacing"));if(I&&ae(I))for(let T of I.attributes)C.add(T.localName);let j=new Map(R&&ae(R)?R.attributes.map(T=>[T.localName,T.value]):[]),_=v.attributes.filter(T=>!C.has(T.localName)&&j.get(T.localName)!==T.value);if(_.length===0)return p;let J=I&&ae(I)?{...I,attributes:[...I.attributes,..._]}:{...v,id:x(),attributes:_,children:[]},H=I?{...k,children:k.children.map(T=>T===I?J:T)}:g(p,"pPr",[J]).children.find(T=>Q(T,"pPr"));return {...p,children:p.children.map(T=>T===k?H:T)}},O=p=>{let k=Yt(p,"pPr"),v=k?.children.find(_=>Q(_,"pStyle")),R=v?Ef(v,"val"):void 0,h=[],C=p;for(let[_,J]of u){let H=k?.children.some(V=>V.kind!=="textValue"&&V.localName===_),T=!!R&&xo(t,R,"pPr",_);_==="spacing"&&(H||T)&&k!==null&&ae(J)&&(C=y(C,k,J,l.get("spacing"),R)),!(H||T)&&h.push(m(J));}let I=_=>{if(_.kind==="textValue")return _;if(_.kind==="run"){let H=Yt(_,"rPr"),T=H?.children.find(se=>Q(se,"rStyle")),V=T?Ef(T,"val"):void 0,ie=[];for(let[se,M]of c)H?.children.some(K=>K.kind!=="textValue"&&K.localName===se)||V&&xo(t,V,"rPr",se)||R&&xo(t,R,"rPr",se)||ie.push(m(M));return g(_,"rPr",ie)}if(_.kind==="paragraphProperties"||_.kind==="runProperties")return _;let J=_.children.map(I);return J.some((H,T)=>H!==_.children[T])?{..._,children:J}:_};return I(g(C,"pPr",h))},P=p=>{if(p.kind==="textValue")return p;if(p.kind==="paragraph")return O(p);let k=p.children.map(P);return k.some((v,R)=>v!==p.children[R])?{...p,children:k}:p};return e.map(P)}var Ts="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function ge(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var Fc=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),Po=Yg,We=new Map;function It(e,t){let n=t.styleIds??We,r=t.numIds??We,o=t.relIds??We,i=t.footnoteIds??We,a=t.endnoteIds??We,s=t.bookmarkIds??We,l=t.sdtIds??We,d=t.revisionIds??We,c=t.docPrIds??We,u=(f,x)=>{if(f.kind==="textValue")return f;let m=f;if(f.namespaceUri===fa&&Fc.has(f.localName)){let P=Ef(f,"val"),p=P!==void 0?n.get(P):void 0;p!==void 0&&(m=ge(m,fa,"val",p));}if(Q(f,"numId")){let P=Ef(f,"val"),p=P!==void 0?r.get(P):void 0;p!==void 0&&(m=ge(m,fa,"val",p));}if(f.kind==="noteReference"){let P=f.localName==="footnoteReference"?i:a,p=Ef(f,"id"),k=p!==void 0?P.get(Ne(p)):void 0;k!==void 0&&(m=ge(m,fa,"id",k));}if(f.kind==="bookmarkStart"||f.kind==="bookmarkEnd"){let P=Ef(f,"id"),p=P!==void 0?s.get(P):void 0;p!==void 0&&(m=ge(m,fa,"id",p));}if(Q(f,"id")&&x==="sdtPr"){let P=Ef(f,"val"),p=P!==void 0?l.get(P):void 0;p!==void 0&&(m=ge(m,fa,"val",p));}if(Po(f)){let P=Ef(f,"id"),p=P!==void 0?d.get(P):void 0;p!==void 0&&(m=ge(m,fa,"id",p));}if(f.kind==="drawingDocPr"){let P=f.attributes.find(k=>k.localName==="id"&&k.namespaceUri==="")?.value,p=P!==void 0?c.get(P):void 0;p!==void 0&&(m=ge(m,"","id",p));}for(let P of m.attributes){if(P.namespaceUri!==Ts)continue;let p=o.get(P.value);p!==void 0&&p!==P.value&&(m=ge(m,Ts,P.localName,p));}let g=f.localName,y=m.children.map(P=>u(P,g));return m!==f||y.some((P,p)=>P!==m.children[p])?{...m,children:y}:f};return u(e,"")}function Cs(e,t,n){let r=e,o=n.get(e)??2;for(;t.has(r);)r=`${e}${o}`,o+=1;return n.set(e,o),r}function Ms(e,t,n){let r=`${e} (pasted)`,o=n.get(e)??2;for(;t.has(r);)r=`${e} (pasted ${o})`,o+=1;return n.set(e,o),r}var Lc=1e5;function As(e){let t=ub(),n=$c(e,t),r=Uc(e,t),o=Bc(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function Ro(e,t,n,r){if(e)return xb(t,e,r);let o=n;return ()=>String(o++)}function Ds(e,t){if(e.add(t),!/^\d{1,10}$/.test(t))return;let n=Number(t);n<=rb&&e.add(String(n));}function _s(e,t){if(t===void 0)return e;let n=Number(t);return Number.isInteger(n)&&n>e?n:e}function $c(e,t){let n=new Map;if(e.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [e.ownerPart,...e.notesParts])Ae([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=Ef(s,"id");l!==void 0&&(Ds(o,l),s.kind==="bookmarkStart"&&(r=_s(r,l)));});let i=Ro(t,o,r+1,rb);for(let a of e.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function Uc(e,t){let n=new Map;if(!e.hasRevision)return n;let r=0,o=new Set;for(let s of [e.ownerPart,...e.notesParts]){let l=s===e.ownerPart;Ae([s.root],d=>{if(!Yg(d))return;let c=Ef(d,"id");c!==void 0&&Ds(o,c),l&&(r=_s(r,c));});}let i=Ro(t,o,r+1,rb),a=false;return Ae(e.travelling,s=>{if(a||!Yg(s))return;let l=Ef(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function Bc(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=$d$1(e.pkg),o=Lc;if(!t){let s=ae$1(e.pkg);s.ok&&(o=s.id);}let i=Ro(t,r,o,_d$1),a=false;return Ae(e.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function Fs(e,t){return `${t?Jt(t):"none"}::${e.children.filter(n=>Q(n,"lvlOverride")).map(Ze).join("")}`}function Ls(e){let t=e.children.find(n=>Q(n,"abstractNumId"));return t?Ef(t,"val"):void 0}function $s(e,t,n){let r=new Set(["0"]),o=0;for(let s of e?.root.children??[]){if(!ae(s)||!Q(s,t))continue;let l=Ef(s,n);if(l===void 0)continue;let d=Number(l);Number.isInteger(d)&&(r.add(String(d)),d>o&&(o=d));}let i=ub();if(i)return xb(r,i,sb);let a=o+1;return ()=>String(a++)}function Us(e,t){let n={numIdMap:new Map,numsToImport:[],abstractsToImport:[]};if(!e||!ae(e.root))return n;let r=new Map,o=[];for(let d of e.root.children)if(ae(d))if(Q(d,"abstractNum")){let c=Ef(d,"abstractNumId");c&&r.set(c,d);}else Q(d,"num")&&o.push(d);let i=new Map;if(t&&ae(t.root)){let d=new Map;for(let c of t.root.children){if(!ae(c)||!Q(c,"abstractNum"))continue;let u=Ef(c,"abstractNumId");u&&d.set(u,c);}for(let c of t.root.children){if(!ae(c)||!Q(c,"num"))continue;let u=Ef(c,"numId");if(!u)continue;let f=Ls(c),x=f?d.get(f):void 0;i.set(Fs(c,x),u);}}let a=$s(t,"abstractNum","abstractNumId"),s=$s(t,"num","numId"),l=new Map;for(let d of o){let c=Ef(d,"numId");if(!c)continue;let u=Ls(d),f=u?r.get(u):void 0,x=Fs(d,f),m=i.get(x);if(m!==void 0){n.numIdMap.set(c,m);continue}let g=u?l.get(u):void 0;if(g===void 0&&f&&u){let P=a();if(P===null)return null;g=P,l.set(u,g),n.abstractsToImport.push(ge(f,fa,"abstractNumId",g));}let y=s();if(y===null)return null;n.numIdMap.set(c,y);let O=ge(d,fa,"numId",y);if(g!==void 0){let P=O.children.map(p=>Q(p,"abstractNumId")?ge(p,fa,"val",g):p);O={...O,children:P};}n.numsToImport.push(O),i.set(x,y);}return n}var bt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",jc=`${bt}/hyperlink`,Bs=`${bt}/image`,Yn=`${bt}/numbering`,Oo=`${bt}/styles`,js="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Hs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function qt(e,t,n,r){for(let o of re(e,t)){if(o.type!==n||o.targetMode==="External")continue;let i=w(o.ownerPart,o.rawTarget);if(i.ok){let a=e.parts.get(i.partName);if(a)return a}}return e.parts.get(r)??null}function Hc(e,t){let n=0;return Ae([e],r=>{let o=t(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Jn(e,t,n,r){if(n.length===0)return e;let o=Ia(t,"paste"),i=n.map(d=>Jf(d,o)),a=bk(t,i),s=r??a.root.children.length,l=Oa(a,a.root.id,s,i,{deferValidation:true});return l.ok?pe(e,l.part):null}function Vs(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||Q(o,"pict")||Q(o,"object")){let a=false;return Ae([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===bt&&t.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===bt)?.value;if(a!==void 0&&t.has(a))return r(o.children)}let i=r(o.children);return i.length===o.children.length&&i.every((a,s)=>a===o.children[s])?o:{...o,children:i}};function r(o){let i=[];for(let a of o){let s=n(a);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(e)}var Vc=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),zs={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function zc(e,t){let n=Qd$1(e);return n==="unknown"||(Object.hasOwn(zs,t)?zs[t]:t)!==n||Vc.has(n)&&!be(e,n)?null:n}function vo(e,t,n){for(let N of t.parts.values())if(Wt([N.root]))return {ok:false,reason:"unsupported-content"};let r=t.parts.get(t.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!e.parts.has(n))return {ok:false,reason:"no-target-part"};let o=r.root.kind==="document"?r.root.children.find(N=>N.kind==="body"):null;if(!o||!ae(o))return {ok:false,reason:"no-fragment-document"};let i=ck(o.children.filter(N=>N.kind==="paragraph"||N.kind==="table"||N.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a$1=e,s=Us(qt(t,t.mainDocumentPart,Yn,"/word/numbering.xml"),qt(a$1,a$1.mainDocumentPart,Yn,"/word/numbering.xml"));if(!s)return {ok:false,reason:"merge-refused"};let{numIdMap:l,numsToImport:d,abstractsToImport:c}=s,u=Xn(qt(t,t.mainDocumentPart,Oo,"/word/styles.xml")),f=qt(a$1,a$1.mainDocumentPart,Oo,"/word/styles.xml"),x=Xn(f),m=new Map,g=[],y=new Set(x.byId.keys()),O=new Set(x.names),P=new Map,p=new Map,k=new Map,v=(N,D)=>{let F=k.get(N);return F===void 0&&(F=Jt(D),k.set(N,F)),F},R=N=>({...N,attributes:N.attributes.filter(D=>!(D.localName==="default"&&D.namespaceUri===fa))});for(let N of u.styles){let D=Ef(N,"styleId");if(!D)continue;let F=x.byId.get(D),U=Jt(It(N,{styleIds:m,numIds:l}));if(F&&v(D,F)===U){m.set(D,D);continue}if(!F){m.set(D,D),y.add(D),g.push(R(N));continue}let W=Cs(`${D}Pasted`,y,P);y.add(W),m.set(D,W),g.push(R(ge(N,fa,"styleId",W)));}let h=g.map(N=>{let D=N.children.find(q=>Q(q,"name")),F=D?Ef(D,"val"):void 0;if(!F||!O.has(F))return F&&O.add(F),N;let U=Ms(F,O,p);O.add(U);let W=N.children.map(q=>Q(q,"name")?ge(q,fa,"val",U):q);return {...N,children:W}}),C=null,I=1,j=()=>{if(C)return C;let N=new Map;for(let[D,F]of a$1.partBytes){let U=D.startsWith("/")?D:`/${D}`;if(!U.startsWith("/word/media/"))continue;N.set(a(F),U);let W=/\/image(\d+)\./.exec(U);W&&(I=Math.max(I,Number(W[1])+1));}return C=N,N},_=new Map,J=N=>{let D=_.get(N);if(!D){D=new Map;for(let F of re(a$1,N)){if(F.targetMode==="External"||F.type!==Bs)continue;let U=w(F.ownerPart,F.rawTarget);U.ok&&D.set(U.partName,F.id);}_.set(N,D);}return D},H=(N,D)=>{let F=N.lastIndexOf("."),U=F===-1?"":N.slice(F+1);return /^[A-Za-z0-9]{1,8}$/.test(U)?U.toLowerCase():D==="image/jpeg"?"jpeg":D==="image/gif"?"gif":"png"},T=(N,D,F)=>{let U=new Map,W=new Set,q=J(D),de=[],ye=new Set,xe$1=[],be=[],Ke=new Map,Xe=[],ur=t.relationships.get(N)??[];for(let oe of ur){if(!F.has(oe.id))continue;if(oe.targetMode==="External"){if(oe.type===jc){let Fe=og(a$1,oe.rawTarget,D);Fe?(a$1=Fe.pkg,U.set(oe.id,Fe.relationshipId)):W.add(oe.id);}else W.add(oe.id);continue}let me=w(oe.ownerPart,oe.rawTarget);if(!me.ok){W.add(oe.id);continue}let we=t.partBytes.get(me.partName)??t.partBytes.get(me.partName.replace(/^\//,"")),cn=(se(t,me.partName)??"").toLowerCase();if(!we||!cn.startsWith("image/")){W.add(oe.id);continue}let Dt=zc(we,cn);if(Dt===null){W.add(oe.id);continue}let w$1=Dt,B=j(),G=a(we),Y=B.get(G);if(!Y){let Fe=H(me.partName,w$1),Kd=mn=>a$1.partBytes.has(mn)||a$1.partBytes.has(mn.slice(1))||a$1.parts.has(mn)||ye.has(mn),pr=`/word/media/image${I}.${Fe}`;for(;Kd(pr);)I+=1,pr=`/word/media/image${I}.${Fe}`;I+=1,Y=pr,de.push({partName:Y,bytes:we,contentType:w$1}),ye.add(Y),B.set(G,Y);}let ne=Y.startsWith("/word/")?Y.slice(6):Y,re=q.get(Y);if(re!==void 0){U.set(oe.id,re);continue}let _e=Ke.get(Y);_e===void 0&&(_e=xe$1.length,Ke.set(Y,_e),xe$1.push(ne),be.push(Y)),Xe.push({recordId:oe.id,index:_e});}if(de.length>0&&(a$1=fe$1(a$1,de)),xe$1.length>0){let oe=ve(xe(a$1,D),D,xe$1.map(me=>[Bs,me]));if(oe.ok){a$1=oe.pkg,oe.ids.forEach((me,we)=>{q.set(be[we],me);});for(let me of Xe)U.set(me.recordId,oe.ids[me.index]);}else for(let me of Xe)W.add(me.recordId);}return {relIdMap:U,dropRelIds:W}},V=T(t.mainDocumentPart,n,mo(i));i=Vs(i,V.dropRelIds);let ie=new Map,se$1=new Map,M=[],$=(N,D)=>ae(N)&&N.namespaceUri===fa&&N.localName===D,K={},S=Vn(i,(N,D)=>{let F=K[N];if(F===void 0){F=new Map,K[N]=F;let U=Lg(t,N);if(U&&ae(U.root))for(let W of U.root.children){if(!$(W,N))continue;let q=Ef(W,"id");if(q===void 0)continue;let de=Ne(q);F.has(de)||F.set(de,W);}}return F.get(D)??null});for(let N of ["footnote","endnote"]){let D=N==="footnote"?ie:se$1,F=S[N];if(F.size===0)continue;let U=Lg(t,N);if(!U||!ae(U.root))continue;let W=Eh(a$1,N);if(!W.ok||!W.package)return {ok:false,reason:"merge-refused"};a$1=W.package;let q=Lg(a$1,N);if(!q)return {ok:false,reason:"merge-refused"};let de=Hc(q.root,xe=>$(xe,N)?Ef(xe,"id"):void 0)+1,ye=[];for(let xe of U.root.children){if(!$(xe,N))continue;let be=Ef(xe,"id"),Ke=Ef(xe,"type");if(Ke==="separator"||Ke==="continuationSeparator"||be===void 0||!F.has(Ne(be))||D.has(Ne(be)))continue;let Xe=String(de++);D.set(Ne(be),Xe),ye.push(ge(xe,fa,"id",Xe));}ye.length>0&&M.push({kind:N,fragmentPartName:U.name,bodies:ck(ye)});}let b=a$1.parts.get(n),A=[...i,...M.flatMap(N=>N.bodies)],X=[],ee=new Set,le=false,z=false,De=new Map;Ae(A,N=>{if(N.kind!=="textValue"){if(N.kind==="bookmarkStart"||N.kind==="bookmarkEnd"){let D=Ef(N,"id");if(D!==void 0&&X.push(D),N.kind==="bookmarkStart"){let F=Ef(N,"name");F&&ee.add(F);}return}if(Po(N)){le=true;return}if(N.kind==="drawingDocPr"){z=true;return}if(N.kind==="contentControlProperties")for(let D of N.children){if(!Q(D,"id"))continue;let F=Ef(D,"val");if(F!==void 0&&!De.has(F)){let U=0,W=`${F}:${De.size}`;for(let q=0;q<W.length;q+=1)U=U*31+W.charCodeAt(q)>>>0;De.set(F,String(U%2147483647||1));}}}});let pe$1=As({pkg:a$1,ownerPart:b,notesParts:M.map(N=>Lg(a$1,N.kind)).filter(N=>N!==null),travelling:A,fragmentBookmarkIds:X,hasRevision:le,hasDocPr:z});if(!pe$1)return {ok:false,reason:"merge-refused"};let At=pe$1.bookmarkIds,an=pe$1.revisionIds,sn=pe$1.docPrIds;if(ee.size>0){let N=new Set;if(Ae([b.root],D=>{if(D.kind!=="textValue"&&D.kind==="bookmarkStart"){let F=Ef(D,"name"),U=Ef(D,"id");F&&U!==void 0&&ee.has(F)&&N.add(U);}}),N.size>0){let D=U=>{if(U.kind==="textValue")return U;let W=[],q=false;for(let de of U.children){if((de.kind==="bookmarkStart"||de.kind==="bookmarkEnd")&&N.has(Ef(de,"id")??"")){q=true;continue}let ye=D(de);ye!==de&&(q=true),W.push(ye);}return q?{...U,children:W}:U},F=D(b.root);F!==b.root&&(Ma(b.root,F),a$1=pe(a$1,{...b,root:F}));}}let Ie=N=>uo(N,ie,se$1);for(let N of M){N.bodies=N.bodies.map(Ie);let D=Lg(a$1,N.kind);if(!D)return {ok:false,reason:"merge-refused"};let F=T(N.fragmentPartName,D.name,mo(N.bodies)),U=Vs(N.bodies,F.dropRelIds);U=[...ko(U,u,x)],U=U.map(q=>It(q,{styleIds:m,numIds:l,relIds:F.relIdMap,footnoteIds:ie,endnoteIds:se$1,bookmarkIds:At,sdtIds:De,revisionIds:an,docPrIds:sn}));let W=Jn(a$1,a$1.parts.get(D.name),U);if(!W)return {ok:false,reason:"merge-refused"};a$1=W;}if(h.length>0){let N=h.map(F=>It(F,{styleIds:m,numIds:l}));if(!f){let F=Aa(`<w:styles xmlns:w="${fa}"></w:styles>`,{name:"/word/styles.xml",contentType:Hs});if(!F.ok)return {ok:false,reason:"merge-refused"};a$1=ze$1(a$1,"/word/styles.xml",F.part.root,Hs);let U=ye(xe(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,Oo,"styles.xml");if(!U.ok)return {ok:false,reason:"merge-refused"};a$1=U.pkg,f=a$1.parts.get("/word/styles.xml")??null;}if(!f)return {ok:false,reason:"merge-refused"};let D=Jn(a$1,a$1.parts.get(f.name),N);if(!D)return {ok:false,reason:"merge-refused"};a$1=D,x=Xn(a$1.parts.get(f.name)??null);}if(c.length>0||d.length>0){let N=qt(a$1,a$1.mainDocumentPart,Yn,"/word/numbering.xml");if(!N){let q=Aa(`<w:numbering xmlns:w="${fa}"></w:numbering>`,{name:"/word/numbering.xml",contentType:js});if(!q.ok)return {ok:false,reason:"merge-refused"};a$1=ze$1(a$1,"/word/numbering.xml",q.part.root,js);let de=ye(xe(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,Yn,"numbering.xml");if(!de.ok)return {ok:false,reason:"merge-refused"};a$1=de.pkg,N=a$1.parts.get("/word/numbering.xml")??null;}if(!N)return {ok:false,reason:"merge-refused"};let D=a$1.parts.get(N.name),F=D.root.children.findIndex(q=>Q(q,"num")),U=c.map(q=>It(q,{styleIds:m,numIds:l})),W=Jn(a$1,D,U,F===-1?void 0:F);if(!W)return {ok:false,reason:"merge-refused"};if(a$1=W,W=Jn(a$1,a$1.parts.get(N.name),d),!W)return {ok:false,reason:"merge-refused"};a$1=W;}let dn=[...ko(i,u,x)].map(Ie).map(N=>It(N,{styleIds:m,numIds:l,relIds:V.relIdMap,footnoteIds:ie,endnoteIds:se$1,bookmarkIds:At,sdtIds:De,revisionIds:an,docPrIds:sn}));return {ok:true,pkg:a$1,blocks:dn}}var Ws=16*1024*1024;function Wc(e){let t=e.parts.get(e.mainDocumentPart);if(!t||t.root.kind!=="document")return false;let n=t.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>_j)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>ak))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!o(l,a+1,s))return false;return true};for(let i of n.children)if(!o(i,1,$j))return false;for(let[i,a]of e.parts)if(i!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,$j*4))return false;return true}function Io(e,t,n){if(n.fragmentBytes.byteLength>Ws)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=ne(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!Wc(o))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:a,story:s}=i;if(a.compositionActive||e.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=e.currentPackage(),d=a.checkpoint();a.graftPackage(()=>e.currentPackage());let c=0,u="";return Fa(e,()=>{let f=a.transact(m=>{for(let P of n.priorOps??[])if(!m.apply(P))return;let g=null,y=m.applyPackage(P=>(g=vo(P,o,s.partName),g.ok?g.pkg:P)),O=g;if(!O||!O.ok){u=`fragment-merge:${O?O.reason:"no-merge"}`,m.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}y&&(c=O.blocks.length,m.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:O.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return u.length>0?{ok:false,reason:"invalidArgs",detail:u}:f.ok?f.change?{ok:true,change:e.promoteStoryTransactionToPackageUnit(l,a,d),blockCount:c}:{ok:true,change:null,blockCount:c}:{ok:false,reason:f.reason,...f.detail?{detail:f.detail}:{}}},f=>Ga(f))}function Gs(){let e=null;return (t,n,r)=>{let o=e;if(e=null,!xj(n)||!("paragraphId"in r)||!zj(t,r.paragraphId))return r;if(r.op==="insertText"&&!r.revision&&r.inside===void 0&&o&&o.partName===t.name&&o.paragraphId===r.paragraphId&&o.offset===r.offset)return {...r,inside:o.controlId};if(r.op!=="deleteText"||r.revision||r.start>=r.end)return r;let i=Ka(t,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=Ej(t,Dj(r));if(a.unprotected.length)return r;let s=Rf(i);for(let l of a.touches){let d=s.spanOf(l.control);d&&d.start<=r.start&&d.end>=r.end&&(e={partName:t.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}var Ks=new WeakSet;function Gc(e){return Ks.add(e),e}function Xs(e){return Ks.has(e)}function Qt(e){return {...e,applyPackage:t=>e.applyPackage(Gc(t))}}var Kc=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertDrawing","deleteText"]),Ys=new Set(["insertDrawing"]);function Xc(e){if(!(e===null||e.start!==e.end))return e}var St={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function Yc(e){return Object.freeze({parts:new Map([[e.name,e]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[e.name.toLowerCase(),e.contentType]])},mainDocumentPart:e.name})}var ct=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(t,n,r={}){let o="root"in t,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?Yc(t):t,this.storyPartName=i??(o?t.name:t.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart;}setStoryRef(t){this.storyRef=t;}get part(){let t=this.current.parts.get(this.storyPartName);if(!t)throw new Error(`story part missing: ${this.storyPartName}`);return t}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(t){this.current=t(this.current);}replacePart(t){let n=this.current.parts.get(t.name);t!==n&&(this.current=pe(this.current,t),this.rev+=1);}checkpoint(){return {pkg:this.current,revision:this.rev,undoStack:this.undoStack.slice(),redoStack:this.redoStack.slice(),composition:this.composition?{entry:{...this.composition.entry},committed:this.composition.committed}:null}}restoreCheckpoint(t){this.current=t.pkg,this.rev=t.revision,this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack),this.composition=t.composition?{entry:{...t.composition.entry},committed:t.composition.committed}:null;}restoreHistoryStacks(t){this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack);}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}transact(t,n={}){return tb(n.actorId,()=>this.commitTransaction(t,n))}commitTransaction(t,n){let r=n.origin??b.mutationHuman,o=n.recordsHistory??(r!==b.projection&&r!==b.awareness),i=this.undoStack[this.undoStack.length-1];o&&!this.composition&&i?.group!==n.historyGroup&&this.closeHistoryGroup();let a=this.current,s=this.rev,l=this.current,d=null,c=0,u=new Set,f=new Set,x=new Set,m=new Set,g=new Set,y=[],O=n.minimumImpact??"text-local",P=null,p=false,k=null,v=null,R=new Map,h=new Map,C=M=>{let $=h.get(M.name);$||($={mint:null,written:new Set},h.set(M.name,$));let K=$;return {mint:()=>(K.mint??=Xg(M))(),wrote:S=>{K.written.add(S);},wroteUnder:S=>K.written.has(S)}},I=()=>{for(let M of h.values())M.mint=null;},j=(M,$)=>{let K=Yi$1.get(M.op);if(K===void 0)return R.clear(),null;let S=`${$.name}\0${K}`,b=R.get(S);b||(b={id:null},R.set(S,b));let A=b;return ()=>A.id??=C($).mint()},_=(M,$)=>{let K=Kc.has(M.op);return !K&&Yi$1.get(M.op)!==void 0?null:((!K||Ys.has(M.op))&&I(),K?C($):null)},J=Gs(),H=null,T=(M,$)=>{if(d)return false;let K=l.parts.get(M);if(!K)return d={reason:"unknown-part",detail:M},false;$=J(K,this.settingsPartOverride?.()??Ag(l),$);let S=wj(this.settingsPartOverride?.()??Ag(l),$)??Fj(K,this.settingsPartOverride?.()??Ag(l),$,H?.partName===M&&"paragraphId"in $&&H.paragraphId===$.paragraphId?H.fieldNodeId:void 0);if(S)return d={reason:S},false;let b=j($,K),A=_($,K),X=this.settingsPartOverride?.()??Ag(l),ee=xj(X)&&"paragraphId"in $&&zj(K,$.paragraphId)?Bi(K,$,H?.partName===M&&H.paragraphId===$.paragraphId?H.fieldNodeId:void 0):null;H=ee&&"paragraphId"in $?{partName:M,paragraphId:$.paragraphId,fieldNodeId:ee.fieldNodeId}:null;let le={deferValidation:true,...b?{revisionIds:b}:{},...A?{trackedRevisionIds:A}:{}},z=ee?Hi(K,$,ee,le):dk(K,$,le);if(!z.ok)return d={reason:z.reason,...z.detail?{detail:z.detail}:{}},false;if(Ys.has($.op)&&I(),l=pe(l,z.part),z.part===K&&z.effect.dirty.length===0&&z.effect.created.length===0&&z.effect.deleted.length===0&&z.effect.split===void 0&&(z.effect.splits===void 0||z.effect.splits.length===0)&&z.effect.join===void 0&&z.effect.caret===void 0)return true;u.add(M),c+=1;for(let pe of z.effect.dirty)f.add(pe);for(let pe of z.effect.created)x.add(pe);for(let pe of z.effect.deleted)m.add(pe);for(let pe of z.effect.dependencyKeys)g.add(pe);z.effect.split&&y.push({split:z.effect.split});for(let pe of z.effect.splits??[])y.push({split:pe});return z.effect.join&&y.push({join:z.effect.join}),St[z.effect.impact]>St[O]&&(O=z.effect.impact),z.effect.caret&&(v={paragraphId:z.effect.caret.paragraphId,start:0,end:0}),true};if(t({apply:M=>T(this.storyPartName,M),applyTo:(M,$)=>T(M,$),applyPackage:M=>{if(d)return false;let $=this.settingsPartOverride?.()??Ag(l),K=Xs(M)?vj($,{op:"comment"}):wj($);if(K)return d={reason:K},false;R.clear(),I();let S=M(l);if(S===l)return true;for(let[b,A]of S.parts)l.parts.get(b)!==A&&u.add(b);return l=S,c+=1,St["flow-structural"]>St[O]&&(O="flow-structural"),true},selectionBefore:M=>{P=M;},selectionAfter:M=>{p=true,k=M;}}),d){let M=d;return {ok:false,reason:M.reason,...M.detail?{detail:M.detail}:{}}}if(c===0)return {ok:true,change:null};let V=p?k:v,ie=p?Xc(k):v??void 0;for(let M of u){let $=a.parts.get(M),K=l.parts.get(M);if(K===void 0)continue;let S=$?ya($,K):ya(K,K);if(!S.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(S.issues)}}let se=Ae$1(l);if(!se.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(se.issues)};if(o)if(this.composition)nk(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:V}};else {let M=n.historyGroup,$=this.undoStack[this.undoStack.length-1];M!==void 0&&$!==void 0&&$.group===M?this.undoStack[this.undoStack.length-1]={...$,selectionAfter:V??$.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:P,selectionAfter:V,group:M}),nk(M,$?.group===M?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&St[n.minimumImpact]>St[O]&&(O=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:f,created:x,deleted:m,dependencyKeys:g,splitJoin:y,impact:O,caret:ie},n.story??this.storyRef??void 0,n.actorId,n.operationId)}}beginComposition(t=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:t,selectionAfter:null},committed:false});}endComposition(){let t=this.composition;this.composition=null,!(!t||!t.committed)&&(this.pushUndo(t.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}closeHistoryGroup(){let t=this.undoStack[this.undoStack.length-1];t===void 0||t.group===void 0||(this.undoStack[this.undoStack.length-1]={...t,group:void 0});}undo(){let t=this.undoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let t=this.redoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(t){this.undoStack.push(t),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(t,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:t,...i?{actorId:i}:{},...a?{operationId:a}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:o?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...o?{story:o}:{}};for(let l of this.subscribers)l(s);return s}};function bo(e,t,n,r){if(!e)return null;if(e.kind==="package")return (r==="undo"?e.selectionBefore:e.selectionAfter)??null;let o=e.partName===t.part.name?t:n.get(e.partName);return (r==="undo"?o?.selectionForUndo():o?.selectionForRedo())??null}function Js(e){let t=null,n;return {context:{selectionBefore(r){t=r,e.selectionBefore(r);},selectionAfter(r){n=r,e.selectionAfter(r);}},snapshot(r){return {selectionBefore:t,selectionAfter:n===void 0?r??null:n}}}}function So(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function qs(e,t){return So(e,t).map(n=>n.name).sort().join(",")}function Qs(e,t,n){if(e.relationships!==t.relationships||e.contentTypes!==t.contentTypes||e.partBytes!==t.partBytes||e.externalTargets!==t.externalTargets||e.mainDocumentPart!==t.mainDocumentPart)return true;if(e.parts===t.parts)return false;if(e.parts.size!==t.parts.size)return true;for(let[r,o]of t.parts)if(r!==n&&e.parts.get(r)!==o)return true;return false}var Qn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Jc="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Nt(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===Qn&&n.localName===t)return n;return null}function qn(e,t){return e.attributes.find(n=>n.namespaceUri===Qn&&n.localName===t)?.value}function qc(e){let t=qn(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function el(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>el(n,t))})}function Qc(e){let t=Aa(`<w:styles xmlns:w="${Qn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:Jc});if(!t.ok)return null;let n=Nt(t.part.root,"style"),r=n?Nt(n,"pPr"):null;return r?el(r,Ia(e)):null}var Zs=["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"];function Zc(e,t){let n=Zs.indexOf(t),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=Zs.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function tl(e,t){let n=Oc$1(e);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Qn&&d.localName==="style"&&qn(d,"type")==="paragraph"&&qn(d,"styleId")===t){r=d;break}if(!r)return null;let o=Nt(r,"name");if(o&&qn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let i=Qc(n);if(!i)return null;let a=Nt(i,"contextualSpacing");if(!a)return null;let s=Nt(r,"pPr"),l;if(s){let d=Nt(s,"contextualSpacing");if(d&&qc(d))return e;l=d?Pa(n,d.id,a):Oa(n,s.id,Zc(s.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=Oa(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,l.part]])}):null}var al="http://schemas.openxmlformats.org/package/2006/relationships",il="application/vnd.openxmlformats-package.relationships+xml",nm="http://schemas.openxmlformats.org/package/2006/content-types",nl="/[Content_Types].xml",mt="/word/numbering.xml",rl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",Zt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",rm=`<Override PartName="${mt}" ContentType="${Zt}"/>`;function Zn(e){return `${e.ownerPart}\0${e.id}`}function sl(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===id$1).map(Zn)),o=n.externalTargets.filter(s=>s.type===id$1&&!r.has(Zn(s)));if(o.length===0)return e;let i=new Set(e.map(Zn)),a=o.filter(s=>!i.has(Zn(s)));return a.length===0?e:Object.freeze([...e,...a])}function ll(e,t,n){let r=e.filter(o=>o.ownerPart===n||t.has(o.ownerPart));return r.length===e.length?e:Object.freeze(r)}function dl(e,t,n=[],r=false){if(e===t)return e;let o=om(e,t,r);return o=im(o,t,n),o}function cl(e,t){let n=new Set;for(let o of e.externalTargets)o.type===id$1&&o.ownerPart!==e.mainDocumentPart&&(e.parts.has(o.ownerPart)||t.has(o.ownerPart)||n.add(o.ownerPart));for(let o of e.parts.keys()){let i=cm(o);!i||i===e.mainDocumentPart||e.parts.has(i)||t.has(i)||e.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return e;let r=e;for(let o of n)r=mm(r,o);return r}function om(e,t,n){let r=t.parts.get(mt);if(!r)return e;let o=e.parts.get(mt),i=n&&o?am(o,r):r,a=pe(e,i),s=(t.relationships.get(t.mainDocumentPart)??[]).find(d=>d.type===rl),l=a.relationships.get(a.mainDocumentPart)??[];if(s&&!l.some(d=>d.type===rl)&&!l.some(d=>d.id===s.id)){let d=lm(a,{...s,ownerPart:a.mainDocumentPart});d&&(a=d);}if(a.contentTypes.overrides.get(u(mt))!==Zt){let d=um(a);d&&(a=d);}return a}function am(e,t){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let d=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!d)return null;let c=l.attributes.find(u=>u.namespaceUri===n&&u.localName===d)?.value;return c===void 0?null:`${l.localName}:${c}`},o=new Set(e.root.children.map(r).filter(Boolean)),i=Ia(e),a=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=e;for(let l of t.root.children){let d=r(l);if(!d||o.has(d)||l.kind==="textValue")continue;let c=a.indexOf(l.localName),u=s.root.children.findIndex(x=>x.kind!=="textValue"&&x.namespaceUri===n&&a.indexOf(x.localName)>c),f=Oa(s,s.root.id,u<0?s.root.children.length:u,[No(l,i)]);f.ok&&(s=f.part,o.add(d));}return s}function im(e,t,n){let r=n.filter(i=>i.type===id$1);if(r.length===0)return e;let o=e;for(let i of r){let a=sm(e,t,i.ownerPart);if(!a||o.externalTargets.some(d=>d.ownerPart===a&&d.id===i.id)||new Set((o.relationships.get(a)??[]).map(d=>d.id)).has(i.id))continue;let l=dm(o,{ownerPart:a,id:i.id,type:id$1,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function sm(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function lm(e,t){let n=e.mainDocumentPart,r=wo(n),o=e.parts.get(r),i=Aa(`<Relationships xmlns="${al}"><Relationship Id="${P(t.id,"relationship id")}" Type="${P(t.type,"relationship type")}" Target="${P(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:il});if(!i.ok)return null;let a=e.relationships.get(n)??[];if(a.some(d=>d.id===t.id))return null;let s={...t,ownerPart:n,order:a.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...e.relationships,[n,[...a,s]]]);return o?ml(e,o,i.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:l})}function dm(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=wo(r),i=e.parts.get(o),a=Aa(`<Relationships xmlns="${al}"><Relationship Id="${P(t.id,"relationship id")}" Type="${id$1}" Target="${P(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:il});if(!a.ok)return null;let s=[...e.externalTargets,t];if(!i)return Object.freeze({...e,parts:new Map([...e.parts,[o,a.part]]),externalTargets:s});let l=ml(e,i,a.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function ml(e,t,n,r){if(!n)return null;let o=Ia(t),i=Oa(t,t.root.id,t.root.children.length,[No(n,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,i.part]]),relationships:r}):null}function No(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>No(n,t))}}function wo(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function cm(e){let t=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(e);if(!t)return null;let n=t[1],r=t[2];return n===""||r===""?null:`${n}/${r}`}function mm(e,t){let n=wo(t),r=new Map(e.parts);r.delete(n);let o=new Map(e.partBytes);o.delete(n);let i=new Map(e.relationships);i.delete(t);let a=Object.freeze(e.externalTargets.filter(s=>s.ownerPart!==t));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function um(e){let t=e.contentTypes.overrides.get(u(mt));if(t===Zt)return e;if(t!==void 0)return null;let n=e.partBytes.get(nl);if(!n)return null;let r=strFromU8(n),o=ol(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+rm+r.slice(i),s=ol(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,ul("Override",{PartName:mt,ContentType:Zt})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[nl,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[u(mt),Zt]])})})}function ol(e){let t=X(e);if(!t.ok)return null;let n=t.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),i=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==nm)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(ul(s.name,s.attributes));return {rootName:r.name,children:a}}function ul(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}var pl=4e3,fl=64;function gl(e){return Lg(e,"footnote")!==null||Lg(e,"endnote")!==null}function hl(e,t,n,r){if(!gl(e))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=Ka(t,n.paragraphId);return !o||o.kind!=="paragraph"?true:Pf(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function yl(e,t,n,r){if(!gl(e))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=Ka(t,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=pl||l>fl)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return Pf(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(a(d,l+1))return true;return false};return a(o,0)}function xl(e,t,n){if(n.count>=pl||t>fl)return true;if(n.count+=1,e.kind==="textValue")return false;if(e.kind==="commentRangeStart"||e.kind==="commentRangeEnd"||e.kind==="commentReference")return true;for(let r of e.children)if(xl(r,t+1,n))return true;return false}function kl(e,t,n,r){if(!Mh(e))return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=Ka(t,o);return !i||i.kind==="textValue"?true:xl(i,0,{count:0})}var Eo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",To="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Pl(e,t){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===t);return r?r.type!==Eo&&r.type!==To?{ok:false,reason:"wrong-relationship-type",detail:r.type}:pm(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function pm(e,t){let n=E(t);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:t.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=e.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}var Co=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),Mo=new Set(["authorTable","deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]);function ut(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Rl(e,t){let n=Ka(e,t);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function Ol(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Ka(r,n);return !o||o.kind!=="drawing"?null:yd$1(o,{ownerPartName:t,supportedMcRequires:rd$1,limits:qd$1,resolveRelationship:td$1(e,t)})}function vl(e,t,n){let r=F(e.relationships.get(t)??[],t,n);return r.mode==="internal"?r.partName:null}function wt(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=ut(e,o.store);if(i)return i;let{store:a,story:s}=o;return Fa(e,()=>fm(e,a,s,n,r),l=>Ga(l))}function fm(e,t,n,r,o){let i=n.partName,a=e.currentPackage(),s=t.checkpoint();t.graftPackage(()=>e.currentPackage());let l=null,d=false,c=false,u=t.transact(m=>{if(o?.commitGuard?.()===false){c=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){d=true;return}let g=r(m,i);if(g===null){m.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=g;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(c)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(d)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!u.ok)return {ok:false,reason:u.reason,...u.detail?{detail:u.detail}:{}};if(!u.change)return {ok:true,change:null};let f=u.change.created.find(m=>{let g=t.part;return Ka(g,m)?.kind==="drawing"});return f&&(l=f),{ok:true,change:e.promoteStoryTransactionToPackageUnit(a,t,s),...l?{drawingNodeId:l}:{}}}function Il(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Rl(r,n);return o?Vj(o):null}function Ao(e,t,n,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(t);if(!a)return i;let s=Ka(a,n);if(!s||s.kind!=="drawing")return i;let l=Rl(a,n);if(!l)return i;let d=Wj(l,r),c=gm(s,d),u=Pa(a,s.id,c,{deferValidation:true});return u.ok?(o=true,pe(i,u.part)):i}),o}function gm(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function bl(e,t,n){let r=he(n.widthPoints),o=he(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=ut(e,i.store);if(a)return a;let s=i.story.partName,l=await ce$1(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=ee(e.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,f=wt(e,t,(x,m)=>{let g=e.currentPackage(),y=ee(g,m,{bytes:d,mime:n.mime});if(!y.ok)return null;g=y.pkg,u=y.partName;let O;if(n.hyperlink){let p=og(g,n.hyperlink,m);if(!p)return null;g=p.pkg,O=p.relationshipId;}if(!x.applyPackage(()=>g))return null;let P=ie({docPrId:y.docPrId,relationshipId:y.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...O?{hyperlinkRelationshipId:O}:{}});return x.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:P,...n.revision?{revision:n.revision}:{}})?P.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return f.ok?f.change?{...f,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:f}async function Do(e,t,n,r,o,i,a){let s=e.resolveStory(t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=ut(e,s.store);if(l)return l;let d=s.story.partName,c=await ce$1(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,f=ee(e.currentPackage(),d,{bytes:u,mime:o});return f.ok?wt(e,t,(x,m)=>{let g=e.currentPackage(),y=Ol(g,d,n),O=y?.picture?.embeddedRelationshipId??null,P=y?.picture?.linkedRelationshipId??null,p=O??P;if(!p)return null;let k=O!==null?vl(g,d,O):null,v=g,R=ee(v,m,{bytes:u,mime:o});return !R.ok||(v=R.pkg,!x.applyPackage(()=>v))||!x.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:R.relationshipId})?null:(x.applyPackage(h=>ke(h,m,k,p)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:f.reason==="invalid-image"?"invalid-image":f.reason}}function Sl(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=ut(e,r.store);if(o)return o;let i=r.story.partName,a=e.currentPackage(),s=a.parts.get(i),l=Ol(a,i,n)??(s?Mj(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let d=l.picture?.embeddedRelationshipId??null,c=l.picture?.linkedRelationshipId??null,u=d??c,f=d!==null?vl(a,i,d):null;return wt(e,t,(x,m)=>x.apply({op:"deleteDrawing",drawingNodeId:n})?(x.applyPackage(g=>ke(g,m,f,u)),n):null)}function hm(e,t){let n=null,r=i=>{let a=false,s=false,l=(d,c)=>{if(a||d.kind==="textValue")return;if(d.id===t){a=true,s=c;return}let u=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let f of d.children)l(f,u);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=Rf(i).spanOf(t);if(a!==null&&a.end>a.start){let s=Ka(e,t);if(!s||s.kind!=="drawing"&&!ud$1(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(e.root),n}function Nl(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=ut(e,o.store);if(i)return i;let a=e.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=hm(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:wt(e,t,l=>l.apply({op:"deleteText",paragraphId:s.paragraphId,start:s.start,end:s.end,revision:r})?n:null):{ok:false,reason:"unknown-drawing"}}async function wl(e,t,n,r,o,i,a,s){let l=await le(o,r,i,void 0,a);return l.ok?Do(e,t,n,l.bytes,l.mime,a,{expectedPackageRevision:e.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function El(e,t,n,r,o,i){let a=e.resolveStory(t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=ut(e,a.store);return s||wt(e,t,(l,d)=>{let c=Il(e.currentPackage(),d,n),u=null;if(i!==null){let x=og(e.currentPackage(),i,d);if(!x||!l.applyPackage(()=>x.pkg))return null;u=x.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!Ao(l,d,n,u))return null}else if(i===null&&!Ao(l,d,n,null))return null;let f=false;return l.applyPackage(x=>{let m=qg(x,d,c);return m===null?(f=true,x):m}),f?null:n})}function Tl(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=ut(e,r.store);return o||wt(e,t,(i,a)=>{let s=Il(e.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=og(e.currentPackage(),n.hyperlink,a);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!Ao(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let u=qg(c,a,s);return u===null?(d=true,c):u}),d?null:n.drawingNodeId})}function ym(e,t){if(e===t)return true;if(e.byteLength!==t.byteLength)return false;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return false;return true}function Cl(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e)if(t.get(n)!==r)return false;return true}function xm(e,t){return e===t||e.ownerPart===t.ownerPart&&e.id===t.id&&e.type===t.type&&e.rawTarget===t.rawTarget&&e.targetMode===t.targetMode&&e.order===t.order}function km(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!xm(i,o[a])))return false}return true}function Pm(e,t){return e===t?true:e.length!==t.length?false:e.every((n,r)=>{let o=t[r];return n===o||n.ownerPart===o.ownerPart&&n.id===o.id&&n.type===o.type&&n.rawTarget===o.rawTarget&&n.sinkSafe===o.sinkSafe})}function Rm(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||!ym(r,o))return false}return true}function Om(e,t){return e.contentTypes===t.contentTypes||Cl(e.contentTypes.defaults,t.contentTypes.defaults)&&Cl(e.contentTypes.overrides,t.contentTypes.overrides)}var er=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),tr=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function Ml(e){for(let[t,n]of e)if(!va(t,n))return tr;return er}function vm(e,t){if(e===t)return er;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Rm(e.partBytes,t.partBytes)||!km(e.relationships,t.relationships)||!Pm(e.externalTargets,t.externalTargets)||!Om(e,t))return tr;let n=[];for(let[a,s]of e.parts){let l=t.parts.get(a);if(!l)return tr;s!==l&&n.push([s,l]);}if(n.length===0)return er;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return Ml(n);let i=wa(o.root,r.root);return i.undecided?Ml(n):i.equal?er:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?tr:{equal:false,dirty:i.paragraphIds,dependencyKeys:[g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function _o(e){return {ok:false,reason:"package-invariant",detail:e}}function Im(e,t){if(!e.parts.get(e.mainDocumentPart))return _o("no-main-document");for(let[r,o]of e.parts){let i=t?.parts.get(r);if(i===o)continue;let a=i?ya(i,o):xa(o);if(!a.ok)return _o(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=Ae$1(e);return n.ok?null:_o(n.issues[0]?.code??"package-invariant")}function Al(e,t,n){let r=e.currentPackage(),o=vm(t,r);if(o.equal)return {ok:true,change:null};let i=Im(t,r);if(i)return i;let a=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===a;return Fa(e,()=>{let l=e.packageRevision;return e.installAuthoritativePackageSnapshot(t),{ok:true,change:e.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?o.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?o.dependencyKeys:[],impact:s?o.impact:"global",story:{kind:"body",partName:a}})}},()=>false)}function Fl(e,t,n,r){let o=[...t],i=new Set;for(let a of o)e.parts.has(a)&&i.add(a);for(let a of n)Dl(a,o,i);for(let a of r)Dl(a,o,i);return i}function Ll(e,t,n,r,o){let i=new Set(e);i.add(t),i.add(n);for(let a of r)_l(a,i);for(let a of o)_l(a,i);return i}function Dl(e,t,n){if(e.kind==="story"){n.add(e.partName);return}for(let r of t)(e.before.parts.has(r)||e.after.parts.has(r))&&n.add(r);}function _l(e,t){if(e.kind==="story"){t.add(e.partName);return}for(let n of e.before.parts.keys())t.add(n);for(let n of e.after.parts.keys())t.add(n);}var $l=64,en=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(t,n,r={}){this.pkg=pe(t,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??$l,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??Dh,this.body=new ct(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>Ag(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name}),ok(this,{current:()=>this.undoOrder.at(-1)??null,split:()=>{lk(this.body,this.stories,null),this.redoOrder.length=0;}});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let t=this.currentPackageMemo;if(t&&t.pkg===this.pkg&&t.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(t.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===t.storyParts.length)return t.result}let n=pe(this.pkg,this.body.part),r=[];for(let o of this.stories.values())r.push(o.part),this.pkg.parts.has(o.part.name)&&(n=pe(n,o.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}resolveStory(t){return t.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:t.kind==="notesPart"?t.noteKind!=="footnote"&&t.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(t.noteKind)}:this.openNotesPartStore(t.noteKind):t.kind!=="headerFooter"||typeof t.rId!="string"||t.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(t.kind)}:this.openHeaderFooterStore(t.rId)}partFor(t){let n=this.resolveStory(t);return n.ok?n.store.part:null}revisionFor(t){let n=this.resolveStory(t);return n.ok?n.store.revision:null}transact(t,n,r={}){return Fa(this,()=>this.commitStoryTransaction(t,n,r),Ga,r.historyGroup)}commitStoryTransaction(t,n,r={}){let o=this.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,f=new Set,x=false,m=new Set,g=false,y,O=false,P;i.graftPackage(()=>this.currentPackage());let p=i.transact(R=>{P=Js(R),n({...R,applyTo:(h,C)=>{let I=R.applyTo(h,C);return I&&h!==a.partName&&(O=true),I},applyPackage:h=>R.applyPackage(C=>{let I=h(C);return I!==C&&!O&&(O=Qs(C,I,a.partName)),I}),apply:h=>(h.op==="setListNumbering"&&h.numId!==null&&(g=true),h.op==="setParagraphProperties"&&(y??=h.properties.find(C=>C.localName==="pStyle")?.attributes?.val),u||(h.op==="deleteText"&&hl(this.pkg,i.part,h,f)||h.op==="deleteBlock"&&yl(this.pkg,i.part,h,f)||Co.has(h.op)||Mo.has(h.op))&&(u=true),x||(h.op==="deleteText"||h.op==="deleteBlock"?x=kl(this.pkg,i.part,h,m):(Co.has(h.op)||Mo.has(h.op))&&(x=true)),R.apply(h)),...P.context});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!p.ok)return {ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}};this.syncPackageFromStore(i);let k=false;if(p.change&&O&&(this.installPackageSnapshotInternal(i.package,false),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),k=true),g&&y){let R=tl(this.pkg,y);R&&this.replacePackageShell(R);}let v=false;if(p.change&&u){let R=this.currentPackage(),h=this.cascadeNoteReferences(s,R);if(h===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};h!==R&&(this.installPackageSnapshotInternal(h),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),v=true);}if(p.change&&x){let R=this.currentPackage(),h=Qh(s,R,{storyPartName:a.partName});if(h===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};h!==R&&(this.installPackageSnapshotInternal(h),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),v=true);}if(p.change){this.packageRev+=1;let R=v||k;R&&nk(r.historyGroup,"split","package-unit"),!d&&r.recordsHistory!==false&&(i.historyDepth>l||R)&&(R?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...P?.snapshot(p.change.caret)}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let h=R?this.publishSynthetic(p.change.origin,"global",a,p.change.created):p.change;return R||this.publish(h),{ok:true,change:h}}return {ok:true,change:p.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(t,n=null){let r=this.resolveStory(t);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(t),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.endComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),t.packageWideEffects){n.restoreHistoryStacks(t.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:t.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let o=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);o&&this.pushUndoPointer({kind:"story",partName:t.partName,story:o});}this.syncPackageFromStore(n);}cancelComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.cancelComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(t.packageWideEffects){n&&n.restoreCheckpoint(t.storyCheckpoint),this.installPackageSnapshotInternal(t.beforePackage),this.packageRev+=1;let r=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);this.publishSynthetic(b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(t){return Fa(this,()=>this.commitLifecycleOp(t),Ga)}commitLifecycleOp(t){let n=this.currentPackage(),r=vj(Ag(n),t);if(r)return {ok:false,reason:r};if(Bh(t)){let s=Ch(n,t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};if(s.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(s.package),this.pushUndoPointer({kind:"package",before:n,after:s.package}),this.packageRev+=1;let l={kind:"body",partName:this.body.part.name},d=this.publishSynthetic(b.mutationHuman,s.impact,l,s.createdPartName?[s.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:d}}if(!tg(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let o=ug(n,t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};this.installPackageSnapshotInternal(o.package),this.pushUndoPointer({kind:"package",before:n,after:o.package}),this.packageRev+=1;let i={kind:"body",partName:this.body.part.name},a=this.publishSynthetic(b.mutationHuman,o.impact,i,o.createdPartName?[o.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:a}}undo(){let t=this.undoOrder.pop();if(!t)return null;if(lk(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.before,true,t.restoreNumbering),this.redoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let t=this.redoOrder.pop();if(!t)return null;if(lk(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.after,true,t.restoreNumbering),this.undoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){return bo(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return bo(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return So(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return qs(this.stories,this.pkg)}insertImage(t,n){return bl(this,t,n)}applyFragmentPaste(t,n){return Io(this,t,n)}replaceImage(t,n,r,o,i,a){return Do(this,t,n,r,o,i,a)}deleteImage(t,n){return Sl(this,t,n)}deleteImageTracked(t,n,r){return Nl(this,t,n,r)}embedExternalImage(t,n,r,o,i,a,s){return wl(this,t,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(t,n,r,o,i){return El(this,t,n,r,o,i)}applyImageProperties(t,n){return Tl(this,t,n)}promoteStoryTransactionToPackageUnit(t,n,r,o){this.installPackageSnapshotInternal(n.package,false),n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:t,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(t){return t?(this.packageRev+=1,this.publish(t),t):null}adoptPackageUnit(t){let n=this.currentPackage();t!==n&&this.pushUndoPointer({kind:"package",before:t,after:n});}installPackageSnapshot(t){this.installPackageSnapshotInternal(t);}installAuthoritativePackageSnapshot(t){this.installPackageSnapshotInternal(t,false);}publishRemotePackage(t,n){return Al(this,t,n)}replacePackageShell(t){this.shellHyperlinks=sl(this.shellHyperlinks,this.pkg,t);let n=t;n=pe(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=pe(n,r.part));this.pkg=n;}installPackageSnapshotInternal(t,n=true,r=false){let o=n?dl(t,this.pkg,this.shellHyperlinks,r):t,i=o.parts.get(o.mainDocumentPart);if(!i)return;this.body.replacePart(i);for(let[s,l]of this.stories){let d=o.parts.get(s);d&&l.replacePart(d);}this.rIdToPartName.clear();let a=o.relationships.get(o.mainDocumentPart)??[];for(let s of a){if(s.type!==Eo&&s.type!==To)continue;let l=E(s);l.mode!=="Internal"||!l.target.ok||this.stories.has(l.target.partName)&&o.parts.has(l.target.partName)&&this.rIdToPartName.set(s.id,l.target.partName);}this.pkg=o,this.pkg=pe(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=pe(this.pkg,s.part));}openNotesPartStore(t){let n=Lg(this.currentPackage(),t);if(!n)return {ok:false,reason:"missing-part",detail:t};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:t},store:r};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let o=qb(n),i=new ct(o,{historyLimit:this.historyLimit,settingsPart:()=>Ag(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:t};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=pe(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(t){let n=this.rIdToPartName.get(t);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:t},store:l}}let r=Pl(this.currentPackage(),t);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(t,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:t},store:o};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let i=qb(r.part),a=new ct(i,{historyLimit:this.historyLimit,settingsPart:()=>Ag(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:t};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(t,i.name),i!==r.part&&(this.pkg=pe(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(t){if(t===this.body.part.name)return {kind:"body",partName:t};for(let[r,o]of this.rIdToPartName)if(o===t)return {kind:"headerFooter",partName:t,rId:r};let n=this.currentPackage().parts.get(t);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:t,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:t,noteKind:"endnote"}:null}syncPackageFromStore(t){this.pkg=pe(this.pkg,t.part);}pushUndoPointer(t){lk(this.body,this.stories,t),t.kind==="package"&&t.before.parts.get("/word/numbering.xml")!==t.after.parts.get("/word/numbering.xml")&&(t={...t,restoreNumbering:true}),this.undoOrder.push(t),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let t=Fl(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[o]of [...this.stories])if(!t.has(o)){this.stories.delete(o);for(let[i,a]of [...this.rIdToPartName])a===o&&this.rIdToPartName.delete(i);}let n=Ll(t,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=cl(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=ll(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(t){this.lastChange=t;for(let n of this.subscribers)n(t);}publishSynthetic(t,n,r,o){this.commitCounter+=1;let i=this.packageRev-1,a={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:t,dirty:[],created:[...o],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(a),a}};var bm=256,Sm=65535,Ul=64;function nr(e,t){return e.length>t}function Bl(e){return typeof e!="string"||e.trim().length===0?"invalid-author":nr(e,bm)?"resource-limit":O(e)?null:"invalid-author"}function jl(e){return typeof e!="string"||e.length===0?"invalid-text":nr(e,Sm)?"resource-limit":O(e)?null:"invalid-text"}function Fo(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(nr(t,Ul))return {ok:false,rejection:"resource-limit"};if(!O(t))return {ok:false,rejection:"invalid-date"};let n=Hf(t);return n===null?{ok:false,rejection:"invalid-date"}:nr(n,Ul)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function Zh(e){if(e===void 0)return null;let t=Fo(e);return t.ok?null:t.rejection}function Lo(e){switch(e){case "invalid-author":return "invalid-author";case "invalid-text":return "invalid-text";case "invalid-date":return "invalid-property-value";case "resource-limit":return "resource-limit"}}function Nm(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function $o(e,t){if(!e){let a=ub(t);return a?wb(new Set,a,rb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Nm(a,fa,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=rb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(e.root);let i=ub(t);return i?wb(r,i,rb):String(n+1)}function Hl(e,t){if(e.kind==="textValue")return e;let n=t.get(e.id);if(n!==void 0)return n;let r=false,o=[];for(let i of e.children){let a=Hl(i,t);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function Tm(e,t,n){let r=Hl(e.root,t);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:e.root.id,nodeId:e.root.id}]};let o=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:ja}]};return Pa(e,e.root.id,o,{deferValidation:true})}function Vl(e,t,n){let r=new Map;for(let i of t){if(i.stampParagraph===null)continue;let a=r.get(i.commentsPartName);a||(a=new Map,r.set(i.commentsPartName,a)),a.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let o=e;for(let[i,a]of r){let s=o.parts.get(i);if(!s)return null;let l=mb(s.root),d=l??"w14",c=new Map;for(let f of a.values())c.set(f.paragraph.id,n(f.paragraph,f.paraId,d));let u=Tm(s,c,l===null?d:null);if(!u.ok)return null;o=pe(o,u.part);}return o}function zl(e,t,n){let r=e.root.children.map(o=>o.kind==="textValue"?o:t.get(o.id)??o);return Na(e,e.root.id,[...r,...n],{deferValidation:true})}var Kl="/word/comments.xml",Xl="/word/commentsExtended.xml",Vo="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",zo="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Cm=[zo,"application/vnd.ms-word.commentsExtended+xml"],Yl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Wo="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",et="http://schemas.microsoft.com/office/word/2012/wordml";function nn(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Et(e,t){return {kind:"genericExtension",namespaceUri:fa,localName:e,prefix:"w",value:t}}function Ge(e,t,n,r,o,i,a,s=[]){return {id:e,kind:t,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function Jl(e,t,n,r,o){let i=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let a of i)for(let s of re(e,a)){if(s.type!==n)continue;let l=w(a,s.rawTarget);if(!l.ok)continue;if(!e.parts.has(l.partName))return l.partName;let d=se(e,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return o}function Uo(e,t,n){let r=e.mainDocumentPart;for(let i of re(e,r)){if(i.type!==t)continue;let a=w(r,i.rawTarget);if(a.ok&&a.partName===n)return e}let o=xe(e,r);return ye(o,r,t,bi(r,n)).pkg}function Go(e,t){return Jl(e,t,Yl,Vo,Kl)}function ql(e,t){let n=Id$1(e,t),r=Jd$1(e,t,n).extended;return r!==null?r:Jl(e,t,Wo,Cm,Xl)}function Wl(e){let t=new Set;for(let n of e.parts.values())for(let r of lb(n.root))t.add(r);return t}function Mm(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=nn(a,ja,"paraId");s!==void 0&&hb(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),n}function Am(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){n=a;return}}return}for(let i of o.children)r(i);}};return r(e.root),n}function Ql(e){let t=mb(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:ja}]},r=Pa(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(Ma(e.root,n),{part:{...e,root:n},prefix:"w14"})}function Zl(e,t,n){return Ge(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===ja&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:ja,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function Dm(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let i=Ql(o),a=Ka(i.part,n);if(!a||a.kind!=="paragraph")return pe(e,i.part);let s=Pa(i.part,a.id,Zl(a,r,i.prefix),{deferValidation:true});return pe(e,s.ok?s.part:i.part)}function _m(e,t,n,r){let o=`${Kl}#comment-${e}`,i=n.text!==n.text.trim(),a=Ge(`${o}.t`,"text",fa,"w","t",i?[{kind:"xmlSpace",namespaceUri:ga,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=Ge(`${o}.rPr`,"runProperties",fa,"w","rPr",[],[Ge(`${o}.rStyle`,"generic",fa,"w","rStyle",[Et("val","CommentReference")],[])]),l=Ge(`${o}.r`,"run",fa,"w","r",[],[s,a]),d=Ge(`${o}.pPr`,"paragraphProperties",fa,"w","pPr",[],[Ge(`${o}.pStyle`,"generic",fa,"w","pStyle",[Et("val","CommentText")],[])]),c=Ge(`${o}.p`,"paragraph",fa,"w","p",[{kind:"genericExtension",namespaceUri:ja,localName:"paraId",prefix:r,value:t}],[d,l]);return Ge(o,"comment",fa,"w","comment",[Et("id",e),Et("author",n.author),...n.initials===void 0?[]:[Et("initials",n.initials)],...n.date===void 0?[]:[Et("date",n.date)]],[c])}function Bo(e,t){let n=Aa(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function Ko(e,t){for(let O of [Bl(t.author),jl(t.text)])if(O)return {ok:false,reason:Lo(O)};let n;if(t.date!==void 0){let O=Fo(t.date);if(!O.ok)return {ok:false,reason:Lo(O.rejection)};n=O.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,i=e.part.name,a=Go(o,i),s=ql(o,i),l=o.parts.get(a),d=$o(l,r.actorId),c=kb(`${a}#${d}`,Wl(o)),u=t.replyToCommentId===void 0?null:Mm(l,t.replyToCommentId),f=t.replyToCommentId!==void 0&&u===null?Am(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&u===null&&!f)return {ok:false,reason:"unknown-revision"};let x=f?kb(`${a}#parent-${t.replyToCommentId}`,new Set([...Wl(o),c])):null,m=u??x,g=t.anchor.endParagraphId??t.anchor.paragraphId,y=e.transact(O=>{let P=Qt(O);P.applyPackage(p=>{let k=p.parts.has(a)?p:(()=>{let v=Bo(a,`<w:comments xmlns:w="${fa}"/>`);return v?ze$1(p,a,v,Vo):null})();return k===null?p:Uo(k,Yl,a)}),f&&x&&P.applyPackage(p=>Dm(p,a,f.id,x)),P.applyPackage(p=>{let k=p.parts.get(a);if(!k)return p;let v=Ql(k),R=Oa(v.part,v.part.root.id,v.part.root.children.length,[_m(d,c,r,v.prefix)],{deferValidation:true});return R.ok?pe(p,R.part):p}),m!==null&&(P.applyPackage(p=>{let k=p.parts.has(s)?p:(()=>{let v=Bo(s,`<w15:commentsEx xmlns:w15="${et}"/>`);return v?ze$1(p,s,v,zo):null})();return k===null?p:Uo(k,Wo,s)}),P.applyPackage(p=>{let k=p.parts.get(s);if(!k)return p;let R=[...Fm(k).has(m.toUpperCase())?[]:[Ho(`${s}#ex-${m}`,m,void 0,false)],Ho(`${s}#ex-${c}`,c,m,false)],h=Oa(k,k.root.id,k.root.children.length,R,{deferValidation:true});return h.ok?pe(p,h.part):p})),P.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"reference"}),P.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"end"}),P.applyTo(i,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return y.ok?{ok:true,commentId:d,change:y.change}:{ok:false,reason:y.reason}}function jo(e){for(let t=e.children.length-1;t>=0;t-=1){let n=e.children[t];if(n.kind==="paragraph")return n}return null}function Gl(e){let t=jo(e);if(!t)return null;let n=nn(t,ja,"paraId");return n!==void 0&&hb(n)?n.toUpperCase():null}function Fm(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===et&&r.localName==="commentEx"){let o=nn(r,et,"paraId");o!==void 0&&hb(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function tn(e,t){return {kind:"genericExtension",namespaceUri:et,localName:e,prefix:"w15",value:t}}function Lm(e,t){return {id:e.id,kind:"generic",namespaceUri:e.namespaceUri,localName:e.localName,...e.prefix===void 0?{}:{prefix:e.prefix},namespaceBindings:e.namespaceBindings,attributes:t,children:e.children}}function $m(e,t,n){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===et&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===et&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&t!==void 0&&r.push(tn("paraIdParent",t)),o||r.push(tn("done",n?"1":"0")),Lm(e,r)}function Ho(e,t,n,r){return {id:e,kind:"generic",namespaceUri:et,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[tn("paraId",t),...n===void 0?[]:[tn("paraIdParent",n)],tn("done",r?"1":"0")],children:[]}}function Xo(e,t,n){return Um(e,t,n,Hd$1())}function Um(e,t,n,r){let o=e.package,i=e.part.name;if(Id$1(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=Fh(o,t,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=Kd(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,u=[];for(let g of s.ids){let y=s.records.get(g);if(!y)return {ok:false,reason:"unknown-comment"};if(!jo(y.node))return {ok:false,reason:"unknown-comment"};let P=Gl(y.node),p=P??kb(`${y.partName}#done-${g}`,d);P===null&&d.add(p),c.set(g,p);}for(let g of s.ids){let y=s.records.get(g),O=jo(y.node),P=c.get(g),p=Gl(y.node),k=s.parentCommentIdByChildId.get(g),v=s.parentParaIdByCommentId.get(g)??(k===void 0?void 0:c.get(k)),R=s.commentExByParaId.get(P);u.push({paraId:P,stampParagraph:p===null?O:null,commentsPartName:y.partName,parentParaId:v,existing:R?.node,existingParentParaId:R?.parentParaId,existingDone:R?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(g=>g.existingDone===n))return {ok:true,changed:false,change:null};let f=s.extendedPartName??Xl,x=s.extendedPartName===null,m=e.transact(g=>{Qt(g).applyPackage(O=>{let P=Vl(O,u,Zl);if(P===null)return O;let p=P;if(!p.parts.has(f)){let C=Bo(f,`<w15:commentsEx xmlns:w15="${et}"/>`);if(!C)return O;let I=ze$1(p,f,C,zo);p=x?Uo(I,Wo,f):I;}let k=p.parts.get(f);if(!k)return O;let v=new Map,R=[];for(let C of u){let I=C.existingParentParaId??C.parentParaId;C.existing?v.set(C.existing.id,$m(C.existing,I,n)):R.push(Ho(`${f}#done-${C.paraId}`,C.paraId,I,n));}let h=zl(k,v,R);return h.ok?pe(p,h.part):O});});return m.ok?{ok:true,changed:true,change:m.change}:{ok:false,reason:m.reason}}function Bm(e,t){let n=Go(e,t);return e.parts.has(n)&&se(e,n)===Vo}function jm(e,t){return Go(e,t)}function Hm(e,t){return ql(e,t)}var ed={kind:"body"};function Vm(e,t,n=ed){let r=n.kind==="body"?null:e.resolveStory(n),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),Fa(e,()=>{let s=Ko(o,t);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Ga(s))}function zm(e,t,n){let r=e.bodyStore(),o=e.currentPackage(),i=vj(Ag(o),{op:"setCommentResolved"});if(i)return {ok:false,reason:i};let a=r.checkpoint();return r.graftPackage(()=>e.currentPackage()),Fa(e,()=>{let s=Xo(r,t,n);return !s.ok||!s.changed||(r.restoreHistoryStacks(a),e.replacePackageShell(r.package),e.adoptPackageUnit(o),e.publishStoryWrite(s.change)),s},s=>s.ok&&s.changed)}function Wm(e,t,n=ed,r){if(t.length===0||vj(Ag(e.currentPackage()),{op:"deleteComments"}))return false;let o=n.kind==="body"?e.bodyStore().part:e.partFor(n);if(!o)return false;let i={storyPartName:o.name,...r===void 0?{}:{noteId:r}},a=e.bodyStore(),s=e.currentPackage(),l=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),Fa(e,()=>{let d=false,c=false,u=a.transact(f=>{Qt(f).applyPackage(m=>{let g=m;for(let y of t){let O=y.parentCommentId===void 0?Oh(g,y.commentId,i):Ph(g,y.commentId,y.parentCommentId,i);if(O===null)return d=true,m;c||=O!==g,g=O;}return g});});return d||!u.ok||!c?false:(a.restoreHistoryStacks(l),e.installPackageSnapshot(a.package),e.adoptPackageUnit(s),e.publishStoryWrite(u.change),true)},d=>d)}var nd=256*1024,rd=4096;function Yo(e,t,n){let r=t.payload,o=e.part.name,i=n??o;if(r){if(r.data.length>nd)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>rd)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(Mb(e.part.root).map(f=>f.node.id)),s=t.replaceControlId===void 0?[]:od(e,o,t.replaceControlId),l=null,d,c=e.transact(f=>{if(t.replaceControlId!==void 0){f.apply({op:"removeContentControl",controlId:t.replaceControlId,keepContent:false});for(let g of s)f.applyPackage(y=>ji(y,g.partName,g.nodeId));}let x=t.replaceUntil;if(x!==void 0&&x<=t.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(x!==void 0&&f.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:x}),!r){f.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock}});return}let m=null;f.applyPackage(g=>{let y=ei(g,i,r.namespaceUri,r.rootLocalName);if(!y.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,g;if(m=oi(y.part,r.rootLocalName,r.nodeId),!m)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,g;let O=ii(y.pkg,y.part.partName,{id:r.nodeId,label:r.label,data:r.data});return hi(O,y.part.partName,r.nodeId)?O:(l="store-not-authored",d="the payload node could not be written into the store",g)}),!(l!==null||!m)&&f.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock},dataBinding:m});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=Gm(e,a);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function Gm(e,t){for(let n of Mb(e.part.root))if(!t.has(n.node.id))return n.node.id}function od(e,t,n){let r=Mb(e.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of ci(e.package,t)){let a=ri(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Jo(e,t){let n=e.part.name,r=od(e,n,t),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let a of r)i.applyPackage(s=>ji(s,a.partName,a.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function Km(e,t,n){if(!e.parts.has(t)||n.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let i of n){let a=di(r,t,i);if(!a)continue;let s=qi$1(r,a.itemId),l=ki(r,a.partName,s);if(l.pkg===r&&gi(r,a.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var td=new WeakMap;function Xm(e,t){let n=td.get(e);n||(n=new Map,td.set(e,n));let r=n.get(t);if(r)return r;let o=ci(e,t).map(i=>({itemId:i.itemId,nodes:new Map(gi(e,i.partName).map(a=>[a.id,a]))}));return n.set(t,o),o}function Ym(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let i=Xm(e,n);if(i.length===0)return r;for(let a of Mb(o.root))for(let s of i){let l=ri(a.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(a.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function Jm(e,t,n){let r=new Map,o=di(e,t,n);if(!o)return r;for(let i of gi(e,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var ad={kind:"body"};function id(e,t,n){let r=t.kind==="body"?null:e.resolveStory(t),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),Fa(e,()=>{let s=n(o);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Ga(s))}function qm(e,t,n=ad){return id(e,n,r=>Yo(r,t,e.bodyStore().part.name))}function Qm(e,t,n=ad){return id(e,n,r=>Jo(r,t))}var ld=new WeakMap;function Oe(e,t){return ld.set(e,t),e}function Z(e){return ld.get(e)??[]}function rn(e){return `${e.kind}-${e.id}`}function qo(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function dd(e){return qo(e)[0]??null}function Tt(e,t){let n=dd(e);if(!n)return Number.MAX_SAFE_INTEGER;let r=t.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function Zm(e,t){let n=t.get(e.start.paragraphId),r=t.get(e.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(e.end.offset-e.start.offset)}var eu=0,tu=1,nu=2;function ru(e,t,n){let r=n.get(t.paragraphId),o=n.get(e.start.paragraphId),i=n.get(e.end.paragraphId);return r===void 0||o===void 0||i===void 0||r<o||r>i||r===o&&t.offset<e.start.offset||r===i&&t.offset>e.end.offset?null:o===i&&e.start.offset===e.end.offset?eu:r===i&&t.offset===e.end.offset?nu:tu}function ou(e,t,n){let r=null;for(let o of qo(e)){let i=ru(o,t,n);if(i===null)continue;let a=Zm(o,n);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var sd={comment:0,custom:1,revision:2};function au(e,t,n){let r=[];for(let o of e){let i=ou(o,t,n);i!==null&&r.push({item:o,grip:i.grip,width:i.width});}return r.sort((o,i)=>o.grip!==i.grip?o.grip-i.grip:o.width!==i.width?o.width-i.width:o.item.kind!==i.item.kind?sd[o.item.kind]-sd[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function Hy(e,t,n){let o=au(e,t,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?cd(e,o):o:null}function Vy(e,t){return cd(e,t)}function cd(e,t){let n=new Map,r=new Map;for(let a of e)a.kind==="comment"?n.set(a.id,a):a.kind==="revision"&&r.set(a.id,a);let o=new Set([t.id]),i=t;for(;i.parentId!==void 0;){let a=n.get(i.parentId);if(!a||o.has(a.id))break;o.add(a.id),i=a;}if(i.parentRevisionId!==void 0){let a=r.get(i.parentRevisionId);if(a)return a}return i}function md(e,t){let n=e.filter(d=>(d.revisionKind==="insert"||d.revisionKind==="delete")&&!d.readOnly&&d.ranges.length>0);if(n.length<2)return e;let r=d=>`${d.paragraphId}\0${d.offset}`,o=new Map;for(let d of n){let c=JSON.stringify([d.revisionKind,d.author,d.nesting]),u=o.get(c);u?u.push(d):o.set(c,[d]);}let i=(d,c)=>{let u=d.ranges[0].start,f=c.ranges[0].start,x=(t.get(u.paragraphId)??0)-(t.get(f.paragraphId)??0);return x!==0?x:u.offset-f.offset};for(let d of o.values()){let c=true;for(let u=1;u<d.length&&c;u+=1)c=i(d[u-1],d[u])<=0;c||d.sort(i);}let a=new Set,s=new Map;for(let d of o.values()){let c=[],u="",f=()=>{if(c.length>1){s.set(c[0].id,su(c));for(let x=1;x<c.length;x+=1)a.add(c[x].id);}c=[];};for(let x of d){let m=r(x.ranges[0].start);c.length>0&&m!==u&&f();let g=c.length===0;c.push(x),(g||iu(x))&&(u=r(x.ranges[x.ranges.length-1].end));}f();}if(s.size===0)return e;let l=[];for(let d of e)a.has(d.id)||l.push(s.get(d.id)??d);return l}function iu(e){return e.ranges.some(t=>t.start.paragraphId!==t.end.paragraphId||t.start.offset!==t.end.offset)}function su(e){let t=e[0],n=[...t.addresses],r=[...t.ranges],o=[...Z(t)],i=t.text,a=t.date;for(let s of e.slice(1)){for(let l of s.addresses)n.some(d=>du(d,l))||n.push(l);for(let l of s.ranges)r.push(l);for(let l of Z(s))o.push(l);i+=s.text,a=lu(a,s.date);}return Oe({...t,id:e.map(s=>s.id).join("+"),addresses:n,ranges:r,text:i,...a===void 0?{}:{date:a}},o)}function lu(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?e:r>n?t:e}function du(e,t){return e.id===t.id&&e.author===t.author&&(e.date??"")===(t.date??"")}var cu=new Map([[167,"\u2663"],[168,"\u2666"],[169,"\u2665"],[170,"\u2660"],[174,"\u2192"],[176,"\xB0"],[180,"\xD7"],[183,"\u2022"],[222,"\u21D2"]]),ud=new Map([[108,"\u25CF"],[110,"\u25A0"],[111,"\u25A1"],[167,"\u25AA"],[216,"\u27A2"],[252,"\u2714"],[253,"\u2718"]]),pd=new Map([[167,"\u25AA"],[183,"\u2022"]]),rr=new Map([["symbol",cu],["wingdings",ud],["wingdings 2",pd],["wingdings 3",pd],["webdings",ud]]),mu=64,Ky=Object.freeze([...rr.keys()]);function or(e){return !e||e.length>mu?false:rr.has(e.toLowerCase())}function Xy(e){for(let t of e){let n=t.codePointAt(0);if(n>=61440&&n<=61695)return true}return false}function Qo(e,t,n){if(e.length===0||!or(t))return e;let r=rr.get(t.toLowerCase());if(n?.(t)===true)return e;let o="",i=false;for(let a of e){let s=a.codePointAt(0);if(s>=61440&&s<=61695){let l=r.get(s-61440);if(l!==void 0){o+=l,i=true;continue}}o+=a;}return i?o:e}function Yy(e,t,n){if(e.length===1&&or(t)){let r=t.toLowerCase();if(r==="symbol"||r==="wingdings"){let o=rr.get(r).get(e.charCodeAt(0));if(o!==void 0&&n?.(t)!==true)return o}}return Qo(e,t,n)}var ar=61440,fd=61695,uu=128;function pu(e){return e.kind==="generic"&&e.namespaceUri===fa&&e.localName==="sym"}function gd(e,t){if(!(e.kind==="textValue"||!("attributes"in e))){for(let n of e.attributes)if(n.localName===t&&(n.namespaceUri===fa||n.namespaceUri===""))return n.value}}function fu(e){return !e||e.length>4||!/^[0-9A-Fa-f]{1,4}$/.test(e)?null:Number.parseInt(e,16)}function gu(e){return !(!Number.isInteger(e)||e<32||e>1114111||e>=127&&e<=159||e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65534)===65534||e===65532)}function hu(e){if(!pu(e))return null;let t=fu(gd(e,"char"));if(t===null)return null;let n=gd(e,"font"),r=n&&n.length<=uu?n:null,o=or(r),i=o&&t<=255&&t+ar<=fd?t+ar:t;if(o&&i>=ar&&i<=fd){let a=Qo(String.fromCodePoint(i),r),s=a.codePointAt(0)<ar;return {text:a,font:r,unicode:s}}return gu(t)?{text:String.fromCodePoint(t),font:r,unicode:t<57344||t>63743}:null}function Zo(e){let t=hu(e);return t?.unicode?t.text:""}function hd(e){return bb(yd(e,true))}function ox(e){return yd(e,false)}function yd(e,t){let n=[],r=o=>{if(o.kind==="textValue"){n.push(o.value);return}if(t&&Wa(o)){n.push(Zo(o));return}let i=Xa(o);if(i!==null){n.push(i);return}for(let a of o.children)r(a);};for(let o of e.blocks)r(o);return n.join("")}function xd(e){if(e.initials&&e.initials.trim().length>0)return e.initials.trim();let t=e.author.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function pt(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return fb(e);if(Wa(e))return Zo(e);let t=Xa(e);if(t!==null)return t;if($e$1(e))return "";let n="";for(let r of e.children)n+=pt(r);return n}var Ct=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t;function kd(e,t,n){let r=new Set(["tcPrChange","trPrChange","tblPrExChange","tblGridChange","tblPrChange"]),o=new Map(n.filter(g=>g.propertyChange&&r.has(g.node.localName)).map(g=>[g.node.id,g]));if(!o.size)return [...t];let i=Ti(e,n).tableHistories,a=[],s=new Map,l=g=>g.node.attributes.find(y=>y.namespaceUri===fa&&y.localName==="author")?.value??"",d=(g,y)=>{if(g.kind==="textValue"||Ct(g,"tbl"))return;let O=o.get(g.id);O&&y.push(O);for(let P of g.children)d(P,y);},c=g=>{if(g.kind!=="textValue"){if(Ct(g,"tbl")){let y,O=[],P=[],p=[],k=false;for(let R of g.children){if(Ct(R,"tblGrid")&&d(R,P),Ct(R,"tblPr")&&d(R,p),!Ct(R,"tr"))continue;let h=[];if(d(R,h),k||=h.some(I=>I.refused),!h.length||h.some(I=>I.refused)){y=void 0;continue}let C=l(h[h.length-1]);(!y||y.author!==C)&&(y={ids:new Set,author:C,tableId:g.id},a.push(y),O.push(y));for(let I of h)y.ids.add(I.node.id);}let v=O.at(-1);if(v&&!k&&P.every(R=>!R.refused)){for(let R of P)v.ids.add(R.node.id);if(O.length===1&&P.length>0)for(let R of p){let h=R.node.children.find(C=>Ct(C,"tblPr"));!R.refused&&R.parent?.kind==="tableProperties"&&h&&l(R)===v.author&&(i.has(R.node.id)||va({...R.parent,children:R.parent.children.filter(C=>C.id!==R.node.id)},h))&&v.ids.add(R.node.id);}}}for(let y of g.children)c(y);}};c(e.root);for(let g of a)for(let y of g.ids)s.set(y,g);let u=new Set;for(let g of t){let O=Z(g).map(P=>s.get(P));if(O.some(P=>P!==O[0]))for(let P of O)P&&u.add(P.tableId);}for(let g of a)if(u.has(g.tableId))for(let y of g.ids)o.get(y)?.node.localName==="tblGridChange"&&(g.ids.delete(y),s.delete(y));let f=new Map;for(let g of t){let y=Z(g),O=y.length?s.get(y[0]):void 0;if(!O||g.readOnly||g.revisionKind!=="format"||!y.every(p=>s.get(p)===O))continue;let P=f.get(O)??[];P.push(g),f.set(O,P);}let x=new Map,m=new Set;for(let g of a){let y=f.get(g)??[],O=y.find(h=>!["tblGridChange","tblPrChange"].includes(h.formattingKind??""))??y[0],P=O?[O,...y.filter(h=>h!==O)]:[],p=P.flatMap(Z),k=new Set(p);if(!O||P.length<2||![...g.ids].every(h=>k.has(h)))continue;let v=[...new Map(P.flatMap(h=>h.addresses).map(h=>[JSON.stringify([h.id,h.author,h.date??null]),h])).values()],R=[...new Map(P.filter(h=>!["tblGridChange","tblPrChange"].includes(h.formattingKind??"")).flatMap(h=>h.ranges).map(h=>[JSON.stringify(h),h])).values()];x.set(O,Oe({...O,author:g.author,addresses:v,ranges:R,text:[...new Set(P.map(h=>h.text).filter(Boolean))].join(`
2
- `)},p));for(let h of P.slice(1))m.add(h);}return t.filter(g=>!m.has(g)).map(g=>x.get(g)??g)}var Rd=e=>e.kind==="textValue"?e.value:[e.namespaceUri,e.localName,e.attributes.map(t=>[t.namespaceUri,t.localName,t.value]).sort((t,n)=>JSON.stringify(t).localeCompare(JSON.stringify(n))),e.children.map(Rd)],Pd=e=>new Map(e.children.filter(t=>t.kind!=="textValue"&&!(t.namespaceUri===fa&&t.localName==="rPrChange")).map(t=>t.kind==="textValue"?["",""]:[JSON.stringify([t.namespaceUri,t.localName]),JSON.stringify(Rd(t))]));function yu(e){if(e.node.localName!=="rPrChange"||!e.parent||e.paragraphMark||e.refused)return;let t=e.node.children.find(i=>i.kind!=="textValue"&&i.namespaceUri===fa&&i.localName==="rPr");if(!t||t.kind==="textValue")return;let n=Pd(t),r=Pd(e.parent),o=[...new Set([...n.keys(),...r.keys()])].sort().filter(i=>n.get(i)!==r.get(i)).map(i=>[i,r.get(i)??null]);return o.length?JSON.stringify(o):void 0}function Od(e,t){let n=new Map(t.map(s=>[s.node.id,yu(s)])),r=new Map;for(let s of e){if(s.revisionKind!=="format"||s.formattingKind!=="rPrChange"||s.readOnly||s.ranges.length!==1)continue;let l=s.ranges[0];if(l.start.paragraphId!==l.end.paragraphId||l.start.offset===l.end.offset)continue;let d=Z(s),c=d.length?n.get(d[0]):void 0;if(!c||!d.every(x=>n.get(x)===c))continue;let u=JSON.stringify([s.author,l.partName,l.start.paragraphId,c]),f=r.get(u)??[];f.push(s),r.set(u,f);}let o=new Set,i=new Map,a=s=>{if(s.length<2)return;let l=s[0],d=[...new Map(s.flatMap(c=>c.addresses).map(c=>[JSON.stringify([c.id,c.author,c.date??null]),c])).values()];i.set(l,Oe({...l,addresses:d,ranges:s.flatMap(c=>c.ranges),text:s.map(c=>c.text).join("")},s.flatMap(Z)));for(let c of s.slice(1))o.add(c);};for(let s of r.values()){s.sort((d,c)=>d.ranges[0].start.offset-c.ranges[0].start.offset);let l=[];for(let d of s)l.length&&l[l.length-1].ranges[0].end.offset!==d.ranges[0].start.offset&&(a(l),l=[]),l.push(d);a(l);}return e.filter(s=>!o.has(s)).map(s=>i.get(s)??s)}var ce=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t,on=(e,t)=>e.attributes.find(n=>n.namespaceUri===fa&&n.localName===t)?.value;function xu(e,t,n){let r=e.children.filter(o=>ce(o,"tc"));return r.length>0&&r.every(o=>{if(o.kind==="textValue")return false;let i=o.children.filter(a=>a.kind==="paragraph");return i.length>0&&i.every(a=>{if(a.kind==="textValue")return false;let s=a.children.find(u=>ce(u,"pPr")),l=s?.kind!=="textValue"?s?.children.find(u=>ce(u,"rPr")):void 0,d=l?.kind!=="textValue"?l?.children.filter(u=>ce(u,"ins")||ce(u,"del")):void 0,c=d?.length===1?d[0]:void 0;return !!c&&c.kind!=="textValue"&&c.localName===t&&on(c,"author")===n})})}function ku(e,t,n,r){let o=new Map(n.filter(p=>p.parent?.localName==="trPr"&&(p.node.localName==="ins"||p.node.localName==="del")).map(p=>[p.node.id,p]));if(o.size===0)return [...t];let i=new Map(n.map(p=>[p.node.id,p])),a=new Map;for(let p of r.values())a.set(p.paragraphId,Math.max(a.get(p.paragraphId)??0,p.end));let s=[],l=new Map,d=new Set,c=new Map,u=(p,k)=>{if(p.kind==="textValue"||ce(p,"tbl"))return;let v=i.get(p.id),R=o.has(p.id);v&&!v.propertyChange&&p.localName===k.direction&&!v.refused&&(R?on(p,"author")===k.author:v.paragraphMark||p.kind==="revisionInsert"||p.kind==="revisionDelete")&&(c.set(p.id,k),R&&k.markerIds.add(p.id));for(let h of p.children)u(h,k);},f=(p,k=0)=>{if(p.kind!=="textValue"){if(ce(p,"tr")&&k>1){let v=p.children.find(R=>ce(R,"trPr"));if(v&&v.kind!=="textValue")for(let R of v.children)o.has(R.id)&&l.set(R.id,p);}if(ce(p,"tbl")){let v;for(let R of p.children){if(R.kind==="textValue"||!ce(R,"tr")){v=void 0;continue}let h=R.children.find(J=>ce(J,"trPr")),C=h?.kind!=="textValue"?h?.children.filter(J=>o.has(J.id))??[]:[],I=C.length===1?C[0]:void 0,j=I&&I.kind!=="textValue"?on(I,"author"):void 0;if(!I||I.kind==="textValue"||j===void 0||o.get(I.id)?.refused){v=void 0;continue}let _=I.localName;if(k>0){if(!xu(R,_,j)){v=void 0;continue}d.add(R.id);}(!v||v.author!==j||v.direction!==_)&&(v={markerIds:new Set,rows:[],author:j,direction:_,followingText:[]},s.push(v)),v.rows.push(R),v.markerIds.add(I.id),u(R,v);}}for(let v of p.children)f(v,k+(ce(p,"tbl")?1:0));}};f(e.root);let x,m=new Set(s.flatMap(p=>p.rows.map(k=>k.id))),g=(p,k=0,v=false)=>{if(p.kind==="textValue")return;d.has(p.id)&&(x=void 0);let R=k+(ce(p,"tbl")?1:0),h=v||m.has(p.id);if(p.kind==="run"&&!h&&(x=void 0),x&&(p.kind==="revisionInsert"||p.kind==="revisionDelete")){let C=x;x=void 0;let I=i.get(p.id),j=on(C.marker,"author");if(I&&!I.refused&&j!==void 0&&p.localName===C.marker.localName&&on(p,"author")===j&&(c.get(p.id)?.author??j)===j){let _=c.get(p.id);_||(_={markerIds:new Set,rows:[C.row],author:j,direction:C.marker.localName,followingText:[pt(p)],rowEndOnly:true},s.push(_),c.set(p.id,_)),_.markerIds.add(C.marker.id),c.set(C.marker.id,_);}}for(let C of p.children)g(C,R,h);if((ce(p,"tc")||p.kind==="paragraph"&&!h)&&(x=void 0),ce(p,"tr")&&(x=void 0,R>1&&!d.has(p.id))){let C=p.children.find(_=>ce(_,"trPr")),I=C&&C.kind!=="textValue"?C.children.filter(_=>o.has(_.id)):[],j=I.length===1?I[0]:void 0;j&&j.kind!=="textValue"&&!o.get(j.id)?.refused&&(x={marker:j,row:p});}};g(e.root),t=t.map(p=>{let k=Z(p);if(p.revisionKind!=="structural"||!k.length||!k.every(R=>l.has(R)))return p;let v=[];for(let R of k){let h,C=I=>{if(!(I.kind==="textValue"||ce(I,"tbl")))if(I.kind==="paragraph")h=I;else for(let j of I.children)C(j);};if(C(l.get(R)),h){let I={paragraphId:h.id,offset:a.get(h.id)??0};v.push({partName:e.name,start:I,end:I});}}return v.length?Oe({...p,ranges:v},k):p});let y=new Map;for(let p of t){let k=Z(p),v=k.length?c.get(k[0]):void 0;if(!v||p.readOnly||!k.every(h=>c.get(h)===v))continue;let R=y.get(v)??[];R.push(p),y.set(v,R);}let O=new Set,P=new Map;for(let p of s){let k=y.get(p)??[],v=k.find(T=>Z(T).some(V=>p.markerIds.has(V))),R=new Set(k.flatMap(Z));if(!v||![...p.markerIds].every(T=>R.has(T)))continue;let h=[v,...k.filter(T=>T!==v)],C=h.flatMap(T=>T.addresses),I=[],j=[],_=T=>{if(!(T.kind==="textValue"||ce(T,"tbl"))){if(T.kind==="paragraph"){I.push({partName:e.name,start:{paragraphId:T.id,offset:0},end:{paragraphId:T.id,offset:a.get(T.id)??0}}),j.push(pt(T));return}for(let V of T.children)_(V);}};for(let T of p.rows)_(T);if(p.rowEndOnly&&I.length){let T=I[I.length-1];I.splice(0,I.length,{...T,start:T.end});}let J=new Set(I.map(T=>T.start.paragraphId));for(let T of h)if(!(T.revisionKind==="structural"&&Z(T).some(V=>!l.has(V))))for(let V of T.ranges)J.has(V.start.paragraphId)||I.push(V);j.push(...p.followingText);let H=Oe({...v,addresses:[...new Map(C.map(T=>[JSON.stringify([T.id,T.author,T.date??null]),T])).values()],ranges:I.length?I:h.flatMap(T=>T.ranges),text:j.join(`
3
- `),nesting:h.reduce((T,V)=>Math.min(T,V.nesting),v.nesting)},h.flatMap(Z));P.set(v,H);for(let T of k)T!==v&&O.add(T);}return t.filter(p=>!O.has(p)).map(p=>P.get(p)??p)}function vd(e,t,n,r,o){let i=Od(kd(e,ku(e,t,n,r),n),n),a=new Set(n.filter(s=>s.node.kind==="moveFromRangeStart"||s.node.kind==="moveToRangeStart").map(s=>s.node.id));return a.size>0||n.some(s=>s.parent?.localName==="trPr"&&["ins","del"].includes(s.node.localName))?i.sort((s,l)=>Tt(s,o)-Tt(l,o)||Number(Z(l).some(d=>a.has(d)))-Number(Z(s).some(d=>a.has(d)))):i}function Id(e){if(e.parent?.localName==="trPr"){if(e.node.localName==="ins")return "rowInsert";if(e.node.localName==="del")return "rowDelete"}if(e.parent?.localName==="tcPr"){if(e.node.localName==="cellIns")return "cellInsert";if(e.node.localName==="cellDel")return "cellDelete";if(e.node.localName==="cellMerge")return "cellMerge"}if(e.parent?.localName==="numPr"&&e.node.localName==="ins")return "numberingInsert"}function bd(e,t,n,r){if(!e.some(m=>m.revisionKind==="paragraphMark"))return e;let o=new Map,i=(m,g)=>{if(!(m.kind==="textValue"||g>64))for(let y=0;y<m.children.length;y+=1){let O=m.children[y],P=m.children[y+1];O.kind==="paragraph"&&P?.kind==="paragraph"&&o.set(O.id,P.id),i(O,g+1);}};i(t.root,0);let a=e.map((m,g)=>g),s=m=>{for(;a[m]!==m;)a[m]=a[a[m]],m=a[m];return m},l=new Map,d=new Map,c=(m,g,y)=>JSON.stringify([m.revisionKind==="paragraphMark"?m.markDirection:m.revisionKind,m.author,m.nesting,g,y]),u=(m,g,y)=>{let O=m.get(g);O?O.push(y):m.set(g,[y]);};e.forEach((m,g)=>{if(!(m.readOnly||!["insert","delete","paragraphMark"].includes(m.revisionKind)))for(let y of m.ranges)u(l,c(m,y.start.paragraphId,y.start.offset),g),u(d,c(m,y.end.paragraphId,y.end.offset),g);});let f=(m,g)=>{for(let y of g){let O=e[m].date,P=e[y].date;O!==void 0&&P!==void 0&&!$g(O,P)||(a[s(y)]=s(m));}};e.forEach((m,g)=>{if(!(m.readOnly||m.revisionKind!=="paragraphMark"||!["insert","delete"].includes(m.markDirection??"")))for(let y of m.ranges){f(g,d.get(c(m,y.start.paragraphId,y.start.offset))??[]);let O=o.get(y.end.paragraphId);O&&f(g,l.get(c(m,O,0))??[]);}});let x=new Map;return e.forEach((m,g)=>{let y=s(g),O=x.get(y);O?O.push(m):x.set(y,[m]);}),[...x.values()].map(m=>{if(m.length===1)return m[0];let g=m.flatMap(k=>k.ranges).sort((k,v)=>n.get(k.start.paragraphId)-n.get(v.start.paragraphId)||k.start.offset-v.start.offset),y=m.flatMap(k=>Z(k)).flatMap(k=>{let v=r.get(k);return v?[v]:[]}).sort((k,v)=>n.get(k.range.start.paragraphId)-n.get(v.range.start.paragraphId)||k.range.start.offset-v.range.start.offset),O=m[0],P=m.find(k=>k.revisionKind!=="paragraphMark"),p=[...new Map(m.flatMap(k=>k.addresses).map(k=>[JSON.stringify(k),k])).values()];return Oe({...O,id:m.map(k=>k.id).join("+"),revisionKind:P?.revisionKind??"paragraphMark",...P?{markDirection:void 0}:{},addresses:p,ranges:g,text:P?y.map(k=>k.text).join(""):""},m.flatMap(k=>Z(k)))})}function ea(e){if(!e.propertyChange||!e.parent)return [];let t=(o,i)=>{let a=o?.children.find(s=>s.kind!=="textValue"&&s.namespaceUri===fa&&s.localName==="lang");return a&&a.kind!=="textValue"?a.attributes.find(s=>s.namespaceUri===fa&&s.localName===i)?.value:void 0},n=e.node.children.find(o=>o.kind!=="textValue"&&o.localName===e.parent.localName),r=[];for(let o of ["val","eastAsia","bidi"]){let i=t(e.parent,o),a=t(n?.kind!=="textValue"?n:void 0,o);i&&i!==a&&!r.includes(i)&&r.push(i);}return r}var Pu=[{property:"bold",element:"b",attribute:"val",kind:"toggle"},{property:"italic",element:"i",attribute:"val",kind:"toggle"},{property:"underline",element:"u",attribute:"val"},{property:"strike",element:"strike",attribute:"val",kind:"toggle"},{property:"fontFamily",element:"rFonts",attribute:"ascii"},{property:"fontSize",element:"sz",attribute:"val",kind:"halfPoints"},{property:"color",element:"color",attribute:"val"},{property:"alignment",element:"jc",attribute:"val"},{property:"leftIndent",element:"ind",attribute:"left",kind:"twips"},{property:"rightIndent",element:"ind",attribute:"right",kind:"twips"},{property:"firstLineIndent",element:"ind",attribute:"firstLine",kind:"twips"},{property:"hangingIndent",element:"ind",attribute:"hanging",kind:"twips"},{property:"spaceBefore",element:"spacing",attribute:"before",kind:"twips"},{property:"spaceAfter",element:"spacing",attribute:"after",kind:"twips"}];function ta(e){if(!e.propertyChange||!e.parent)return [];let t=e.node.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===fa&&r.localName===e.parent.localName),n=[];for(let r of Pu){let o=a=>{let s=a?.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===fa&&d.localName===r.element);if(!s||s.kind==="textValue")return null;let l=s.attributes.find(d=>d.namespaceUri===fa&&d.localName===r.attribute)?.value;if(r.kind==="toggle")return l==="0"||l==="false"||l==="off"?"false":"true";if(l===void 0)return null;if(r.kind==="halfPoints"||r.kind==="twips"){let d=r.kind==="twips"?_c$1(l)??Number.NaN:Number(l);return Number.isFinite(d)?String(d/(r.kind==="halfPoints"?2:20)):l}return l},i=o(e.parent);i!==o(t?.kind!=="textValue"?t:void 0)&&n.push({property:r.property,value:i});}return n}function sr(e){return Ed(e,true)}function Ex(e){return Ed(e,false)}function Ed(e,t){let n=t?Nd.get(e.root):void 0;if(n)return n;let r=new Map,o=s=>{let l=t?Sd.get(s):void 0;if(l){for(let[c,u]of l)r.set(c,u);return}let d=new Map;Ou(s,d,t),t&&Sd.set(s,d);for(let[c,u]of d)r.set(c,u);},i=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){o(s);return}for(let d of s.children)i(d,l+1);}};i(e.root,0);let a=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){let d=t?wd.get(s):void 0;if(!d){let c=[];Td(s,0,c,t),d=c,t&&wd.set(s,d);}for(let[c,u]of d)r.set(c,u);return}if(s.kind==="table"||s.kind==="tableRow"||s.kind==="tableCell"){let d=t?ir.get(s):void 0;d||(d=Cd(s),t&&ir.set(s,d));for(let[c,u]of d)r.set(c,u);}for(let d of s.children)a(d,l+1);}};return a(e.root,0),t&&Nd.set(e.root,r),r}function Td(e,t,n,r){if(!(e.kind==="textValue"||t>64)){if(e.kind==="table"||e.kind==="tableRow"||e.kind==="tableCell"){let o=r?ir.get(e):void 0;o||(o=Cd(e),r&&ir.set(e,o));for(let i of o)n.push(i);}for(let o of e.children)Td(o,t+1,n,r);}}function Cd(e){let t=null,n=(i,a)=>{if(!(t||i.kind==="textValue"||a>64)){if(i.kind==="paragraph"){t=i;return}for(let s of i.children)n(s,a+1);}};if(n(e,0),!t)return Ru;let r={paragraphId:t.id,start:0,end:0},o=[];if(e.kind==="textValue")return o;for(let i of e.children)if(!(i.kind==="textValue"||!["tblPr","tblGrid","tblPrEx","trPr","tcPr"].includes(i.localName)))for(let a of i.children){if(a.kind==="textValue")continue;(a.localName===`${i.localName}Change`||i.localName==="trPr"&&["ins","del"].includes(a.localName)||i.localName==="tcPr"&&["cellIns","cellDel","cellMerge"].includes(a.localName))&&o.push([a.id,r]);}return o}var Ru=[],Sd=new WeakMap,Nd=Gh(8),ir=new WeakMap,wd=new WeakMap;function Ou(e,t,n){let r=n?Rf(e):Tf(e),o=(s,l,d,c)=>{if(!(s.kind==="textValue"||c>64)){t.set(s.id,{paragraphId:e.id,start:l,end:d});for(let u of s.children)o(u,l,d,c+1);}},i=(s,l)=>{if(s.kind==="textValue"||l>64)return;let d=r.spanOf(s);if(s.kind==="fldSimple"&&d){o(s,d.start,d.end,l);return}if(s.kind==="run"){if(!d)return;t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)c.kind==="runProperties"&&o(c,d.start,d.end,l+1);return}d&&t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)i(c,l+1);};for(let s of e.children)s.kind!=="paragraphProperties"&&i(s,0);let a=e.children.find(s=>s.kind==="paragraphProperties");a&&o(a,r.length,r.length,0);}var Iu={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function lr(e,t){for(let n of e.attributes)if(n.localName===t&&n.namespaceUri===fa)return n.value}function na(e){return `${e.id}\0${e.author}\0${e.date??""}`}var bu={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo",moveFromRangeStart:"moveFrom",moveToRangeStart:"moveTo"},Dd={retainRevisionItems:true,revisionSites:ej,locations:sr,commentAnchors:Ih,deepOrder:uj};function dr(e){return _d(e,Dd)}function _d(e,t){let n=e.root.kind!=="paragraph";if(n&&t.retainRevisionItems){let o=Md.get(e.root);if(o&&o.name===e.name)return o.items}let r=Su(e,t);return n&&t.retainRevisionItems&&Md.set(e.root,{name:e.name,items:r}),r}var Md=Gh(8);function Su(e,t){let n=t.revisionSites(e);if(n.length===0)return [];let r=t.locations(e),o=new Map(Ui(e.root).map(m=>[m.start.id,m])),i=Wi(e.root),a=n.some(m=>m.paragraphMark),s=new Map,l=new Map,d=new Map,c=Si(e,n);for(let m of n){if(c.has(m.node.id))continue;let g=o.get(m.node.id),y=g?g.content.map(pt).join(""):pt(m.node),O=lr(m.node,"id"),P=O??`missing-${m.node.id}`,p=lr(m.node,"author")??"",k=lr(m.node,"author")===void 0&&m.node.localName!=="tblGridChange",v=lr(m.node,"date"),R=v===void 0?{id:P,author:p}:{id:P,author:p,date:v},h=i.has(m.node.id)?"insert":m.propertyChange?"format":m.paragraphMark?"paragraphMark":bu[m.node.kind]??"structural",C=m.paragraphMark?Iu[m.node.localName]:void 0,I=h==="structural"?Id(m):void 0,j=r.get(m.node.id),_=g?.end&&r.get(g.end.id),J=j&&_&&j.paragraphId===_.paragraphId?{...j,end:_.end}:j,H=J?{partName:e.name,start:{paragraphId:J.paragraphId,offset:J.start},end:{paragraphId:J.paragraphId,offset:J.end}}:null;a&&H&&(h==="paragraphMark"||h==="insert"||h==="delete")&&s.set(m.node.id,{range:H,text:h==="paragraphMark"?`
4
- `:y});let T=h==="structural"?`structural\0${na(R)}`:`${h}\0${m.node.localName}\0${na(R)}`,V=d.get(T)??T,ie=l.get(V),se=ie?.ranges[ie.ranges.length-1]?.end;(h==="insert"||h==="delete")&&H&&se&&se.paragraphId===H.start.paragraphId&&se.offset<H.start.offset&&(V=`${T}\0site-${m.node.id}`),(h==="insert"||h==="delete")&&d.set(T,V);let M=l.get(V);if(M){M.siteNodeIds.push(m.node.id),I&&!M.structuralChanges?.includes(I)&&(M.structuralChanges??=[]).push(I),m.propertyChange&&(M.formattingLanguages=[...new Set([...M.formattingLanguages??[],...ea(m)])],M.formattingChanges=[...new Map([...M.formattingChanges??[],...ta(m)].map($=>[JSON.stringify($),$])).values()]),H&&!M.ranges.some($=>$.partName===H.partName&&$.start.paragraphId===H.start.paragraphId&&$.start.offset===H.start.offset&&$.end.paragraphId===H.end.paragraphId&&$.end.offset===H.end.offset)&&M.ranges.push(H),h!=="structural"&&M.revisionKind==="structural"&&(M.revisionKind=h),M.readOnly||=m.refused||k,m.nesting>M.nesting&&(M.nesting=m.nesting),h==="delete"||h==="moveFrom"?M.deletedText+=y:h!=="format"&&h!=="paragraphMark"&&(M.text+=y);continue}l.set(V,{address:R,localName:m.node.localName,...h==="insert"||h==="delete"?{identitySuffix:`\0site-${m.node.id}`}:{},...I?{structuralChanges:[I]}:{},...m.propertyChange?{formattingLanguages:ea(m),formattingChanges:ta(m)}:{},revisionKind:h,...C?{markDirection:C}:{},author:p,...v===void 0?{}:{date:v},text:h==="format"||h==="paragraphMark"||h==="delete"||h==="moveFrom"?"":y,deletedText:h==="delete"||h==="moveFrom"?y:"",ranges:H?[H]:[],siteNodeIds:[m.node.id],nesting:m.nesting,readOnly:m.refused||k||O===void 0});}let u=[...l.values()].map(m=>Oe({kind:"revision",id:`${m.revisionKind}${m.revisionKind==="format"||m.revisionKind==="paragraphMark"?`-${m.localName}`:""}-${e.name}\0${na(m.address)}${m.identitySuffix??""}`,address:m.address,addresses:[m.address],revisionKind:m.revisionKind,...m.revisionKind==="format"?{formattingKind:m.localName}:{},...m.structuralChanges?.length?{structuralChanges:m.structuralChanges}:{},...m.formattingChanges?.length?{formattingChanges:m.formattingChanges}:{},...m.formattingLanguages?.length?{formattingLanguages:m.formattingLanguages}:{},...m.markDirection?{markDirection:m.markDirection}:{},author:m.author,...m.date===void 0?{}:{date:m.date},text:m.text||m.deletedText,replacedText:"",ranges:m.ranges,nesting:m.nesting,readOnly:m.readOnly,replyIds:[]},m.siteNodeIds)),f=t.deepOrder(e),x=vd(e,u,n,r,f);return bd(md(x,f),e,f,s)}function Fd(e,t,n){let r=new Map(t.map(c=>[c.commentId,c])),o=new Map,i=new Map;for(let c of e)c.paraId&&o.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let a=new Map,s=new Map;for(let c of e){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let f=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;a.has(f)?s.set(c.id,a.get(f)):a.set(f,c.id);}let l=new Map;for(let c of e){let u=c.paraId?n.get(c.paraId.toUpperCase()):void 0,f=u?.parentParaId?o.get(u.parentParaId):void 0,x=c.parentCommentId?i.get(c.parentCommentId):void 0,m=u===void 0?s.get(c.id):void 0,g=m?i.get(m):void 0,y=f??x??g;y&&y.id!==c.id&&l.set(c.id,y.id);}for(let c of [...l.keys()]){let u=new Set([c]),f=l.get(c);for(;f!==void 0;){if(u.has(f)){l.delete(c);break}u.add(f),f=l.get(f);}}let d=new Map;for(let[c,u]of l){let f=d.get(u);f?f.push(c):d.set(u,[c]);}return e.map(c=>{let u=r.get(c.id),f=c.paraId?n.get(c.paraId.toUpperCase()):void 0,x=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:f?.done??false,...x===void 0?{}:{parentId:x},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function Nu(e){return wu(e,Dd)}function wu(e,t){let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let c of [...e.furnitureParts??[],...e.stylesPart?[e.stylesPart]:[]])r.has(c.name)||(r.add(c.name),n.push(c));let o=e.commentsPart?Kh(e.commentsPart):[],i=e.commentsExtendedPart?Lh(e.commentsExtendedPart):new Map,a=[],s=[],l=n.length===1?t.deepOrder(n[0]):new Map;for(let c of n){for(let x of _d(c,t))a.push(x);for(let x of t.commentAnchors(c))s.push(x);if(n.length===1)continue;let u=l,f=u.size;for(let[x,m]of t.deepOrder(c))u.has(x)||u.set(x,f+m);}return Ld([...a,...Fd(o,s,i)]).sort((c,u)=>Tt(c,l)-Tt(u,l))}function Eu(e,t){if(e.kind!=="comment")return e;let n=e.replyIds??[],r=n.filter(i=>t.has(i)),o=e.parentId!==void 0&&!t.has(e.parentId);if(!o&&r.length===n.length)return e;if(o){let{parentId:i,parentRevisionId:a,...s}=e;return r.length===n.length?s:{...s,replyIds:r}}return {...e,replyIds:r}}function Ad(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function Ld(e){let t=new Set;for(let l of e)l.kind==="comment"&&t.add(l.id);let n=e.map(l=>Eu(l,t)),r=new Map;for(let l of n)if(l.kind==="revision")for(let d of l.ranges??[]){if(d.start.paragraphId===d.end.paragraphId&&d.start.offset===d.end.offset)continue;let c=Ad(d),u=l.nesting??0,f=r.get(c);(f===void 0||u>f.nesting)&&r.set(c,{id:l.id,nesting:u});}let o=new Map;for(let l of n)l.kind==="comment"&&l.replyIds&&l.replyIds.length>0&&o.set(l.id,l.replyIds);let i=l=>{let d=[],c=new Set([l]),u=[...o.get(l)??[]];for(;u.length>0;){let f=u.shift();c.has(f)||(c.add(f),d.push(f),u.push(...o.get(f)??[]));}return d},a=new Map,s=new Map;for(let l of n){if(l.kind!=="comment"||l.parentId!==void 0||l.orphaned||!l.range)continue;let d=r.get(Ad(l.range))?.id;if(d===void 0)continue;let c=[l.id,...i(l.id)];for(let f of c)s.set(f,d);let u=a.get(d);u?u.push(...c):a.set(d,c);}return n.map(l=>{if(l.kind==="revision"){let d=a.get(l.id)??[];return d.length===0&&(l.replyIds??[]).length===0?l:Oe({...l,replyIds:d},Z(l))}if(l.kind==="comment"){let d=s.get(l.id);if(d===void 0){if(l.parentRevisionId===void 0)return l;let{parentRevisionId:c,...u}=l;return u}return l.parentRevisionId===d?l:{...l,parentRevisionId:d}}return l})}var Tu=256,Cu=2e3,$d=/[\p{L}\p{N}_]/u;function ra(e){let t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(let r=0;r<e.length;r+=1){let o=e[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function Ud(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&$d.test(r)||o!==void 0&&$d.test(o))}function Bd(e){return typeof e=="string"&&e.length>0&&e.length<=256}function Mu(e,t,n,r={}){let o={matches:[],truncated:false};if(!Bd(t)||e.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?t:ra(t),l=i?e:ra(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),u=[],f=l.indexOf(s,d);for(;f>=0;){let x=f+s.length;if(x>c)return {matches:u,truncated:false};if(!a||Ud(e,f,x)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:f,length:s.length});}f=l.indexOf(s,x);}return {matches:u,truncated:false}}var Au=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),Du=96;function oa(e,t){return e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t}function _u(e){return e.kind==="textValue"&&e.value.trim()===""}function Fu(e){let t=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>Du)return;if(Bf(r)){let s=Df(r),l=Kb(r);if(s&&l&&s.children.every(_u)&&Au.has(l.type)){t.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||oa(r,"p");for(let s of r.children)n(s,a,i+1);};return n(e,false,0),t}function Lu(e){return Gj(e,"rPr",{kind:"runProperties",children:[Gj(e,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function $u(e){let t=e.find(r=>r.kind==="paragraph"||oa(r,"p"));if(!t||t.kind==="textValue")return null;let n=t.children.filter(r=>r.kind!=="paragraphProperties"&&!oa(r,"pPr"));return n.length>0?n:null}function aa(e,t){let n=Fu(t.root);if(n.length===0)return t;let r=null,o=d=>{if(d!==void 0)return r??=kg(e),r.find(c=>c.name===d)},i=Ia(t,"paste"),a=new Set(lb(t.root)),s={value:0},l=t;for(let[d,c]of n.entries()){let u=o(c.docPart),f=nb(t,c.control),x=null;if(u){let P=u.blocks.map((p,k)=>pb(Jf(p,i),a,vb(`${c.control.id}:placeholder:${d}:${k}`),s,f));x=c.inline?$u(P):P;}if(!x){let P=Hj(i,Bj(c.kind),Lu(i));x=c.inline?[P]:[pb(Gj(i,"p",{kind:"paragraph",children:[P]}),a,vb(`${c.control.id}:placeholder:${d}`),s,f)];}let m=Ij(Cf(c.control),{showingPlaceholder:true},i),g={...c.content,children:x},y=c.control.children.map(P=>P.id===c.content.id?g:P.kind!=="textValue"&&P.localName==="sdtPr"?m:P),O=Na(l,c.control.id,y);O.ok&&(l=O.part);}return l}function jd(e,t,n){let r=t.filter(a=>a.node.localName==="tblGridChange"&&n.has(a.node.id));if(!r.length)return new Set;let o=new Map;for(let a of t){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(a.node.localName))continue;let s=a.parent;for(;s&&s.kind!=="table";)s=La(e,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(a.node.id),o.set(s.id,l);}let i=new Set;for(let a of r){let s=a.parent&&La(e,a.parent.id),l=s&&o.get(s.id);l?.some(d=>n.has(d))&&l.some(d=>!n.has(d))&&i.add(a.node.id);}return i}function Uu(e,t,n,r){let o=r??e.root,i=o.kind==="textValue"?e:{...e,root:o},a=dr(i),s=n===void 0?[...Si(i,ej(i))]:[],l=s.length?[{op:"acceptAllRevisions",siteNodeIds:s,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||a.length===0)return {ops:l,result:{resolved:[],skipped:[...new Set(n??[])].map(S=>({key:S,reason:"unknown-revision"})),remaining:a.length}};let d=new Set(n??a.map(rn)),c=new Map(a.map(S=>[rn(S),S])),u=new Set;for(let S of d){let b=c.get(S);if(b)for(let A of Z(b))u.add(A);}let f=ej(i),x=Vi(o,f,u,t);for(let S of x.selected)u.add(S);for(let S of a){let b=Z(S);b.length&&b.every(A=>u.has(A))&&d.add(rn(S));}let m=hj(o,f),g=new Map(f.map((S,b)=>[S.node.id,b])),y=f.map((S,b)=>b),O=S=>{for(;y[S]!==S;)y[S]=y[y[S]],S=y[S];return S},P=(S,b)=>{y[O(b)]=O(S);};for(let S of x.dependencies){let b=S.flatMap(A=>g.has(A)?[g.get(A)]:[]);for(let A of b)P(b[0],A);}let p=new Map;for(let S of a){let b=Z(S).flatMap(A=>{let X=g.get(A);return X===void 0?[]:[X]});for(let A of b)P(b[0],A);}let k=f.filter(S=>u.has(S.node.id)),v=new Set(_i(e,k,t).keys()),R=new Map;for(let[S,b]of f.entries()){if(t==="reject"&&b.propertyChange&&b.parent&&u.has(b.node.id))for(let X of b.parent.children)Xi$1(b.node.localName,X)||p.set(X.id,S);let A=t==="accept"?b.node.localName==="del"||b.node.localName==="moveFrom":b.node.localName==="ins"||b.node.localName==="moveTo";if(b.paragraphMark&&b.parent&&A&&!m.has(b.node.id)&&u.has(b.node.id)){let X=La(e,b.parent.id),ee=X&&La(e,X.id),le=ee&&La(e,ee.id);if(X&&ee&&le){let z=R.get(le.id);z||(z=cj(le.children,v),R.set(le.id,z)),z.has(ee.id)&&p.set(X.id,S);}}if(u.has(b.node.id)&&$i(e,b,t)){let X=$i(e,b,t);X&&!b.refused&&p.set(X.id,S);}}for(let[S,b]of aj(e,k,t)){let A=Ka(e,S),X=g.get(b[0]);if(!(A?.kind!=="tableCell"||X===void 0))for(let ee of A.children)ee.localName==="tcPr"&&p.set(ee.id,X);}let h=(S,b)=>{let A=g.get(S.id),X=p.get(S.id);A!==void 0&&X!==void 0&&P(X,A);let ee=A??X;ee!==void 0&&b!==void 0&&P(b,ee);let le=ee??b;if(S.kind!=="textValue")for(let z of S.children)h(z,le);};h(o);for(let S of gj(o).values()){let b=S.wrappers.flatMap(A=>{let X=g.get(A.id);return X===void 0?[]:[X]});for(let A of b)P(b[0],A);}for(let S of f.some(b=>b.node.localName==="cellMerge")?bj(i):[]){let b=S.flatMap(A=>{let X=g.get(A);return X===void 0?[]:[X]});for(let A of b)P(b[0],A);}let C=new Map;for(let[S,b]of f.entries()){let A=O(S),X=C.get(A)??[];X.push(b),C.set(A,X);}let I=new Map;for(let[S,b]of C)b.some(A=>A.refused||t==="reject"&&A.propertyChange&&Zi$1(A.node)===null)?I.set(S,"unsupported-revision"):b.some(A=>!u.has(A.node.id))&&I.set(S,"incomplete-group");for(let S of a)if(S.readOnly)for(let b of Z(S)){let A=g.get(b);A!==void 0&&I.set(O(A),"unsupported-revision");}let j=f.filter((S,b)=>u.has(S.node.id)&&!I.has(O(b))),_=false,J=_i(e,j,t);for(let[S,b]of J){if(p.has(S))continue;let A=g.get(b[0]);A!==void 0&&(p.set(S,A),_=true);}if(_){h(o);for(let[S,b]of [...I]){let A=O(S);I.get(A)!=="unsupported-revision"&&I.set(A,b);}}let H=[],T=[],V=new Set,ie=new Set(Ri(e,f,t));for(let S of ie){let b=La(e,S);for(;b;){if(J.has(b.id)){ie.delete(S);break}b=La(e,b.id);}}for(let S of d){let b=c.get(S);if(!b){T.push({key:S,reason:"unknown-revision"});continue}let A={key:S,author:b.author,partName:e.name,revisionKind:b.revisionKind},X=Z(b),ee;for(let le of X){let z=g.get(le);if(ee=z===void 0?"incomplete-group":I.get(O(z)),ee)break}if(X.length||(ee="unsupported-revision"),ee)T.push({key:S,reason:ee,revision:A});else {X.some(le=>ie.has(le))?T.push({key:S,reason:"retained-structure",revision:A}):H.push(A);for(let le of X)ie.has(le)||V.add(le);}}let se=jd(e,f,V),M=new Set;for(let S of a){let b=Z(S);if(S.formattingKind!=="tblGridChange"&&b.length>1)for(let A of b)se.has(A)&&M.add(A);}let $=[...V].filter(S=>!x.implicit.has(S)&&!M.has(S)),K=a.length-H.length;if(K>0&&$.length){let S={...e,root:{...e.root}},b=ij(S,t,void 0,{siteNodeIds:$,...r?{scopeRootId:r.id}:{}});if(b.ok&&b.part){let A=r?Ka(b.part,r.id):b.part.root;K=A&&A.kind!=="textValue"?dr({...b.part,root:A}).length:0;}}return {ops:V.size?[...l,{op:t==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:$,...r?{scopeRootId:r.id}:{}}]:l,result:{resolved:H,skipped:T,remaining:K}}}function ia(e){return e.kind!=="textValue"}function cr(e,t){for(let n of e.children)if(ia(n)&&n.localName===t)return n;return null}function Bu(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(ia(r)){if(r.localName===t)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var Wd=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function Mt(e,t,n){let r=cr(e,t),i=(r?cr(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&Wd.test(i)?i:null}var Hd=new WeakMap;function ju(e){let t=e?Hd.get(e):void 0;if(t)return t;let n=e?Bu(e,"fontScheme"):null;if(!n)return Gd;let r=Object.freeze({major:Mt(n,"majorFont","latin"),minor:Mt(n,"minorFont","latin"),majorEastAsia:Mt(n,"majorFont","ea"),minorEastAsia:Mt(n,"minorFont","ea"),majorBidi:Mt(n,"majorFont","cs"),minorBidi:Mt(n,"minorFont","cs"),...Wu(n)});return e&&Hd.set(e,r),r}var Vd=new WeakMap,Gd=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null});function sa(e,t=null){let n=e?ju(e):Gd,r=t?cr(t,"themeFontLang"):null;if(!r||!t)return n;let o=Vd.get(t);o||Vd.set(t,o=new WeakMap);let i=o.get(n);if(i)return i;let a=x=>r.attributes.find(m=>m.localName===x)?.value,s=zd(a("val")),l=zd(a("bidi")),d=a("eastAsia"),c=mr(d),u=(x,m,g)=>m&&(x?n.majorSupplemental:n.minorSupplemental)?.[m]||g||null,f=Object.freeze({major:u(true,s,n.major),minor:u(false,s,n.minor),majorEastAsia:u(true,c,n.majorEastAsia),minorEastAsia:u(false,c,n.minorEastAsia),majorBidi:u(true,l,n.majorBidi),minorBidi:u(false,l,n.minorBidi),...d===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,f),f}var Hu=new Map([["minorAscii",e=>e.minor],["minorHAnsi",e=>e.minor],["majorAscii",e=>e.major],["majorHAnsi",e=>e.major],["minorEastAsia",e=>e.minorEastAsia??null],["majorEastAsia",e=>e.majorEastAsia??null],["minorBidi",e=>e.minorBidi??null],["majorBidi",e=>e.majorBidi??null]]);function CP(e,t,n){if(e===void 0)return null;let r=Hu.get(e)?.(t)??null;if(r!==null)return r;let o=mr(n);return o?(e==="majorEastAsia"?t.majorSupplemental:e==="minorEastAsia"?t.minorSupplemental:void 0)?.[o]??null:null}function mr(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[0]==="ja"?"Jpan":t[0]==="ko"?"Hang":t[0]!=="zh"?null:t.includes("hant")?"Hant":t.includes("hans")?"Hans":t.some(n=>["tw","hk","mo"].includes(n))?"Hant":"Hans"}var Vu=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function zd(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[1]&&/^[a-z]{4}$/.test(t[1])?t[1][0].toUpperCase()+t[1].slice(1):mr(e)??Vu.get(t[0])??null}var zu=new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]);function MP(e){return zu.get(mr(e)??"")??null}function Wu(e){let t={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of cr(e,n)?.children??[]){if(!ia(i)||i.localName!=="font")continue;let a=i.attributes.find(l=>l.localName==="script")?.value,s=i.attributes.find(l=>l.localName==="typeface")?.value;a&&/^[A-Z][a-z]{3}$/.test(a)&&s&&Wd.test(s)&&(o[a]=s);}Object.keys(o).length&&(t[r]=Object.freeze(o));}return t}var ft=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function la(e,t,n,r){let o=(e.relationships.get(t)??[]).find(i=>i.type===n);if(o){let i=E(o);if(i.mode==="Internal"&&i.target.ok){let a=e.parts.get(i.target.partName);if(a)return a}}return e.parts.get(r)}function VP(e){let t=ne(e);if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let n=t.package.parts.get(t.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:t.package.mainDocumentPart};let r=new en(t.package,aa(t.package,qb(n)));return {ok:true,view:Gu(r)}}function Gu(e){let t=()=>e.currentPackage(),n=()=>e.bodyStore().part,r=(d,c)=>la(t(),t().mainDocumentPart,d,c)?.root??null,o=Object.freeze(sa(null)),i=null,a=Vh,s=null;return Object.freeze({part:n,currentPackage:t,packageRevision:()=>e.packageRevision,stylesRoot:()=>r(ft.styles,"/word/styles.xml"),numberingRoot:()=>r(ft.numbering,"/word/numbering.xml"),settingsRoot:()=>r(ft.settings,"/word/settings.xml"),documentThemeFonts(){let d=t();return i!==d&&(o=Object.freeze(sa(r(ft.theme,"/word/theme/theme1.xml"),r(ft.settings,"/word/settings.xml"))),i=d),o},documentProperties(){let d=t();if(s!==d){let c=la(d,"/",ft.coreProperties,"/docProps/core.xml"),u=la(d,"/",ft.extendedProperties,"/docProps/app.xml");a=Wh(c?.root??null,u?.root??null),s=d;}return a},headerFooterPartsBySection:()=>Re(t()),headerFooterResolutionBySection:()=>Qe$1(t()),relationshipTarget:d=>pg(t(),n().name,d)})}
5
- export{Zh as $,MP as $a,qr as A,ar as Aa,ac as B,fd as Ba,zt as C,uu as Ca,Zr as D,pu as Da,ic as E,gu as Ea,eo as F,hu as Fa,to as G,Zo as Ga,no as H,hd as Ha,ro as I,ox as Ia,dc as J,xd as Ja,Qi as K,sr as Ka,Wt as L,Ex as La,Bn as M,dr as Ma,jn as N,Fd as Na,rs as O,Nu as Oa,Xp as P,wu as Pa,es as Q,Ld as Qa,Cc as R,Tu as Ra,vo as S,Cu as Sa,Ws as T,ra as Ta,Io as U,Ud as Ua,ct as V,Bd as Va,$l as W,Mu as Wa,en as X,aa as Xa,Bl as Y,Uu as Ya,jl as Z,sa as Za,Fo as _,CP as _a,Ky as a,$o as aa,VP as ab,or as b,Ko as ba,Gu as bb,Xy as c,Xo as ca,Qo as d,Bm as da,Yy as e,jm as ea,Xd as f,Hm as fa,Gi as g,Vm as ga,Dn as h,zm as ha,st as i,Wm as ia,_n as j,nd as ja,Fn as k,rd as ka,fe as l,Yo as la,Qd as m,Jo as ma,lt as n,Km as na,Ht as o,Ym as oa,Ln as p,Jm as pa,Vt as q,qm as qa,$n as r,Qm as ra,Xr as s,Z as sa,Yr as t,rn as ta,Jr as u,qo as ua,nc as v,dd as va,rc as w,Tt as wa,Qr as x,au as xa,Xi as y,Hy as ya,oc as z,Vy as za};
@@ -1 +0,0 @@
1
- import {_a}from'./chunk-GWQJ5774.js';import {fa}from'./chunk-UMRSBLO7.js';var z=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,J=128,Q=/[\u0000-\u001F\u007F-\u009F]/,G=16,nn=2,en=3276;function V(e){return e.kind!=="textValue"}function P(e,n){for(let t of e.children)if(V(t)&&t.localName===n)return t}function O(e,n){return e.attributes.find(t=>t.localName===n)?.value}function D(e){return e===void 0||e.length===0||e.length>J||Q.test(e)?null:e}function v(e,n){let t=_a(O(e,"asciiTheme"),n)??_a(O(e,"hAnsiTheme"),n);if(t!==null)return t;let l=O(e,"ascii")??O(e,"hAnsi");return l===void 0?null:z.test(l)?l:null}function C(e,n){let t=_a(O(e,"eastAsiaTheme"),n);if(t!==null)return t;let l=O(e,"eastAsia");return l===void 0?null:z.test(l)?l:null}function tn(e){return e!==void 0&&z.test(e)?e:null}function On(e){return tn(e)}function ln(e){return e!==void 0&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(n=>!!O(e,n))}function Y(e,n){if(!e)return {fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};let t=P(e,"rFonts"),l=P(e,"sz"),i=l?O(l,"val"):void 0,r=i!==void 0&&/^\d{1,4}$/.test(i)?Number(i):null;return {fontFamily:t?v(t,n):null,hasLatinFontReference:ln(t),fontSizeHalfPoints:r!==null&&r>=nn&&r<=en?r:null}}function Sn(e,n){let t=new Map,l={fontFamily:null,fontSizeHalfPoints:null,hasLatinFontReference:false};if(e){let a=P(e,"docDefaults"),s=a?P(a,"rPrDefault"):void 0;l=Y(s?P(s,"rPr"):void 0,n);for(let u of e.children){if(!V(u)||u.localName!=="style")continue;let o=D(O(u,"styleId"));if(o===null||t.has(o))continue;let f=P(u,"basedOn");t.set(o,{basedOn:D(f?O(f,"val"):void 0),own:Y(P(u,"rPr"),n)});}}let i=new Map,r=a=>{let s=a??"",u=i.get(s);if(u)return u;let o=null,f=null,m=l.hasLatinFontReference,b=new Set,y=a;for(let I=0;y!==null&&I<G&&!b.has(y);I+=1){b.add(y);let E=t.get(y);if(!E)break;o??=E.own.fontFamily,m||=E.own.hasLatinFontReference,f??=E.own.fontSizeHalfPoints,y=E.basedOn;}let g={hasLatinFontReference:m,fontFamily:o??l.fontFamily,fontSizeHalfPoints:f??l.fontSizeHalfPoints};return i.set(s,g),g};return (a,s)=>{let u=r(a),o=s?.find(b=>b.localName==="rFonts"),f=o?_a(o.attributes?.asciiTheme,n)??_a(o.attributes?.hAnsiTheme,n):null,m=["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(b=>!!o?.attributes?.[b]);return {fontFamily:f??u.fontFamily??(!u.hasLatinFontReference&&!m?n.minor:null),fontSizeHalfPoints:u.fontSizeHalfPoints}}}var an=16,on=16,rn=32,sn=4096;function x(e){return e.kind!=="textValue"}function c(e,n){for(let t of e.children)if(x(t)&&t.localName===n)return t}function M(e,n){return e.attributes.find(t=>t.localName===n)?.value}function un(e){return e==="1"||e==="true"||e==="on"}function H(){return {families:new Map,styleIds:new Set,anyText:false,bareParagraph:false,bareRun:false,bareTable:false}}function _(e,n){for(let[t,l]of n.families)e.families.has(t)||e.families.set(t,l);for(let t of n.styleIds)e.styleIds.add(t);e.anyText||=n.anyText,e.bareParagraph||=n.bareParagraph,e.bareRun||=n.bareRun,e.bareTable||=n.bareTable;}function T(e,n){if(n===null)return;let t=n.toLowerCase();e.has(t)||e.set(t,n);}var fn=new Set(["tab","noBreakHyphen","softHyphen","footnoteRef","endnoteRef","footnoteReference","endnoteReference"]),dn=128;function cn(e){for(let n of e.attributes)if(n.localName==="font"&&!(n.namespaceUri!==fa&&n.namespaceUri!==""))return n.value.length>0&&n.value.length<=dn;return false}function $(e,n){if(n?.has(e.id))return true;for(let t of e.children)if(!(!x(t)||t.namespaceUri!==fa)){if(fn.has(t.localName))return true;if(t.localName==="sym"){if(!cn(t))return true;continue}if(!(t.localName!=="t"&&t.localName!=="delText")){for(let l of t.children)if(!x(l)&&l.value.length>0)return true}}return false}function mn(e){for(let n of e.children)if(!(!x(n)||n.namespaceUri!==fa)&&!(n.localName!=="t"&&n.localName!=="delText")){for(let t of n.children)if(!x(t))for(let l of t.value){let i=l.codePointAt(0);if(i>=4352&&i<=4607||i>=11904&&i<=40959||i>=43360&&i<=43391||i>=44032&&i<=55295||i>=63744&&i<=64255||i>=65072&&i<=65103||i>=65280&&i<=65519||i>=131072&&i<=262143)return true}}return false}function K(e,n){let t=[e];for(;t.length>0;){let l=t.pop();if(x(l)){if(n?.has(l.id))return true;if(l.localName==="r"&&l.namespaceUri===fa){if($(l,n))return true;continue}for(let i of l.children)t.push(i);}}return false}function yn(e,n,t,l){if(!$(e,l))return;n.anyText=true;let i=c(e,"rPr"),r=i?c(i,"rFonts"):void 0;r&&(T(n.families,v(r,t)),mn(e)&&T(n.families,C(r,t)));let a=i?c(i,"rStyle"):void 0,s=D(a?M(a,"val"):void 0);s!==null?n.styleIds.add(s):n.bareRun=true;}function gn(e,n,t){if(!t)return;n.anyText=true;let l=e.localName==="tbl",i=c(e,l?"tblPr":"pPr"),r=i?c(i,l?"tblStyle":"pStyle"):void 0,a=D(r?M(r,"val"):void 0);a!==null?n.styleIds.add(a):l?n.bareTable=true:n.bareParagraph=true;}function X(e){return (e.localName==="p"||e.localName==="tbl")&&e.namespaceUri===fa}function U(e,n,t,l,i){e.namespaceUri===fa&&(i?.has(e.id)&&e.localName==="fldSimple"&&(n.anyText=true,n.bareRun=true),e.localName==="r"?yn(e,n,t,i):X(e)&&gn(e,n,l));}var W=new WeakMap;function q(e,n,t){let l=W.get(e);if(l&&l.major===n.major&&l.minor===n.minor&&l.majorEastAsia===n.majorEastAsia&&l.minorEastAsia===n.minorEastAsia&&l.majorBidi===n.majorBidi&&l.minorBidi===n.minorBidi)return l.summary;let i=H();if(e.children.length>=on&&t<rn){for(let r of e.children)x(r)&&_(i,q(r,n,t+1));U(e,i,n,i.anyText);}else {let r=[e];for(;r.length>0;){let a=r.pop();if(!x(a))continue;let s=X(a)&&K(a);U(a,i,n,s);for(let u=a.children.length-1;u>=0;u-=1)r.push(a.children[u]);}}return W.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,summary:i}),i}var xn={docDefaultFamilies:[],defaultParagraph:null,defaultCharacter:null,defaultTable:null,chainFamilies:()=>[]},Z=new WeakMap;function w(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?v(l,n):null}function k(e,n){let t=c(e,"rPr"),l=t?c(t,"rFonts"):void 0;return l?C(l,n):null}function hn(e,n){let t=new Map,l=null,i=null,r=null,a=null,s=null,u=c(e,"docDefaults"),o=u?c(u,"rPrDefault"):void 0;o&&(l=w(o,n),i=k(o,n));let f=o?c(o,"rPr"):void 0,m=f?c(f,"rFonts"):void 0;m&&["ascii","hAnsi","asciiTheme","hAnsiTheme"].some(d=>!!M(m,d))||(l??=n.minor);let y=0;for(let d of e.children){if(!x(d)||d.localName!=="style")continue;if(y>=sn)break;y+=1;let h=D(M(d,"styleId"));if(h===null)continue;let S=c(d,"basedOn"),F=[];for(let p of d.children){if(!x(p)||p.localName!=="tblStylePr")continue;let L=w(p,n);L!==null&&F.push(L);let R=k(p,n);R!==null&&F.push(R);}t.set(h,{basedOn:D(S?M(S,"val"):void 0),family:w(d,n),eastAsiaFamily:k(d,n),conditionalFamilies:F});let A=un(M(d,"default")),j=M(d,"type");j==="paragraph"?A?r=h:r===h&&(r=null):j==="character"?A?a=h:a===h&&(a=null):j==="table"&&(A?s=h:s===h&&(s=null));}let g=new Map,I=d=>{if(d===null)return [];let h=g.get(d);if(h)return h;let S=[],F=null,A=null,j=new Set,p=d;for(let L=0;p!==null&&L<an&&!j.has(p);L+=1){j.add(p);let R=t.get(p);if(!R)break;F??=R.family,A??=R.eastAsiaFamily,S.push(...R.conditionalFamilies),p=R.basedOn;}return F!==null&&S.unshift(F),A!==null&&S.unshift(A),g.set(d,S),S};return {docDefaultFamilies:[l,i].filter(d=>d!==null),defaultParagraph:r,defaultCharacter:a,defaultTable:s,chainFamilies:I}}function bn(e,n){if(!e)return {...xn,docDefaultFamilies:n.minor?[n.minor]:[]};let t=Z.get(e);if(t&&t.major===n.major&&t.minor===n.minor&&t.majorEastAsia===n.majorEastAsia&&t.minorEastAsia===n.minorEastAsia&&t.majorBidi===n.majorBidi&&t.minorBidi===n.minorBidi)return t.index;let l=hn(e,n);return Z.set(e,{major:n.major,minor:n.minor,majorEastAsia:n.majorEastAsia,minorEastAsia:n.minorEastAsia,majorBidi:n.majorBidi,minorBidi:n.minorBidi,index:l}),l}function En(e,n,t,l){let i=H(),r=new Map;for(let o of e){let f=H();for(let m of o.children){if(!x(m))continue;if(!l||l.size===0){_(f,q(m,t,0));continue}let b=H(),y=[m];for(;y.length>0;){let g=y.pop();if(!x(g))continue;let I=X(g)&&K(g,l);U(g,b,t,I,l);for(let E=g.children.length-1;E>=0;E-=1)y.push(g.children[E]);}_(f,b);}_(i,f);for(let m of f.families.values())T(r,m);}let a=bn(n,t),s=new Map;for(let o of i.styleIds)for(let f of a.chainFamilies(o))T(s,f);if(i.bareParagraph)for(let o of a.chainFamilies(a.defaultParagraph))T(s,o);if(i.bareRun)for(let o of a.chainFamilies(a.defaultCharacter))T(s,o);if(i.bareTable)for(let o of a.chainFamilies(a.defaultTable))T(s,o);if(i.anyText)for(let o of a.docDefaultFamilies)T(s,o);for(let o of r.keys())s.delete(o);let u=[...s.values()].sort((o,f)=>o<f?-1:o>f?1:0);return Object.freeze({direct:Object.freeze([...r.values()]),inherited:Object.freeze(u)})}function An(e,n,t){let l=En(e,n,t),i=[...l.direct,...l.inherited];return i.sort((r,a)=>r<a?-1:r>a?1:0),i}export{tn as a,On as b,Sn as c,En as d,An as e};