@docx-editor.dev/core 2.32.0 → 2.34.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 (121) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/dist/automation.cjs +1 -1
  4. package/dist/automation.d.ts +14 -52
  5. package/dist/automation.js +1 -1
  6. package/dist/binding.cjs +1 -1
  7. package/dist/binding.d.ts +14 -14
  8. package/dist/binding.js +1 -1
  9. package/dist/{chrome-print-CznJ0ucN.d.ts → chrome-print-DY0xsXm_.d.ts} +231 -125
  10. package/dist/chunk-37IYWENL.cjs +1 -0
  11. package/dist/chunk-37RNWL45.js +4 -0
  12. package/dist/chunk-5HUVQXET.cjs +4 -0
  13. package/dist/chunk-5JP3QQF7.js +7 -0
  14. package/dist/chunk-5KOLFKOB.cjs +5 -0
  15. package/dist/chunk-6MF5PN2E.js +236 -0
  16. package/dist/chunk-77JT2AU7.js +2 -0
  17. package/dist/{chunk-ETDZFNMI.js → chunk-7FUORGCW.js} +1 -1
  18. package/dist/chunk-A5BTVPET.cjs +236 -0
  19. package/dist/chunk-AFXFH2T2.js +3 -0
  20. package/dist/chunk-AVCYP7OY.js +5 -0
  21. package/dist/chunk-BL2E4QRA.js +1 -0
  22. package/dist/chunk-DB7X4Y6O.js +4 -0
  23. package/dist/chunk-DR6W23TB.cjs +2 -0
  24. package/dist/chunk-DYLB5U42.js +1 -0
  25. package/dist/chunk-E5BKDHIP.cjs +1 -0
  26. package/dist/chunk-IWXBRUPG.cjs +4 -0
  27. package/dist/{chunk-L5TYBFDB.js → chunk-KCUXXO3Q.js} +1 -1
  28. package/dist/chunk-KYA4Y2YB.js +1 -0
  29. package/dist/{chunk-6UDJUI3W.cjs → chunk-L74TCGVH.cjs} +1 -1
  30. package/dist/chunk-NBSSQSKY.js +30 -0
  31. package/dist/{chunk-OKMEMSKB.cjs → chunk-NEM774E3.cjs} +1 -1
  32. package/dist/chunk-NKZVMMHU.cjs +1 -0
  33. package/dist/chunk-TXIO5WYQ.cjs +32 -0
  34. package/dist/chunk-UKG2TXWH.cjs +7 -0
  35. package/dist/chunk-V7CO55DO.cjs +3 -0
  36. package/dist/chunk-VLQDQNSS.js +1 -0
  37. package/dist/chunk-VQOAC3VI.cjs +30 -0
  38. package/dist/chunk-YWJSQA2O.js +32 -0
  39. package/dist/chunk-ZJ74LCFI.cjs +1 -0
  40. package/dist/collaboration/replication.cjs +1 -1
  41. package/dist/collaboration/replication.d.ts +13 -4
  42. package/dist/collaboration/replication.js +1 -1
  43. package/dist/collaboration.d.ts +3 -3
  44. package/dist/contracts/document.d.ts +3 -3
  45. package/dist/contracts/editor.d.ts +10 -10
  46. package/dist/contracts/interaction.d.ts +2 -2
  47. package/dist/contracts/modules.d.ts +12 -12
  48. package/dist/contracts/types.d.ts +4 -4
  49. package/dist/{custom-node-writes-CLJKGD9t.d.ts → custom-node-writes-DparEcZK.d.ts} +45 -7
  50. package/dist/diagnostic-context-CkZKkKvB.d.ts +98 -0
  51. package/dist/{diagnostic-hints-DK8-V0fk.d.ts → diagnostic-hints-BTyb8yzX.d.ts} +3 -3
  52. package/dist/{document-protection-NaniLHWF.d.ts → document-protection-DdWxihIN.d.ts} +1 -1
  53. package/dist/{headless-document-view-Bcz9_Qva.d.ts → drawing-graphic-kind-CK0cMc7H.d.ts} +161 -18
  54. package/dist/drawing-preview-package-fFjXpOMS.d.ts +115 -0
  55. package/dist/{editor-DZwOTmlR.d.ts → editor-DDCkWqfD.d.ts} +125 -21
  56. package/dist/{editor-scope-B3L-1ALc.d.ts → editor-scope-CA6egMaK.d.ts} +5 -1
  57. package/dist/editor.cjs +1 -1
  58. package/dist/editor.css +4 -4
  59. package/dist/editor.d.ts +387 -78
  60. package/dist/editor.js +1 -1
  61. package/dist/export.cjs +2 -2
  62. package/dist/export.d.ts +47 -12
  63. package/dist/export.js +2 -2
  64. package/dist/{font-resolver-BlQNGdvR.d.ts → font-resolver-Bm9XqTNO.d.ts} +14 -0
  65. package/dist/index.cjs +1 -1
  66. package/dist/index.d.ts +38 -23
  67. package/dist/index.js +1 -1
  68. package/dist/{layout-shaping-E5J4Z1Gf.d.ts → layout-shaping-Byj-TwsI.d.ts} +1 -1
  69. package/dist/layout.cjs +1 -1
  70. package/dist/layout.d.ts +434 -199
  71. package/dist/layout.js +1 -1
  72. package/dist/metafile-drawing-Ce6TuWLm.d.ts +115 -0
  73. package/dist/{note-properties-Ds5R2_3F.d.ts → note-properties-BiunaIQa.d.ts} +31 -7
  74. package/dist/output.cjs +1 -1
  75. package/dist/output.d.ts +77 -13
  76. package/dist/output.js +1 -1
  77. package/dist/{protocol-DKa4qt7F.d.ts → protocol-Dn44dL4M.d.ts} +184 -120
  78. package/dist/{review-paragraph-order-Dc17w_6v.d.ts → review-paragraph-order-BWMXAKuA.d.ts} +1 -1
  79. package/dist/{revision-projection-Cn6rZJ7H.d.ts → revision-projection-DwFhgIR0.d.ts} +1 -1
  80. package/dist/{semantic-cell-selection-BaUR0iJ4.d.ts → semantic-cell-selection-DhalxEBH.d.ts} +2 -2
  81. package/dist/{semantic-interaction-CJoHLoOl.d.ts → semantic-interaction-QeuzEtAk.d.ts} +2 -4
  82. package/dist/{semantic-paint-BPw_n0li.d.ts → semantic-paint-BYDZbTiY.d.ts} +16 -9
  83. package/dist/{semantic-record-queries-C0rJ3sB4.d.ts → semantic-record-queries-Bf5bgQL3.d.ts} +1 -1
  84. package/dist/{semantic-records-BvN-WWst.d.ts → semantic-records-CzZiWMY8.d.ts} +348 -132
  85. package/dist/store.cjs +1 -1
  86. package/dist/store.d.ts +526 -19
  87. package/dist/store.js +1 -1
  88. package/dist/{tree-op-types-C_S2niXW.d.ts → tree-op-types-DKvJSH8T.d.ts} +1024 -501
  89. package/dist/{tree-package-store-CRHvMyNj.d.ts → tree-package-store-Cl3BkWXF.d.ts} +8 -3
  90. package/dist/{tree-session-contract-D1awo_dA.d.ts → tree-session-contract-BL50pqs8.d.ts} +15 -8
  91. package/dist/{unsupported-elements-CVos5cqe.d.ts → unsupported-elements-Bra4QTOM.d.ts} +1 -1
  92. package/licenses/ECMA-376.md +29 -0
  93. package/package.json +2 -2
  94. package/dist/bookmark-names-DDuAra_V.d.ts +0 -37
  95. package/dist/chunk-25EXMBV2.cjs +0 -5
  96. package/dist/chunk-3IEXDEFH.cjs +0 -7
  97. package/dist/chunk-65XBN67F.cjs +0 -2
  98. package/dist/chunk-6NVZNB7O.cjs +0 -3
  99. package/dist/chunk-ACLR4DMK.js +0 -1
  100. package/dist/chunk-B2BEELUE.js +0 -1
  101. package/dist/chunk-DDFHKQFU.js +0 -30
  102. package/dist/chunk-E4IAO4CY.cjs +0 -2
  103. package/dist/chunk-FDSL5OJU.cjs +0 -30
  104. package/dist/chunk-FS7CMYLT.js +0 -4
  105. package/dist/chunk-GDS24SZN.js +0 -30
  106. package/dist/chunk-GIY6NT2X.js +0 -5
  107. package/dist/chunk-GWM3AKUD.js +0 -18
  108. package/dist/chunk-HDOXACHP.js +0 -2
  109. package/dist/chunk-IILEENID.js +0 -1
  110. package/dist/chunk-MNF2K7NN.cjs +0 -30
  111. package/dist/chunk-O324RB6R.cjs +0 -1
  112. package/dist/chunk-QXJKYNYZ.js +0 -1
  113. package/dist/chunk-RALTVLB6.js +0 -2
  114. package/dist/chunk-SRVKFUFI.js +0 -3
  115. package/dist/chunk-TELQ52LG.cjs +0 -1
  116. package/dist/chunk-TJHE5EET.cjs +0 -1
  117. package/dist/chunk-UMMRURPE.js +0 -7
  118. package/dist/chunk-XJYZVGQR.cjs +0 -1
  119. package/dist/chunk-ZGTIE3QJ.cjs +0 -4
  120. package/dist/chunk-ZOZI27AW.cjs +0 -18
  121. package/dist/diagnostic-context-BtDUY3v2.d.ts +0 -31
@@ -0,0 +1,4 @@
1
+ import {h,i,u,k,p,o,n,v,w,Ld as Ld$1,ve,pa as pa$1,ue,vk,wi,An,gj,mg,Ye,H,ng,W,F,Xe,Vm as Vm$1,Ch,Sb,Wb,Cj,eb,kg as kg$1,Pa as Pa$1,ug,tg,sg,gg,Va as Va$1,Wa,Kk,Rb,Ng,g,wf,Nk,Ok,Fk,Na as Na$1,vg,En as En$1,Bj,Fn,Qj,zj,Aj,bj,cj,N,Ob,Cn,X,Gh,Ub,Pb,Ib,hb,bf,ff as ff$1,Hj,jf,jc as jc$1,jk,ek,ok,ik,hk,ck,rk,dk,qk,kk,gk,E,V,ab,ib,gb,Jb,Lb,Nb,Ih,Tb,om as om$1,hm as hm$1,nm as nm$1,qm as qm$1,Ah,Yl as Yl$1,Il as Il$1,$k,gl as gl$1,fl as fl$1,cl as cl$1,sl as sl$1,Kl as Kl$1,al as al$1,Fl as Fl$1,Gl as Gl$1,bl as bl$1,Cl as Cl$1,ul as ul$1,Yk,db,yl as yl$1,Dl as Dl$1,El as El$1,cb,Al as Al$1,em as em$1,xl as xl$1,dm as dm$1,Ll as Ll$1,je,Yi,nf as nf$1,of as of$1,Wj,Vj,va as va$1,Yd as Yd$1,oe as oe$1,Te,Fe,Ne,ld as ld$1,sa as sa$1,Ha as Ha$1,K,Xi,f,_f,qg,mm as mm$1,Pk,Rk,Tk,wn as wn$1,Bn,Ti,Cm as Cm$1,zm as zm$1,fb,si,Oj,ag,Xf,Zf,bg,dg,cn,eg,ye,gf as gf$1,bk,Kb,ua as ua$1,Fb,Dj,zh,hc as hc$1,Bl as Bl$1,oa as oa$1,ya as ya$1,wa as wa$1,Fa as Fa$1,Ia as Ia$1,Ga,Jf,Wf,Zk,Vb,Qb as Qb$1,qf,Bm as Bm$1,Re as Re$1,Ke as Ke$1,Le,O,La as La$1,l,Ma as Ma$1,C,cf as cf$1,df as df$1,ef as ef$1,Ej,hf as hf$1,Tc as Tc$1,Ic as Ic$1,$e,af as af$1,Gj,if as _if,Bh,Wk,Xk,rm as rm$1,tl as tl$1,_k,lm as lm$1,km as km$1,ui,sj,uj,tj,Oe,Ka,Y,Fj,Ta as Ta$1,Xa,ia as ia$1,pm as pm$1,lc as lc$1,oj,fm as fm$1,mi,ea as ea$1,Za,Ya,ni,Yg,uk,Ca as Ca$1,Am as Am$1,Zi,on,pn as pn$1,qa,Uf,Vf,Tf}from'./chunk-6MF5PN2E.js';import {strFromU8,strToU8}from'fflate';var Vd=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],jd=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,Gd=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Qs(e){return jd.test(e)||Gd.test(e)}function ur(e,t){if(!Qs(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 zd=/^(\d+)\.(\d+)\.(\d+)$/;function vt(e){let t=zd.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 fr(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 gr(e,t){let n=vt(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=vt(r.slice(1));return fr(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 a=true;for(let i of o){let s=i.startsWith(">=")?">=":i.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=vt(i.slice(s.length)),c=fr(n,l);s===">="?a=a&&c>=0:a=a&&c<0;}return a}return fr(n,vt(r))===0}var Re=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},So=(e,t)=>`${e}:${t}`;function Wd(e,t={}){let n=new Map;for(let c of e){if(ur(c.id,"extension"),Zs(c.version,c.id),n.has(c.id))throw new Re("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let d of c.contributions)ur(d.id,d.kind),Zs(d.version,`${c.id} \u2192 ${d.id}`),d.replaces&&Yd(d.replaces.targetRange,`${c.id} \u2192 replaces ${d.replaces.targetId}`);}for(let c of e){for(let d of c.dependencies??[])if(!n.has(d))throw new Re("missing-dependency",`${c.id} requires missing extension ${d}`,[c.id,d]);for(let d of c.conflicts??[])if(n.has(d)){let m=[c.id,d].sort();throw new Re("conflict",`extensions ${m[0]} and ${m[1]} conflict`,m)}}Xd(n);let r=new Set(t.availablePorts??[]);for(let c of e)for(let d of c.contributions)d.kind==="runtimePort"&&r.add(d.id);for(let c of e)for(let d of c.requiredPorts??[])if(!r.has(d))throw new Re("missing-port",`${c.id} requires unavailable port ${d}`,[c.id,d]);let o=new Map,a=new Map,i=new Map;for(let c of e)for(let d of c.contributions){let m=So(d.kind,d.id);if(d.replaces){let f=So(d.kind,d.replaces.targetId),h=i.get(f)??[];h.push({ext:c.id,c:d}),i.set(f,h);continue}if(a.has(m)){let f=[o.get(m),c.id].sort();throw new Re("id-collision",`${d.kind} id ${d.id} registered by both ${f[0]} and ${f[1]}`,f)}a.set(m,d),o.set(m,c.id);}let s=new Map(a);for(let[c,d]of i){let m=a.get(c);if(!m){let y=d[0];throw new Re("replacement-target-missing",`${y.ext} replaces missing target ${y.c.replaces.targetId}`,[y.ext,y.c.replaces.targetId])}let f=m.replaceable??{kind:"none"};for(let{ext:y,c:P}of d){if(!gr(m.version,P.replaces.targetRange))throw new Re("replacement-version-mismatch",`${y} replaces ${P.replaces.targetId}@${m.version} outside range ${P.replaces.targetRange}`,[y,P.replaces.targetId]);if(f.kind==="none")throw new Re("unauthorized-replacement",`${P.replaces.targetId} does not authorize replacement (attempted by ${y})`,[y,P.replaces.targetId])}let h=Kd(m,d);s.set(c,h);}return {extensions:n,contributions:s,get:(c,d)=>s.get(So(c,d))}}function Kd(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)),a=o[0].c.replaces.priority??0,i=o.filter(s=>(s.c.replaces.priority??0)===a);if(i.length>1){let s=i.map(l=>l.ext).sort();throw new Re("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${a}: ${s.join(", ")}`,s)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new Re("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Xd(e){let o=new Map,a=[],i=s=>{o.set(s,1),a.push(s);let l=[...e.get(s)?.dependencies??[]].sort();for(let c of l){let d=o.get(c)??0;if(d===1){let m=a.indexOf(c),f=[...a.slice(m),c];throw new Re("dependency-cycle",`dependency cycle: ${f.join(" -> ")}`,f)}d===0&&i(c);}a.pop(),o.set(s,2);};for(let s of [...e.keys()].sort())(o.get(s)??0)===0&&i(s);}function Zs(e,t){try{vt(e);}catch{throw new Re("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Yd(e,t){try{gr("0.0.0",e);}catch{throw new Re("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var wt=class extends Error{constructor(t){super(t),this.name="BudgetError";}},pn=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new u(`${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 wt(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new wt(`${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 wt(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new wt(`${this.label}: budget already released`)}};var hr=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},un=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 hr(t.derivedOnly,t._reason)}}}};var yr=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},vo=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 yr(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(k.clock)}identity(){return this.resolve(k.identity)}},wo=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}},Eo=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function qd(e){let t=p(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",a={id:o,limits:t,config:n,ports:e.ports,budget:new pn(`op:${o}`,r),cancellation:new un};return Object.freeze(a)}function Jd(e){e.budget.dispose();}var Co=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"}}),el=Object.keys(Co);function Qd(e,t){return new u(`${Co[t].phase}:${t}`,e[t])}var To=class{counter;current=0;peak=0;constructor(t){this.counter=new u("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 Zd(){for(let e of el){let t=o[e],n$1=n[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n$1)||n$1<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n$1)throw new Error(`default ${e} exceeds ceiling`)}}var Qe="dev.docx-editor.core.comparator",Mo={authoredState:{id:`${Qe}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${Qe}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${Qe}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${Qe}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${Qe}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${Qe}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${Qe}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${Qe}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${Qe}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${Qe}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function Do(e,t,n,r={}){let o=Mo[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:tl(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let a=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,i=v(t,a),s=v(n,a);return i===s?{equal:true}:{equal:false,left:i,right:s}}}}function Ao(e,t){let n=Mo[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 w(t,r)}function tl(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)=>tl(r,t[o],n)):false}var rl=new Set([...h,...i]),nl=/^[0-9a-f]{16}$/,em=/^[0-9a-f]*$/;function _o(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,a)=>{let i=`step[${a}]`;rl.has(o.origin)||n(`${i}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${i}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${i}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${i}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${i}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&tm(s.modelChange,i,n)):(s.committedRevision!==void 0&&n(`${i}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${i}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!nl.test(s.authoredStateHash)&&n(`${i}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!nl.test(s.outputHash)&&n(`${i}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),em.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 tm(e,t,n){rl.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function nm(e,t){let n=_o(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,a)=>{let i=`step[${a}]`,s=t.applyStep(o),l=o.expect;if(s.outcome!==l.outcome){r.push(`${i}: outcome ${s.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(s.committedRevision!==l.committedRevision&&r.push(`${i}: revision ${s.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${i}: store returned no authored state to hash`);else {Do("authoredState",s.authoredState,s.authoredState).equal||r.push(`${i}: authored state is not self-consistent`);let d=ol(s.authoredState);d!==l.authoredStateHash&&r.push(`${i}: authoredStateHash ${d} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function ol(e){return Ao("authoredState",e)}var rm="urn:schemas-microsoft-com:office:office";function om(e){return e.namespaceUri!==pa$1?false:e.localName==="object"?true:e.localName==="pict"&&e.children.some(t=>t.kind!=="textValue"&&t.namespaceUri===rm&&t.localName==="OLEObject")}function al(e){if(e.kind==="textValue")return false;if(Ld$1(e))return ve(e)!==null;let t=e;return (t.kind==="drawing"||t.namespaceUri===pa$1&&t.localName==="drawing")&&ue(t)}function am(e){return e.kind==="textValue"?false:om(e)||al(e)}function il(e,t){let n=[...e];for(;n.length;){let r=n.pop();if(r.kind!=="textValue"){if(t(r))return true;for(let o of r.children)n.push(o);}}return false}function fn(e){return il(e,am)}function kg(e){return il(e,al)}var sl=24,kr=Object.freeze([Object.freeze({localName:"kern",attributes:Object.freeze({val:"2"})}),Object.freeze({localName:"sz",attributes:Object.freeze({val:String(sl)})}),Object.freeze({localName:"szCs",attributes:Object.freeze({val:String(sl)})})]),Pr=Object.freeze([Object.freeze({localName:"spacing",attributes:Object.freeze({after:"160",line:"278",lineRule:"auto"})})]),cl=Object.freeze({run:true,paragraph:true}),dl=Object.freeze({run:false,paragraph:false});function ml(e){if(!e)return cl;let t=n=>e.children.some(r=>r.kind!=="textValue"&&r.namespaceUri===pa$1&&r.localName===n);return {run:!t("rPrDefault"),paragraph:!t("pPrDefault")}}function Uo(e,t){return e&&e.namespaceUri!==pa$1?dl:ml(t)}function Rg(e){return e?e.namespaceUri!==pa$1?dl:ml(im(e)):cl}function xr(e,t,n,r){return {id:n,kind:e,namespaceUri:pa$1,localName:t,prefix:"w",namespaceBindings:[],attributes:[],children:r}}function ll(e,t){let n=e==="rPr"?kr:Pr;return xr(e==="rPr"?"runProperties":"paragraphProperties",e,`${t}-${e}`,n.map(r=>vk(r,`${t}-${e}-${r.localName}`)))}function im(e){let t=e.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===pa$1&&n.localName==="docDefaults");return t&&t.kind!=="textValue"?t:void 0}function pl(e,t,n){let r=Uo(e,t);if(!r.run&&!r.paragraph)return t;let o=[];r.run&&o.push(xr("generic","rPrDefault",`${n}-rPrDefault`,[ll("rPr",n)])),r.paragraph&&o.push(xr("generic","pPrDefault",`${n}-pPrDefault`,[ll("pPr",n)]));let a=r.run?[...o,...t?.children??[]]:[...t?.children??[],...o];return t?{...t,children:a}:xr("generic","docDefaults",`${n}-docDefaults`,a)}var Et="http://schemas.openxmlformats.org/officeDocument/2006/relationships",sm="http://schemas.openxmlformats.org/package/2006/relationships",lm="http://schemas.openxmlformats.org/drawingml/2006/main",gl="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",hl="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",yl="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",xl="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",kl="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",Fo="application/vnd.openxmlformats-package.relationships+xml",Lo=`${Et}/styles`,$o=`${Et}/numbering`,Pl=`${Et}/footnotes`,Ol=`${Et}/endnotes`,bl=`${Et}/officeDocument`,cm=`${Et}/theme`;function We(e){return e.kind!=="textValue"}function ul(e,t){return {...e,children:t}}function ht(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)ht(n,t);}var dm=new Set(["pStyle","rStyle","tblStyle"]);function Bo(e,t){for(let n of e)ht(n,r=>{if(r.kind!=="textValue"&&dm.has(r.localName)&&r.namespaceUri===pa$1){let o=Ch(r,"val");o&&t.add(o);}});}function Ho(e,t){for(let n of e)ht(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===pa$1){let o=Ch(r,"val");o&&t.add(o);}});}function Vo(e){let t=new Set;return gn(e,t),t}function gn(e,t){for(let n of e)ht(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===Et&&o.value.length>0&&t.add(o.value);});}function He(e){return /^\d+$/.test(e)?e.replace(/^0+(?=\d)/,""):e}function br(e,t){let n={footnote:new Set,endnote:new Set},r=[],o=a=>{for(let i of a)ht(i,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",c=Ch(s,"id");if(c===void 0)return;let d=He(c);n[l].has(d)||(n[l].add(d),r.push({kind:l,id:d}));});};for(o(e);r.length>0;){let a=r.pop(),i=t(a.kind,a.id);i!==null&&o([i]);}return n}function jo(e,t,n){if(e.kind==="textValue")return e;let r=[],o=false;for(let a of e.children){if(a.kind!=="textValue"&&a.namespaceUri===pa$1&&(a.localName==="footnoteReference"||a.localName==="endnoteReference")){let l=a.localName==="footnoteReference"?t:n,c=Ch(a,"id");if(a.kind!=="noteReference"||c===void 0||!l.has(He(c))){o=true;continue}}let s=jo(a,t,n);s!==a&&(o=true),r.push(s);}return o?{...e,children:r}:e}function mm(e,t){for(let n of mg(e,t)){if(n.type!==Lo||n.targetMode==="External")continue;let r=E(n.ownerPart,n.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return e.parts.get("/word/styles.xml")??null}function Rl(e,t,n){for(let r of mg(e,t)){if(r.type!==n||r.targetMode==="External")continue;let o=E(r.ownerPart,r.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return null}function Il(e,t){let n=mm(e,t),r=new Map,o=[],a=null;if(n&&We(n.root))for(let i of n.root.children){if(!We(i))continue;if(i.localName==="docDefaults"&&i.namespaceUri===pa$1){a=i;continue}if(i.localName!=="style"||i.namespaceUri!==pa$1)continue;let s=Ch(i,"styleId");s&&r.set(s,i),(Ch(i,"default")==="1"||Ch(i,"default")==="true")&&o.push(i);}return {part:n,byId:r,defaults:o,docDefaults:a}}var pm=new Set(["basedOn","link","next"]);function Nl(e,t){let n=new Set,r=[...t];for(let i of e.defaults){let s=Ch(i,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let i=r.pop();if(n.has(i))continue;n.add(i);let s=e.byId.get(i);if(s){o.push(s);for(let l of s.children)if(We(l)&&pm.has(l.localName)&&l.namespaceUri===pa$1){let c=Ch(l,"val");c&&r.push(c);}}}if(!e.part||!We(e.part.root))return o;let a=new Map;return e.part.root.children.forEach((i,s)=>a.set(i,s)),o.sort((i,s)=>(a.get(i)??0)-(a.get(s)??0))}function Go(e,t,n){let r=Rl(e,t,$o)??e.parts.get("/word/numbering.xml")??null;if(!r||!We(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],a=new Set;for(let s of r.root.children){if(!We(s)||s.localName!=="num"||s.namespaceUri!==pa$1)continue;let l=Ch(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let c of s.children)if(We(c)&&c.localName==="abstractNumId"){let d=Ch(c,"val");d&&a.add(d);}}}let i=[];for(let s of r.root.children){if(!We(s)||s.localName!=="abstractNum"||s.namespaceUri!==pa$1)continue;let l=Ch(s,"abstractNumId");l&&a.has(l)&&i.push(s);}return {part:r,nums:o,abstracts:i}}var Or={latin:null,eastAsia:null,cs:null};function Sl(e,t){let n=Rl(e,t,cm);if(!n)return {major:Or,minor:Or};let r={major:{...Or},minor:{...Or}};return ht(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==lm||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let a=o.localName==="majorFont"?r.major:r.minor;for(let i of o.children){if(!We(i))continue;let s=Ch(i,"typeface");s&&(i.localName==="latin"?a.latin=s:i.localName==="ea"?a.eastAsia=s:i.localName==="cs"&&(a.cs=s));}}),{major:r.major,minor:r.minor}}function um(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 fm=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],fl=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function yt(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===pa$1){let a=[],i=new Map;for(let s of e.attributes){let l=fm.find(([c])=>c===s.localName);if(l&&s.namespaceUri===pa$1){let c=um(t,s.value);c&&i.set(l[1],c);continue}a.push(s);}for(let[s,l]of i)a.some(c=>c.localName===s)||a.push({kind:"genericExtension",namespaceUri:pa$1,localName:s,prefix:"w",value:l});n=a;}else e.attributes.some(a=>fl.has(a.localName)&&a.namespaceUri===pa$1&&e.attributes.some(i=>i.localName==="val"))&&(n=e.attributes.filter(a=>!(fl.has(a.localName)&&a.namespaceUri===pa$1)));let r=e.children.map(a=>yt(a,t)),o=r.some((a,i)=>a!==e.children[i]);return n===e.attributes&&!o?e:{...e,attributes:n,children:r}}function vl(e,t,n){return {id:e,name:e,contentType:t,root:n}}function wl(e,t){if(e.root.kind==="document"){let r=e.root.children.find(a=>a.kind==="body"),o=r&&We(r)?ul(r,t):{id:"fragment#body",kind:"body",namespaceUri:pa$1,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return ul(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:pa$1,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:pa$1,localName:"document",prefix:"w",namespaceBindings:We(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function hn(e){let t=e.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${W(n.id)}" Type="${W(n.type)}" Target="${W(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${sm}">${t}</Relationships>`}function El(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Tl(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Rr(e,t){return {...e,children:t}}function Ir(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===pa$1}function yn(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)yn(n,t);return t}function Cl(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=Cl(n,t);if(r)return r}return null}function gm(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&Ir(n,"vMerge")){if(Ch(n,"val")==="restart")return n;let a=[...n.attributes.filter(i=>!(i.localName==="val"&&i.namespaceUri===pa$1)),{kind:"wmlVal",namespaceUri:pa$1,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:a}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||Ir(n,"tc");return Rr(n,n.children.map(a=>t(a,o)))};return Rr(e,e.children.map(n=>t(n,false)))}function Ml(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(Ir(e,"tr")){t.push(e);return}for(let n of e.children)Ml(n,t);}}function Dl(e,t,n){if(e.kind==="textValue"||e.kind==="table")return {node:e,hadRows:false,keptRows:false};if(Ir(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let i=n.value?gm(e):e;return n.value=false,{node:i,hadRows:true,keptRows:true}}let r=false,o=false,a=[];for(let i of e.children){let s=Dl(i,t,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&a.push(s.node);}return r?{node:o?Rr(e,a):null,hadRows:true,keptRows:o}:{node:e,hadRows:false,keptRows:false}}function Al(e,t,n){let r=[];for(let l of e.children)Ml(l,r);let o=new Set(yn(e).filter(l=>t.inRange.has(l)));if(o.size===0)return;let a=r.filter(l=>{let c=yn(l);return c.length>0&&c.every(d=>t.covered.has(d))}),i=new Set(a.flatMap(l=>yn(l)));if(a.length>0&&o.size===i.size&&[...o].every(l=>i.has(l))){let l={value:true},c=new Set(a),d=[];for(let m of e.children){let f=Dl(m,c,l);f.node!==null&&d.push(f.node);}n.push(Rr(e,d));return}for(let l of yn(e)){if(!t.inRange.has(l))continue;let c=Cl(e,l);c&&n.push(c);}}var hm="http://schemas.openxmlformats.org/package/2006/content-types",ym=5e4;function Ze(e){return e.kind!=="textValue"}function _l(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)_l(n,t);return t}function zo(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=zo(n,t);if(r)return r}return null}function xm(){return {id:"fragment#styles",kind:"generic",namespaceUri:pa$1,localName:"styles",prefix:"w",namespaceBindings:[{prefix:"w",namespaceUri:pa$1}],attributes:[],children:[]}}function st(e,t){return {...e,children:t}}function km(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===pa$1}function Pm(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&Ze(t)?t:null}return Ze(e.root)?e.root:null}function Om(e,t){return _l(e).some(n=>t.has(n))}function Wo(e,t,n){for(let r of e)if(Ze(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"){Al(r,t,n);continue}if(r.kind==="contentControl"){let o=r.children.find(a=>a.kind==="contentControlContent");o&&Ze(o)&&Wo(o.children,t,n);continue}Om(r,t.inRange)&&Wo(r.children,t,n);}}var bm=new Set(["commentRangeStart","commentRangeEnd"]);function Rm(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function Ko(e){if(e.kind==="textValue")return e;if(bm.has(e.localName)&&e.namespaceUri===pa$1||Rm(e)||km(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=Ko(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?st(e,n):e}function Im(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let c of l.children)if(c.kind==="fldChar"){let d=Ch(c,"fldCharType");t.push({nodeId:c.id,type:d==="separate"||d==="end"?d:"begin"});}else c.kind==="instrText"&&t.push({nodeId:c.id,type:"instr"});return}for(let c of l.children)n(c);}};for(let l of e)n(l);if(t.length===0)return e;let r=new Set,o=[],a=null,i=[];for(let l of t){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let d=o[o.length-1];d?d.separateId=l.nodeId:a=l.nodeId;continue}if(l.type==="instr"){let d=o[o.length-1];d?d.instrIds.push(l.nodeId):a===null&&i.push(l.nodeId);continue}if(!o.pop()){r.add(l.nodeId),a!==null&&r.add(a);for(let d of i)r.add(d);a=null,i=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let c of l.instrIds)r.add(c);}a!==null&&r.add(a);for(let l of i)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 c=[],d=false;for(let m of l.children){let f=s(m);if(f===null){d=true;continue}f!==m&&(d=true),c.push(f);}return d?st(l,c):l};return e.map(l=>s(l)).filter(l=>l!==null)}function Xo(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=Xo(n);return t}function Nm(e,t){let n=[];for(let r of e.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=t.get(r.id),a=Xo(r);if(o===void 0||a>=o){n.push(r);continue}if(a===0)continue;let i=r.children.find(s=>s.kind==="contentControlContent");i&&Ze(i)?n.push(...i.children):n.push(r);}return st(e,n)}function Sm(e){let t=new Set,n=new Set,r=i=>{if(i.kind!=="textValue"){if(i.kind==="bookmarkStart"){let s=Ch(i,"id");s!==void 0&&t.add(s);}if(i.kind==="bookmarkEnd"){let s=Ch(i,"id");s!==void 0&&n.add(s);}for(let s of i.children)r(s);}};for(let i of e)r(i);let o=new Set([...t].filter(i=>n.has(i)));if(o.size===t.size&&o.size===n.size)return e;let a=i=>{if(i.kind==="textValue")return i;if(i.kind==="bookmarkStart"||i.kind==="bookmarkEnd"){let c=Ch(i,"id");return c!==void 0&&o.has(c)?i:null}let s=[],l=false;for(let c of i.children){let d=a(c);if(d===null){l=true;continue}d!==c&&(l=true),s.push(d);}return l?st(i,s):i};return e.map(i=>a(i)??i)}function vm(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],a=t.paragraphIds[t.paragraphIds.length-1],i=new Map;for(let R of [o,a]){let G=zo(r.root,R);if(!G)return {ok:false,reason:"empty-range"};for(let W of G.children)W.kind==="contentControl"&&i.set(W.id,Xo(W));}let s=r,l=zo(s.root,a);if(!l)return {ok:false,reason:"empty-range"};let c=wi(l);if(t.endOffset<c){let R=An(s,{op:"deleteText",paragraphId:a,start:t.endOffset,end:c},{deferValidation:true});if(!R.ok)return {ok:false,reason:"trim-refused"};s=R.part;}if(t.startOffset>0){let R=An(s,{op:"deleteText",paragraphId:o,start:0,end:t.startOffset},{deferValidation:true});if(!R.ok)return {ok:false,reason:"trim-refused"};s=R.part;}let d=Pm(s);if(!d)return {ok:false,reason:"unknown-part"};let m={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},f=[];if(Wo(d.children,m,f),f.length===0)return {ok:false,reason:"empty-range"};if(f.length>ym)return {ok:false,reason:"resource-limit"};let h=f.map(R=>Ko(R)).filter(R=>R!==null).map(R=>R.kind!=="paragraph"||R.id!==o&&R.id!==a?R:Nm(R,i));h=[...Im(h)],h=[...Sm(h)];let y=gj(e,"footnote"),P=gj(e,"endnote"),T=(R,G)=>Ze(R)&&R.namespaceUri===pa$1&&R.localName===G,p=br(h,(R,G)=>{let W=R==="footnote"?y:P;if(!W||!Ze(W.root))return null;for(let re of W.root.children){if(!T(re,R))continue;let Y=Ch(re,"id");if(Y!==void 0&&He(Y)===G)return re}return null}),x=p.footnote,k=p.endnote;x.size===0&&(y=null),k.size===0&&(P=null);let v=(R,G,W)=>{if(!R||!Ze(R.root))return [];let re=[];for(let Y of R.root.children){if(!T(Y,G))continue;let se=Ch(Y,"id"),g=Ch(Y,"type");if(g==="separator"||g==="continuationSeparator"){re.push(Y);continue}if(se!==void 0&&W.has(He(se))){let u=Ko(Y);u&&Ze(u)&&re.push(u);}}return re},A=v(y,"footnote",x),O=v(P,"endnote",k),D=[...A,...O];if(fn(h)||fn(D))return {ok:false,reason:"unsupported-content"};let F$1=[...h,...D],w=new Set;Bo(F$1,w);let N=Il(e,e.mainDocumentPart),S=new Set;Ho(F$1,S);let I=[],_=Go(e,e.mainDocumentPart,S);for(;;){let R=w.size,G=S.size;I=Nl(N,w),Ho(I,S),_=Go(e,e.mainDocumentPart,S);let W=[..._.nums,..._.abstracts];Bo(W,w);for(let re of W)ht(re,Y=>{if(Y.kind!=="textValue"&&(Y.localName==="styleLink"||Y.localName==="numStyleLink")&&Y.namespaceUri===pa$1){let se=Ch(Y,"val");se&&w.add(se);}});if(w.size===R&&S.size===G)break}let q=Sl(e,e.mainDocumentPart),ee=I.map(R=>yt(R,q)),K=N.part&&Ze(N.part.root)?N.part.root:null,ae=pl(K,N.docDefaults,"fragment#doc-defaults"),B=ae?yt(ae,q):null;h=h.map(R=>yt(R,q));let V=A.map(R=>yt(R,q)),z=O.map(R=>yt(R,q)),ne=new Set;gn(h,ne);let ie=mg(e,r.name).filter(R=>ne.has(R.id)),Ne=new Map,Xe$1=0,Ce=R=>{let G=new Set;for(let W of R){if(W.targetMode==="External")continue;let re=E(W.ownerPart,W.rawTarget);if(!re.ok){G.add(W.id);continue}if((ng(e,re.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let se=e.partBytes.get(re.partName)??e.partBytes.get(re.partName.replace(/^\//,""));se?(Ne.set(re.partName,se),Xe$1+=se.byteLength):G.add(W.id);continue}G.add(W.id);}return G},Ve=Ce(ie),J=(R,G)=>{if(R.kind==="textValue")return R;if(R.kind==="drawing"||R.namespaceUri===pa$1&&(R.localName==="pict"||R.localName==="object")){let Y=new Set;gn([R],Y);for(let se of Y)if(G.has(se))return null;return R}let W=[],re=false;for(let Y of R.children){let se=J(Y,G);if(se===null){re=true;continue}se!==Y&&(re=true),W.push(se);}return re?st(R,W):R};Ve.size>0&&(h=h.map(R=>J(R,Ve)).filter(R=>R!==null));let Me=ie.filter(R=>!Ve.has(R.id)),ue=(R,G)=>{if(!R)return [];let W=new Set;gn(G,W);let re=mg(e,R.name).filter(se=>W.has(se.id)),Y=Ce(re);if(Y.size>0)for(let se=0;se<G.length;se+=1){let g=J(G[se],Y);g!==null&&(G[se]=g);}return re.filter(se=>!Y.has(se.id))},At=ue(y,V),dt=ue(P,z),Pe=new Map,tt=[],nn=new Map,Oe=(R,G,W)=>{let re=vl(R,G,W);Pe.set(R.slice(1),Ye(Ha$1(re))),tt.push([R,G]),nn.set(R,re);},b=(R,G)=>R.map(W=>{if(W.targetMode==="External")return {...W,ownerPart:G};let re=E(W.ownerPart,W.rawTarget);return {...W,ownerPart:G,rawTarget:re.ok?re.partName:W.rawTarget}}),U=b(Me,"/word/document.xml"),$=b(At,"/word/footnotes.xml"),j=b(dt,"/word/endnotes.xml"),X=new Set(U.map(R=>R.id)),Z=9001,de=(R,G)=>{let W=El(X,Z);Z+=1,X.add(W),U.push({ownerPart:"/word/document.xml",id:W,type:R,rawTarget:G,targetMode:"Internal",order:U.length});},we=wl(s,h);if(Oe("/word/document.xml",gl,we),ee.length>0||B){let R=st(K??xm(),[...B?[B]:[],...ee]);Oe("/word/styles.xml",hl,R),de(Lo,"styles.xml");}if(_.part&&(_.nums.length>0||_.abstracts.length>0)){let R=st(_.part.root,[..._.abstracts.map(G=>yt(G,q)),..._.nums]);Oe("/word/numbering.xml",yl,R),de($o,"numbering.xml");}y&&V.length>0&&(Oe("/word/footnotes.xml",xl,st(y.root,V)),de(Pl,"footnotes.xml"),$.length>0&&Pe.set("word/_rels/footnotes.xml.rels",Ye(hn($)))),P&&z.length>0&&(Oe("/word/endnotes.xml",kl,st(P.root,z)),de(Ol,"endnotes.xml"),j.length>0&&Pe.set("word/_rels/endnotes.xml.rels",Ye(hn(j))));let xe=new Map;for(let[R,G]of Ne){Pe.set(R.slice(1),G);let W=Tl(R);W&&!xe.has(W)&&xe.set(W,H(ng(e,R)??"application/octet-stream"));}let De={ownerPart:"/",id:"rId1",type:bl,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Pe.set("word/_rels/document.xml.rels",Ye(hn(U))),Pe.set("_rels/.rels",Ye(hn([De])));let Ye$1=[`<Default Extension="rels" ContentType="${Fo}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...xe].map(([R,G])=>`<Default Extension="${W(R)}" ContentType="${W(G)}"/>`)].join(""),Ae=tt.map(([R,G])=>`<Override PartName="${W(R)}" ContentType="${W(G)}"/>`).join("");Pe.set("[Content_Types].xml",Ye(`<Types xmlns="${hm}">${Ye$1}${Ae}</Types>`));let _e=new Map;_e.set("/",[De]),_e.set("/word/document.xml",U),$.length>0&&_e.set("/word/footnotes.xml",$),j.length>0&&_e.set("/word/endnotes.xml",j);let le=[];for(let R of _e.values())for(let G of R)G.targetMode==="External"&&le.push({ownerPart:G.ownerPart,id:G.id,type:G.type,rawTarget:G.rawTarget,sinkSafe:F(G.rawTarget).ok});let me=new Map;me.set("rels",Fo),me.set("xml","application/xml");for(let[R,G]of xe)me.set(R,G);let qe={defaults:me,overrides:new Map(tt)},mt=new Map;for(let[R,G]of Pe)mt.set(R.startsWith("/")?R:`/${R}`,G);return {ok:true,bytes:Xe(Pe),package:Object.freeze({parts:nn,partBytes:mt,relationships:_e,externalTargets:le,contentTypes:qe,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t.lastMarkCovered,blockCount:h.length,mediaBytes:Xe$1}}function pe(e){return e.kind!=="textValue"}function oe(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===pa$1}function Ke(e,t){for(let n of e)t(n),n.kind!=="textValue"&&Ke(n.children,t);}function xt(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===pa$1&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===ua$1&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(xt).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function kn(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(xt).join("")}`}function vr(e){let t=[],n=new Map,r=new Set,o=null;if(e&&pe(e.root))for(let a of e.root.children){if(!pe(a))continue;if(oe(a,"docDefaults")){o=a;continue}if(!oe(a,"style"))continue;t.push(a);let i=Ch(a,"styleId");i&&n.set(i,a);let s=a.children.find(c=>oe(c,"name")),l=s?Ch(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function Nr(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(i=>oe(i,t));if(!o||!pe(o))return r;let a=o.children.find(i=>oe(i,n));if(!a||!pe(a))return r;for(let i of a.children)i.kind!=="textValue"&&r.set(i.localName,i);return r}function Fl(e){let t=e.part?.root;return t&&pe(t)?t:null}function Ul(e){return Uo(Fl(e),e.docDefaults)}function Sr(e){return new Map(e.map(t=>[t.localName,vk(t,`fragment#application-${t.localName}`)]))}function wm(e,t){let n=new Set,r=t;for(let o=0;o<16&&r;o+=1){let a=e.byId.get(r);if(!a)break;let s=xn(a,"pPr")?.children.find(c=>oe(c,"spacing"));if(s&&pe(s))for(let c of s.attributes)n.add(c.localName);let l=a.children.find(c=>oe(c,"basedOn"));r=l?Ch(l,"val"):void 0;}return n}function Yo(e,t,n,r){let o=t;for(let a=0;a<16&&o;a+=1){let i=e.byId.get(o);if(!i)return false;let s=i.children.find(c=>oe(c,n));if(s&&pe(s)&&s.children.some(c=>c.kind!=="textValue"&&c.localName===r))return true;let l=i.children.find(c=>oe(c,"basedOn"));o=l?Ch(l,"val"):void 0;}return false}function Em(e,t){for(let n of e.styles){if(Ch(n,"type")!==t)continue;let r=Ch(n,"default");if(r==="1"||r==="true")return Ch(n,"styleId")}}function xn(e,t){let n=e.children.find(r=>oe(r,t));return n&&pe(n)?n:null}var Tm=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])),Cm=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 qo(e,t,n){let r=Fl(t)?Ul(t):null,o=Ul(n),a=r?.run?Sr(kr):Nr(t.docDefaults,"rPrDefault","rPr"),i=o.run?Sr(kr):Nr(n.docDefaults,"rPrDefault","rPr"),s=r?.paragraph?Sr(Pr):Nr(t.docDefaults,"pPrDefault","pPr"),l=o.paragraph?Sr(Pr):Nr(n.docDefaults,"pPrDefault","pPr"),c=(x,k,v)=>{let A=Em(x,"paragraph"),O=A?x.byId.get(A):void 0;if(!O)return A;for(let[D,F]of [["rPr",k],["pPr",v]]){let w=xn(O,D);if(w)for(let N of w.children)N.kind!=="textValue"&&F.set(N.localName,N);}return A};c(t,a,s),c(n,i,l);let d=new Map;for(let[x,k]of a){let v=i.get(x);(!v||xt(v)!==xt(k))&&d.set(x,k);}let m=new Map;for(let[x,k]of s){if(x==="sectPr")continue;let v=l.get(x);(!v||xt(v)!==xt(k))&&m.set(x,k);}if(d.size===0&&m.size===0)return e;let f=0,h=()=>`fragment#materialized-${f++}`,y=x=>{let k=v=>v.kind==="textValue"?{id:h(),kind:"textValue",value:v.value}:{...v,id:h(),children:v.children.map(k)};return k(x)},P=(x,k,v)=>{if(v.length===0)return x;let A=xn(x,k);if(A){let D=k==="rPr"?Cm:Tm,F=[...A.children];for(let N of v){let S=N.kind==="textValue"?Number.MAX_SAFE_INTEGER:D.get(N.localName)??Number.MAX_SAFE_INTEGER,I=F.length;for(let _=0;_<F.length;_+=1){let q=F[_];if(q.kind==="textValue")continue;let ee=D.get(q.localName);if(ee!==void 0&&ee>S){I=_;break}}F.splice(I,0,N);}let w={...A,children:F};return {...x,children:x.children.map(N=>N===A?w:N)}}let O={id:h(),kind:k==="rPr"?"runProperties":"paragraphProperties",namespaceUri:pa$1,localName:k,prefix:"w",namespaceBindings:[],attributes:[],children:v};return {...x,children:[O,...x.children]}},T=(x,k,v,A,O)=>{let D=wm(t,O),F=k.children.find(_=>oe(_,"spacing"));if(F&&pe(F))for(let _ of F.attributes)D.add(_.localName);let w=new Map(A&&pe(A)?A.attributes.map(_=>[_.localName,_.value]):[]),N=v.attributes.filter(_=>!D.has(_.localName)&&w.get(_.localName)!==_.value);if(N.length===0)return x;let S=F&&pe(F)?{...F,attributes:[...F.attributes,...N]}:{...v,id:h(),attributes:N,children:[]},I=F?{...k,children:k.children.map(_=>_===F?S:_)}:P(x,"pPr",[S]).children.find(_=>oe(_,"pPr"));return {...x,children:x.children.map(_=>_===k?I:_)}},M=x=>{let k=xn(x,"pPr"),v=k?.children.find(N=>oe(N,"pStyle")),A=v?Ch(v,"val"):void 0,O=[],D=x;for(let[N,S]of m){let I=k?.children.some(q=>q.kind!=="textValue"&&q.localName===N),_=!!A&&Yo(t,A,"pPr",N);N==="spacing"&&(I||_)&&k!==null&&pe(S)&&(D=T(D,k,S,l.get("spacing"),A)),!(I||_)&&O.push(y(S));}let F=N=>{if(N.kind==="textValue")return N;if(N.kind==="run"){let I=xn(N,"rPr"),_=I?.children.find(K=>oe(K,"rStyle")),q=_?Ch(_,"val"):void 0,ee=[];for(let[K,ae]of d)I?.children.some(V=>V.kind!=="textValue"&&V.localName===K)||q&&Yo(t,q,"rPr",K)||A&&Yo(t,A,"rPr",K)||ee.push(y(ae));return P(N,"rPr",ee)}if(N.kind==="paragraphProperties"||N.kind==="runProperties")return N;let S=N.children.map(F);return S.some((I,_)=>I!==N.children[_])?{...N,children:S}:N};return F(P(D,"pPr",O))},p=x=>{if(x.kind==="textValue")return x;if(x.kind==="paragraph")return M(x);let k=x.children.map(p);return k.some((v,A)=>v!==x.children[A])?{...x,children:k}:x};return e.map(p)}var Ll="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function Ie(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var Mm=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),Jo=uj,lt=new Map;function zt(e,t){let n=t.styleIds??lt,r=t.numIds??lt,o=t.relIds??lt,a=t.footnoteIds??lt,i=t.endnoteIds??lt,s=t.bookmarkIds??lt,l=t.sdtIds??lt,c=t.revisionIds??lt,d=t.docPrIds??lt,m=(f,h)=>{if(f.kind==="textValue")return f;let y=f;if(f.namespaceUri===pa$1&&Mm.has(f.localName)){let p=Ch(f,"val"),x=p!==void 0?n.get(p):void 0;x!==void 0&&(y=Ie(y,pa$1,"val",x));}if(oe(f,"numId")){let p=Ch(f,"val"),x=p!==void 0?r.get(p):void 0;x!==void 0&&(y=Ie(y,pa$1,"val",x));}if(f.kind==="noteReference"){let p=f.localName==="footnoteReference"?a:i,x=Ch(f,"id"),k=x!==void 0?p.get(He(x)):void 0;k!==void 0&&(y=Ie(y,pa$1,"id",k));}if(f.kind==="bookmarkStart"||f.kind==="bookmarkEnd"){let p=Ch(f,"id"),x=p!==void 0?s.get(p):void 0;x!==void 0&&(y=Ie(y,pa$1,"id",x));}if(oe(f,"id")&&h==="sdtPr"){let p=Ch(f,"val"),x=p!==void 0?l.get(p):void 0;x!==void 0&&(y=Ie(y,pa$1,"val",x));}if(Jo(f)){let p=Ch(f,"id"),x=p!==void 0?c.get(p):void 0;x!==void 0&&(y=Ie(y,pa$1,"id",x));}if(f.kind==="drawingDocPr"){let p=f.attributes.find(k=>k.localName==="id"&&k.namespaceUri==="")?.value,x=p!==void 0?d.get(p):void 0;x!==void 0&&(y=Ie(y,"","id",x));}for(let p of y.attributes){if(p.namespaceUri!==Ll)continue;let x=o.get(p.value);x!==void 0&&x!==p.value&&(y=Ie(y,Ll,p.localName,x));}let P=f.localName,T=y.children.map(p=>m(p,P));return y!==f||T.some((p,x)=>p!==y.children[x])?{...y,children:T}:f};return m(e,"")}function $l(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 Bl(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 Dm=1e5;function Hl(e){let t=Sb(),n=Am(e,t),r=_m(e,t),o=Um(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function Qo(e,t,n,r){if(e)return Vb(t,e,r);let o=n;return ()=>{for(;t.has(String(o));)o+=1;return o>r?null:String(o++)}}function Vl(e,t){if(e.add(t),!/^\d{1,10}$/.test(t))return;let n=Number(t);n<=Pb&&e.add(String(n));}function jl(e,t){if(t===void 0)return e;let n=Number(t);return Number.isInteger(n)&&n>e?n:e}function Am(e,t){let n=new Map;if(e.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let i of [e.ownerPart,...e.notesParts])Ke([i.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=Ch(s,"id");l!==void 0&&(Vl(o,l),s.kind==="bookmarkStart"&&(r=jl(r,l)));});let a=Qo(t,o,r+1,Pb);for(let i of e.fragmentBookmarkIds){if(n.has(i))continue;let s=a();if(s===null)return null;n.set(i,s);}return n}function _m(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;Ke([s.root],c=>{if(!uj(c))return;let d=Ch(c,"id");d!==void 0&&Vl(o,d),l&&(r=jl(r,d));});}let a=Qo(t,o,r+1,Pb),i=false;return Ke(e.travelling,s=>{if(i||!uj(s))return;let l=Ch(s,"id");if(l===void 0||n.has(l))return;let c=a();c===null?i=true:n.set(l,c);}),i?null:n}function Um(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=Uf(e.pkg),o=Dm;if(!t){let s=Vf(e.pkg);s.ok&&(o=s.id);}let a=Qo(t,r,o,Tf),i=false;return Ke(e.travelling,s=>{if(i||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(d=>d.localName==="id"&&d.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let c=a();c===null?i=true:n.set(l,c);}),i?null:n}function Gl(e,t){return `${t?kn(t):"none"}::${e.children.filter(n=>oe(n,"lvlOverride")).map(xt).join("")}`}function zl(e){let t=e.children.find(n=>oe(n,"abstractNumId"));return t?Ch(t,"val"):void 0}function Wl(e,t,n){let r=new Set(["0"]),o=0;for(let s of e?.root.children??[]){if(!pe(s)||!oe(s,t))continue;let l=Ch(s,n);if(l===void 0)continue;let c=Number(l);Number.isInteger(c)&&(r.add(String(c)),c>o&&(o=c));}let a=Sb();if(a)return Vb(r,a,Qb$1);let i=o+1;return ()=>String(i++)}function Kl(e,t){let n={numIdMap:new Map,numsToImport:[],abstractsToImport:[]};if(!e||!pe(e.root))return n;let r=new Map,o=[];for(let c of e.root.children)if(pe(c))if(oe(c,"abstractNum")){let d=Ch(c,"abstractNumId");d&&r.set(d,c);}else oe(c,"num")&&o.push(c);let a=new Map;if(t&&pe(t.root)){let c=new Map;for(let d of t.root.children){if(!pe(d)||!oe(d,"abstractNum"))continue;let m=Ch(d,"abstractNumId");m&&c.set(m,d);}for(let d of t.root.children){if(!pe(d)||!oe(d,"num"))continue;let m=Ch(d,"numId");if(!m)continue;let f=zl(d),h=f?c.get(f):void 0;a.set(Gl(d,h),m);}}let i=Wl(t,"abstractNum","abstractNumId"),s=Wl(t,"num","numId"),l=new Map;for(let c of o){let d=Ch(c,"numId");if(!d)continue;let m=zl(c),f=m?r.get(m):void 0,h=Gl(c,f),y=a.get(h);if(y!==void 0){n.numIdMap.set(d,y);continue}let P=m?l.get(m):void 0;if(P===void 0&&f&&m){let p=i();if(p===null)return null;P=p,l.set(m,P),n.abstractsToImport.push(Ie(f,pa$1,"abstractNumId",P));}let T=s();if(T===null)return null;n.numIdMap.set(d,T);let M=Ie(c,pa$1,"numId",T);if(P!==void 0){let p=M.children.map(x=>oe(x,"abstractNumId")?Ie(x,pa$1,"val",P):x);M={...M,children:p};}n.numsToImport.push(M),a.set(h,T);}return n}var Wt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Fm=`${Wt}/hyperlink`,Xl=`${Wt}/image`,wr=`${Wt}/numbering`,Zo=`${Wt}/styles`,Yl="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",ql="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Pn(e,t,n,r){for(let o of mg(e,t)){if(o.type!==n||o.targetMode==="External")continue;let a=E(o.ownerPart,o.rawTarget);if(a.ok){let i=e.parts.get(a.partName);if(i)return i}}return e.parts.get(r)??null}function Lm(e,t){let n=0;return Ke([e],r=>{let o=t(r);if(o===void 0)return;let a=Number(o);Number.isInteger(a)&&a>n&&(n=a);}),n}function Er(e,t,n,r){if(n.length===0)return e;let o=ab(t,"paste"),a=n.map(c=>Ih(c,o)),i=Cm$1(t,a),s=r??i.root.children.length,l=hb(i,i.root.id,s,a,{deferValidation:true});return l.ok?kg$1(e,l.part):null}function Jl(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||oe(o,"pict")||oe(o,"object")){let i=false;return Ke([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===Wt&&t.has(l.value)&&(i=true);}),i?null:o}if(o.kind==="hyperlink"){let i=o.attributes.find(s=>s.namespaceUri===Wt)?.value;if(i!==void 0&&t.has(i))return r(o.children)}let a=r(o.children);return a.length===o.children.length&&a.every((i,s)=>i===o.children[s])?o:{...o,children:a}};function r(o){let a=[];for(let i of o){let s=n(i);s!==null&&(Array.isArray(s)?a.push(...s):a.push(s));}return a}return r(e)}var $m=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),Ql={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function Bm(e,t){let n=Jf(e);if(n==="unknown")return null;let r=H(t);return (Object.hasOwn(Ql,r)?Ql[r]:r)!==n||$m.has(n)&&!Wf(e,n)?null:n}function ea(e,t,n){for(let b of t.parts.values())if(fn([b.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(b=>b.kind==="body"):null;if(!o||!pe(o))return {ok:false,reason:"no-fragment-document"};let a=Vm$1(o.children.filter(b=>b.kind==="paragraph"||b.kind==="table"||b.kind==="contentControl"));if(a.length===0)return {ok:false,reason:"no-fragment-document"};let i=e,s=Kl(Pn(t,t.mainDocumentPart,wr,"/word/numbering.xml"),Pn(i,i.mainDocumentPart,wr,"/word/numbering.xml"));if(!s)return {ok:false,reason:"merge-refused"};let{numIdMap:l,numsToImport:c,abstractsToImport:d}=s,m=vr(Pn(t,t.mainDocumentPart,Zo,"/word/styles.xml")),f$1=Pn(i,i.mainDocumentPart,Zo,"/word/styles.xml"),h=vr(f$1),y=new Map,P=[],T=new Set(h.byId.keys()),M=new Set(h.names),p=new Map,x=new Map,k=new Map,v=(b,U)=>{let $=k.get(b);return $===void 0&&($=kn(U),k.set(b,$)),$},A=b=>({...b,attributes:b.attributes.filter(U=>!(U.localName==="default"&&U.namespaceUri===pa$1))});for(let b of m.styles){let U=Ch(b,"styleId");if(!U)continue;let $=h.byId.get(U),j=kn(zt(b,{styleIds:y,numIds:l}));if($&&v(U,$)===j){y.set(U,U);continue}if(!$){y.set(U,U),T.add(U),P.push(A(b));continue}let X=$l(`${U}Pasted`,T,p);T.add(X),y.set(U,X),P.push(A(Ie(b,pa$1,"styleId",X)));}let O=P.map(b=>{let U=b.children.find(Z=>oe(Z,"name")),$=U?Ch(U,"val"):void 0;if(!$||!M.has($))return $&&M.add($),b;let j=Bl($,M,x);M.add(j);let X=b.children.map(Z=>oe(Z,"name")?Ie(Z,pa$1,"val",j):Z);return {...b,children:X}}),D=null,F=1,w=Sb()===void 0?null:Wb(Number.MAX_SAFE_INTEGER),N=()=>{if(D)return D;let b=new Map;for(let[U,$]of i.partBytes){let j=U.startsWith("/")?U:`/${U}`;if(!j.startsWith("/word/media/"))continue;b.set(f($),j);let X=/\/image(\d+)\./.exec(j);X&&(F=Math.max(F,Number(X[1])+1));}return D=b,b},S=new Map,I=b=>{let U=S.get(b);if(!U){U=new Map;for(let $ of mg(i,b)){if($.targetMode==="External"||$.type!==Xl)continue;let j=E($.ownerPart,$.rawTarget);j.ok&&U.set(j.partName,$.id);}S.set(b,U);}return U},_=(b,U)=>{let $=b.lastIndexOf("."),j=$===-1?"":b.slice($+1);return /^[A-Za-z0-9]{1,8}$/.test(j)?j.toLowerCase():U==="image/jpeg"?"jpeg":U==="image/gif"?"gif":"png"},q=(b,U,$)=>{let j=new Map,X=new Set,Z=I(U),de=[],we=new Set,xe=[],De=[],Ye=new Map,Ae=[],_e=t.relationships.get(b)??[];for(let le of _e){if(!$.has(le.id))continue;if(le.targetMode==="External"){if(le.type===Fm){let E=Xi(i,le.rawTarget,U);E?(i=E.pkg,j.set(le.id,E.relationshipId)):X.add(le.id);}else X.add(le.id);continue}let me=E(le.ownerPart,le.rawTarget);if(!me.ok){X.add(le.id);continue}let qe=t.partBytes.get(me.partName)??t.partBytes.get(me.partName.replace(/^\//,"")),mt=(ng(t,me.partName)??"").toLowerCase();if(!qe||!mt.startsWith("image/")){X.add(le.id);continue}let R=Bm(qe,mt);if(R===null){X.add(le.id);continue}let G=R,W=N(),re=f(qe),Y=W.get(re);if(!Y){let E=_(me.partName,G),L=fe=>i.partBytes.has(fe)||i.partBytes.has(fe.slice(1))||i.parts.has(fe)||we.has(fe),Q;if(w)do Q=`/word/media/image${w.next().value}.${E}`;while(L(Q));else {for(Q=`/word/media/image${F}.${E}`;L(Q);)F+=1,Q=`/word/media/image${F}.${E}`;F+=1;}Y=Q,de.push({partName:Y,bytes:qe,contentType:G}),we.add(Y),W.set(re,Y);}let se=Y.startsWith("/word/")?Y.slice(6):Y,g=Z.get(Y);if(g!==void 0){j.set(le.id,g);continue}let u=Ye.get(Y);u===void 0&&(u=xe.length,Ye.set(Y,u),xe.push(se),De.push(Y)),Ae.push({recordId:le.id,index:u});}if(de.length>0&&(i=_f(i,de)),xe.length>0){let le=qg(sg(i,U),U,xe.map(me=>[Xl,me]));if(le.ok){i=le.pkg,le.ids.forEach((me,qe)=>{Z.set(De[qe],me);});for(let me of Ae)j.set(me.recordId,le.ids[me.index]);}else for(let me of Ae)X.add(me.recordId);}return {relIdMap:j,dropRelIds:X}},ee=q(t.mainDocumentPart,n,Vo(a));a=Jl(a,ee.dropRelIds);let K=new Map,ae=new Map,B=[],V=(b,U)=>pe(b)&&b.namespaceUri===pa$1&&b.localName===U,z={},ne=br(a,(b,U)=>{let $=z[b];if($===void 0){$=new Map,z[b]=$;let j=gj(t,b);if(j&&pe(j.root))for(let X of j.root.children){if(!V(X,b))continue;let Z=Ch(X,"id");if(Z===void 0)continue;let de=He(Z);$.has(de)||$.set(de,X);}}return $.get(U)??null});for(let b of ["footnote","endnote"]){let U=b==="footnote"?K:ae,$=ne[b];if($.size===0)continue;let j=gj(t,b);if(!j||!pe(j.root))continue;let X=Cj(i,b);if(!X.ok||!X.package)return {ok:false,reason:"merge-refused"};i=X.package;let Z=gj(i,b);if(!Z)return {ok:false,reason:"merge-refused"};let de=Lm(Z.root,xe=>V(xe,b)?Ch(xe,"id"):void 0)+1,we=[];for(let xe of j.root.children){if(!V(xe,b))continue;let De=Ch(xe,"id"),Ye=Ch(xe,"type");if(Ye==="separator"||Ye==="continuationSeparator"||De===void 0||!$.has(He(De))||U.has(He(De)))continue;let Ae=String(de++);U.set(He(De),Ae),we.push(Ie(xe,pa$1,"id",Ae));}we.length>0&&B.push({kind:b,fragmentPartName:j.name,bodies:Vm$1(we)});}let ie=i.parts.get(n),Ne=[...a,...B.flatMap(b=>b.bodies)],Xe=[],Ce=new Set,Ve=false,J=false,Me=new Map;Ke(Ne,b=>{if(b.kind!=="textValue"){if(b.kind==="bookmarkStart"||b.kind==="bookmarkEnd"){let U=Ch(b,"id");if(U!==void 0&&Xe.push(U),b.kind==="bookmarkStart"){let $=Ch(b,"name");$&&Ce.add($);}return}if(Jo(b)){Ve=true;return}if(b.kind==="drawingDocPr"){J=true;return}if(b.kind==="contentControlProperties")for(let U of b.children){if(!oe(U,"id"))continue;let $=Ch(U,"val");if($!==void 0&&!Me.has($)){let j=0,X=`${$}:${Me.size}`;for(let Z=0;Z<X.length;Z+=1)j=j*31+X.charCodeAt(Z)>>>0;Me.set($,String(j%2147483647||1));}}}});let ue=Hl({pkg:i,ownerPart:ie,notesParts:B.map(b=>gj(i,b.kind)).filter(b=>b!==null),travelling:Ne,fragmentBookmarkIds:Xe,hasRevision:Ve,hasDocPr:J});if(!ue)return {ok:false,reason:"merge-refused"};let At=ue.bookmarkIds,dt=ue.revisionIds,Pe=ue.docPrIds;if(Ce.size>0){let b=new Set;if(Ke([ie.root],U=>{if(U.kind!=="textValue"&&U.kind==="bookmarkStart"){let $=Ch(U,"name"),j=Ch(U,"id");$&&j!==void 0&&Ce.has($)&&b.add(j);}}),b.size>0){let U=j=>{if(j.kind==="textValue")return j;let X=[],Z=false;for(let de of j.children){if((de.kind==="bookmarkStart"||de.kind==="bookmarkEnd")&&b.has(Ch(de,"id")??"")){Z=true;continue}let we=U(de);we!==de&&(Z=true),X.push(we);}return Z?{...j,children:X}:j},$=U(ie.root);$!==ie.root&&(eb(ie.root,$),i=kg$1(i,{...ie,root:$}));}}let tt=b=>jo(b,K,ae);for(let b of B){b.bodies=b.bodies.map(tt);let U=gj(i,b.kind);if(!U)return {ok:false,reason:"merge-refused"};let $=q(b.fragmentPartName,U.name,Vo(b.bodies)),j=Jl(b.bodies,$.dropRelIds);j=[...qo(j,m,h)],j=j.map(Z=>zt(Z,{styleIds:y,numIds:l,relIds:$.relIdMap,footnoteIds:K,endnoteIds:ae,bookmarkIds:At,sdtIds:Me,revisionIds:dt,docPrIds:Pe}));let X=Er(i,i.parts.get(U.name),j);if(!X)return {ok:false,reason:"merge-refused"};i=X;}if(O.length>0){let b=O.map($=>zt($,{styleIds:y,numIds:l}));if(!f$1){let $=Pa$1(`<w:styles xmlns:w="${pa$1}"></w:styles>`,{name:"/word/styles.xml",contentType:ql});if(!$.ok)return {ok:false,reason:"merge-refused"};i=ug(i,"/word/styles.xml",$.part.root,ql);let j=tg(sg(i,i.mainDocumentPart),i.mainDocumentPart,Zo,"styles.xml");if(!j.ok)return {ok:false,reason:"merge-refused"};i=j.pkg,f$1=i.parts.get("/word/styles.xml")??null;}if(!f$1)return {ok:false,reason:"merge-refused"};let U=Er(i,i.parts.get(f$1.name),b);if(!U)return {ok:false,reason:"merge-refused"};i=U,h=vr(i.parts.get(f$1.name)??null);}if(d.length>0||c.length>0){let b=Pn(i,i.mainDocumentPart,wr,"/word/numbering.xml");if(!b){let Z=Pa$1(`<w:numbering xmlns:w="${pa$1}"></w:numbering>`,{name:"/word/numbering.xml",contentType:Yl});if(!Z.ok)return {ok:false,reason:"merge-refused"};i=ug(i,"/word/numbering.xml",Z.part.root,Yl);let de=tg(sg(i,i.mainDocumentPart),i.mainDocumentPart,wr,"numbering.xml");if(!de.ok)return {ok:false,reason:"merge-refused"};i=de.pkg,b=i.parts.get("/word/numbering.xml")??null;}if(!b)return {ok:false,reason:"merge-refused"};let U=i.parts.get(b.name),$=U.root.children.findIndex(Z=>oe(Z,"num")),j=d.map(Z=>zt(Z,{styleIds:y,numIds:l})),X=Er(i,U,j,$===-1?void 0:$);if(!X)return {ok:false,reason:"merge-refused"};if(i=X,X=Er(i,i.parts.get(b.name),c),!X)return {ok:false,reason:"merge-refused"};i=X;}let Oe=[...qo(a,m,h)].map(tt).map(b=>zt(b,{styleIds:y,numIds:l,relIds:ee.relIdMap,footnoteIds:K,endnoteIds:ae,bookmarkIds:At,sdtIds:Me,revisionIds:dt,docPrIds:Pe}));return {ok:true,pkg:i,blocks:Oe}}var Kt=class extends Error{},On=e=>e.kind==="textValue"?"":e.localName??"",he=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===pa$1&&On(e)===t,Hm=new Set(["bookmarkStart","bookmarkEnd","commentRangeStart","commentRangeEnd","permStart","permEnd","proofErr"]),Zl=new Set(["moveFrom","moveTo","moveFromRangeStart","moveFromRangeEnd","moveToRangeStart","moveToRangeEnd"]),Tr=e=>e.kind!=="textValue"&&e.namespaceUri===pa$1&&Hm.has(On(e));function Vm(e){let t=-1,n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===pa$1&&tj.has(r.localName))for(let o of r.attributes)o.namespaceUri!==pa$1||o.localName!=="id"||/^\d{1,9}$/.test(o.value)&&(t=Math.max(t,Number(o.value)));for(let o of r.children)n(o);}};for(let r of e.parts.values())n(r.root);return t}function ec(e,t){let n=e.parts.get(e.mainDocumentPart);if(!n||n.root.kind!=="document")return null;let r=ab(n),o=Vm(e)+1,a=p=>mi(r(),"revisionInsert","ins",ni(String(o++),t),p),i=()=>mi(r(),"generic","ins",ni(String(o++),t),[]),s=p=>{let x=[],k=[],v=()=>{if(k.some(O=>!Tr(O)))x.push(a(k));else for(let O of k)x.push(O);k=[];},A=O=>{if(O.kind==="textValue"){k.push(O);return}if(Zl.has(On(O))&&O.namespaceUri===pa$1)throw new Kt;if(O.kind==="revisionInsert"){for(let D of O.children)A(D);return}if(O.kind==="revisionDelete"){k.push(O);return}if(Yg(O)){for(let D of uk(O,r))A(D);return}if(Ca$1(O)){v();let D=O.children.filter(w=>qf(O,w)),F=O.children.filter(w=>!qf(O,w));x.push({...O,children:[...D,...s(F)]});return}k.push(O);};for(let O of p)A(O);return v(),x},l=p=>{let x=p&&p.kind!=="textValue"?p.children:[],k=x.find(I=>he(I,"rPr")),v=k&&k.kind!=="textValue"?k.children:[];if(v.some(I=>Zl.has(On(I))))throw new Kt;let A=v.filter(I=>!he(I,"ins")),O=A.filter(I=>he(I,"del")),D=A.filter(I=>!he(I,"del")),F=mi(k?.id??r(),"runProperties","rPr",k&&k.kind!=="textValue"?k.attributes:[],[i(),...O,...D]),w=x.filter(I=>!he(I,"rPr")),N=w.filter(I=>he(I,"sectPr")||he(I,"pPrChange")),S=w.filter(I=>!N.includes(I));return mi(p?.id??r(),"paragraphProperties","pPr",p&&p.kind!=="textValue"?p.attributes:[],[...S,F,...N])},c=p=>{let x=p.children.find(v=>v.kind==="paragraphProperties"),k=p.children.filter(v=>v.kind!=="paragraphProperties");return {...p,children:[l(x),...s(k)]}},d=p=>{let k=(p&&p.kind!=="textValue"?p.children:[]).filter(O=>!he(O,"ins")),v=k.filter(O=>he(O,"del")||he(O,"trPrChange")),A=k.filter(O=>!v.includes(O));return mi(p?.id??r(),p&&p.kind!=="textValue"?p.kind:"generic","trPr",p&&p.kind!=="textValue"?p.attributes:[],[...A,i(),...v])},m=p=>{let x=p.children.find(O=>he(O,"trPr")),k=p.children.filter(O=>!he(O,"trPr")),v=k.filter(O=>he(O,"tblPrEx")),A=k.filter(O=>!he(O,"tblPrEx")).map(O=>O.kind==="tableCell"?{...O,children:O.children.map(y)}:O.kind==="textValue"||Tr(O)?O:f(O));return {...p,children:[...v,d(x),...A]}};function f(p){throw new Kt(On(p))}function h(p){return p.kind==="textValue"||Tr(p)?p:p.kind==="tableRow"?m(p):p.kind==="tableProperties"||p.kind==="tableGrid"?p:p.kind==="contentControl"||p.kind==="contentControlContent"?{...p,children:p.children.map(x=>qf(p,x)?x:h(x))}:he(p,"tblPr")||he(p,"tblGrid")?p:f(p)}function y(p){if(p.kind==="textValue"||Tr(p))return p;switch(p.kind){case "paragraph":return c(p);case "table":return {...p,children:p.children.map(h)};case "tableProperties":case "tableGrid":return p;case "contentControl":case "contentControlContent":return {...p,children:p.children.map(x=>qf(p,x)?x:y(x))};default:return he(p,"tcPr")||he(p,"sectPr")||he(p,"sdtPr")||he(p,"sdtEndPr")?p:f(p)}}let T=n.root.children.find(p=>p.kind==="body");if(!T||T.kind!=="body")return null;let M=new Map(e.parts);try{let p=gb(n,T.id,T.children.map(y));if(!p.ok)return null;M.set(e.mainDocumentPart,p.part);for(let[x,k]of e.parts){if(!jm.test(x))continue;r=ab(k);let v=k;for(let A of k.root.children){if(!he(A,"footnote")&&!he(A,"endnote")||A.kind==="textValue")continue;let O=A.attributes.find(F=>F.localName==="type")?.value;if(O!==void 0&&O!=="normal")continue;let D=gb(v,A.id,A.children.map(y));if(!D.ok)return null;v=D.part;}M.set(x,v);}}catch(p){if(p instanceof Kt)return null;throw p}return {...e,parts:M}}var jm=/\/(?:footnotes|endnotes)\.xml$/;var tc=16*1024*1024;function Gm(e){let t=e.parts.get(e.mainDocumentPart);if(!t||t.root.kind!=="document")return false;let n=t.root.children.find(a=>a.kind==="body");if(!n||n.kind!=="body"||n.children.length>zm$1)return false;let r=0,o=(a,i,s)=>{if(i>s||(r+=1,r>Bm$1))return false;if(a.kind==="textValue")return true;for(let l of a.children)if(!o(l,i+1,s))return false;return true};for(let a of n.children)if(!o(a,1,Am$1))return false;for(let[a,i]of e.parts)if(a!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(a)&&!o(i.root,1,Am$1*4))return false;return true}function ta(e,t,n){if(n.fragmentBytes.byteLength>tc)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=gg(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=n.revision?ec(r.package,n.revision):r.package;if(!o)return {ok:false,reason:"invalidArgs",detail:"fragment-untrackable"};let a=o;if(!Gm(a))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:s,story:l}=i;if(s.compositionActive||e.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let c=e.currentPackage(),d=s.checkpoint();s.graftPackage(()=>e.currentPackage());let m=0,f="";return Va$1(e,()=>{let h=s.transact(P=>{for(let x of n.priorOps??[])if(!P.apply(x))return;let T=null,M=P.applyPackage(x=>(T=ea(x,a,l.partName),T.ok?T.pkg:x)),p=T;if(!p||!p.ok){f=`fragment-merge:${p?p.reason:"no-merge"}`,P.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}M&&(m=p.blocks.length,P.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:p.blocks,lastMarkCovered:n.lastMarkCovered})&&n.revision&&p.blocks[0]?.kind!=="paragraph"&&P.apply({op:"setParagraphMarkRevision",paragraphId:n.paragraphId,kind:"ins",revision:n.revision}));},{story:l,...n.actorId?{actorId:n.actorId}:{}});return f.length>0?{ok:false,reason:"invalidArgs",detail:f}:h.ok?h.change?{ok:true,change:e.promoteStoryTransactionToPackageUnit(c,s,d),blockCount:m}:{ok:true,change:null,blockCount:m}:{ok:false,reason:h.reason,...h.detail?{detail:h.detail}:{}}},h=>Wa(h))}function nc(){let e=null;return (t,n,r)=>{let o=e;if(e=null,!Pk(n)||!("paragraphId"in r)||!Rk(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 a=cb(t,r.paragraphId);if(a?.kind!=="paragraph")return r;let i=lm$1(t,km$1(r));if(i.unprotected.length)return r;let s=ui(a);for(let l of i.touches){let c=s.spanOf(l.control);c&&c.start<=r.start&&c.end>=r.end&&(e={partName:t.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}function na(e,t){for(let[n,r]of t.parts){let o=e.parts.get(n);!o||o.root===r.root||o.root.id!==r.root.id||fb(o.root,r.root);}return t}var rc=new WeakSet;function zm(e){return rc.add(e),e}function oc(e){return rc.has(e)}function bn(e){return {...e,applyPackage:t=>e.applyPackage(zm(t))}}var ac=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertComplexField","insertEquation","insertDrawing","deleteText","setParagraphMarkRevision"]),ra=new Set(["insertDrawing"]),Wm=new Set(["insertContentControl","insertInlineContentControl","setContentControlProperties","removeContentControl","splitParagraph"]);function ic(e){return Wm.has(e.op)&&!("revision"in e&&e.revision)}function Km(e){if(!(e===null||e.start!==e.end))return e}var Xt={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function Xm(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 Rn=new WeakMap;function Cr(e){return Rn.get(e)?.()??e.part}var Tt=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];pushCount=0;subscribers=new Set;historyLimit;settingsPartOverride;contentLockPolicy;storyRef=null;composition=null;constructor(t,n,r={}){let o="root"in t,a=typeof n=="string"?n:void 0,i=typeof n=="object"&&n!==null?n:r;this.current=o?Xm(t):t,this.storyPartName=a??(o?t.name:t.mainDocumentPart),this.historyLimit=i.historyLimit??200,this.settingsPartOverride=i.settingsPart,this.contentLockPolicy=Kk(i.contentLockPolicy);}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 historyPushCount(){return this.pushCount}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=kg$1(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 Rb(n.actorId,()=>Ng(n.fieldResults,()=>this.commitTransaction(t,n)))}commitTransaction(t,n){let r=n.origin??g.mutationHuman,o=n.recordsHistory??(r!==g.projection&&r!==g.awareness),a=this.undoStack[this.undoStack.length-1];o&&!this.composition&&a?.group!==n.historyGroup&&this.closeHistoryGroup();let i=this.current,s=this.rev,l=this.current,c=null,d=0,m=new Set,f=new Set,h=new Set,y=new Set,P=new Set,T=[],M=n.minimumImpact??"text-local",p=null,x=false,k=null,v=null,A=new Map,O=new Map,D=B=>{let V=O.get(B.name);V||(V={mint:null,written:new Set},O.set(B.name,V));let z=V;return {mint:()=>(z.mint??=sj(B))(),wrote:ne=>{z.written.add(ne);},wroteUnder:ne=>z.written.has(ne)}},F=()=>{for(let B of O.values())B.mint=null;},w=(B,V)=>{let z=Zk.get(B.op);if(z===void 0)return A.clear(),null;let ne=`${V.name}\0${z}`,ie=A.get(ne);ie||(ie={id:null},A.set(ne,ie));let Ne=ie;return ()=>Ne.id??=D(V).mint()},N=(B,V)=>{let z=ac.has(B.op);return !z&&Zk.get(B.op)!==void 0?null:((z?ra.has(B.op):!ic(B))&&F(),z?D(V):null)},S=nc(),I=null,_=(B,V)=>{if(c)return false;let z=l.parts.get(B);if(!z)return c={reason:"unknown-part",detail:B},false;V=S(z,this.settingsPartOverride?.()??wf(l),V);let ne=Ok(this.settingsPartOverride?.()??wf(l),V)??mm$1(z,this.settingsPartOverride?.()??wf(l),V,I?.partName===B&&"paragraphId"in V&&I.paragraphId===V.paragraphId?I.fieldNodeId:void 0);if(ne)return c={reason:ne},false;let ie=w(V,z),Ne=N(V,z),Xe=this.settingsPartOverride?.()??wf(l),Ce=Pk(Xe)&&"paragraphId"in V&&Rk(z,V.paragraphId)?Tk(z,V,I?.partName===B&&I.paragraphId===V.paragraphId?I.fieldNodeId:void 0):null;I=Ce&&"paragraphId"in V?{partName:B,paragraphId:V.paragraphId,fieldNodeId:Ce.fieldNodeId}:null;let Ve={deferValidation:true,...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{},...ie?{revisionIds:ie}:{},...Ne?{trackedRevisionIds:Ne}:{}},J=Ce?wn$1(z,V,Ce,Ve):Bn(z,V,Ve);if(!J.ok)return c={reason:J.reason,...J.detail?{detail:J.detail}:{}},false;if(ra.has(V.op)&&F(),l=kg$1(l,J.part),J.part===z&&J.effect.dirty.length===0&&J.effect.created.length===0&&J.effect.deleted.length===0&&J.effect.split===void 0&&(J.effect.splits===void 0||J.effect.splits.length===0)&&J.effect.join===void 0&&J.effect.caret===void 0)return true;m.add(B),d+=1;for(let ue of J.effect.dirty)f.add(ue);for(let ue of J.effect.created)h.add(ue);for(let ue of J.effect.deleted)y.add(ue);for(let ue of J.effect.dependencyKeys)P.add(ue);J.effect.split&&T.push({split:J.effect.split});for(let ue of J.effect.splits??[])T.push({split:ue});if(J.effect.join&&T.push({join:J.effect.join}),Xt[J.effect.impact]>Xt[M]&&(M=J.effect.impact),J.effect.caret){let ue=J.effect.caret.offset??0;v={paragraphId:J.effect.caret.paragraphId,start:ue,end:ue};}return true},q=Rn.get(this);Rn.set(this,()=>l.parts.get(this.storyPartName)??this.part);try{t({apply:B=>_(this.storyPartName,B),applyTo:(B,V)=>_(B,V),applyPackage:B=>{if(c)return !1;let V=this.settingsPartOverride?.()??wf(l),z=oc(B)?Nk(V,{op:"comment"}):Ok(V);if(z)return c={reason:z},!1;A.clear(),F();let ne;try{ne=B(l);}catch(ie){if(!Fk(ie))throw ie;return c={reason:ie.reason,detail:ie.message},!1}if(ne===l)return !0;for(let[ie,Ne]of ne.parts)l.parts.get(ie)!==Ne&&m.add(ie);return l=ne,d+=1,Xt["flow-structural"]>Xt[M]&&(M="flow-structural"),!0},selectionBefore:B=>{p=B;},selectionAfter:B=>{x=!0,k=B;}});}finally{q?Rn.set(this,q):Rn.delete(this);}if(c){let B=c;return {ok:false,reason:B.reason,...B.detail?{detail:B.detail}:{}}}if(d===0)return {ok:true,change:null};let ee=x?k:v,K=x?Km(k):v??void 0;for(let B of m){let V=i.parts.get(B),z=l.parts.get(B);if(z===void 0)continue;let ne=V?Na$1(V,z):Na$1(z,z);if(!ne.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(ne.issues)}}let ae=vg(l);if(!ae.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(ae.issues)};if(o)if(this.composition)En$1(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:ee}};else {let B=n.historyGroup,V=this.undoStack[this.undoStack.length-1];B!==void 0&&V!==void 0&&V.group===B?this.undoStack[this.undoStack.length-1]={...V,selectionAfter:ee??V.selectionAfter}:this.pushUndo({pkg:i,revision:s,selectionBefore:p,selectionAfter:ee,group:B}),En$1(B,V?.group===B?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Xt[n.minimumImpact]>Xt[M]&&(M=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:f,created:h,deleted:y,dependencyKeys:P,splitJoin:T,impact:M,caret:K},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=na(this.current,t.pkg),this.rev+=1,this.publish(g.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=na(this.current,t.pkg),this.rev+=1,this.publish(g.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}discardNewestUndoEntry(){let t=this.undoStack.pop();return t?{selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}:null}pushUndo(t){this.pushCount+=1,this.undoStack.push(t),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(t,n,r,o,a,i){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:t,...a?{actorId:a}:{},...i?{operationId:i}:{},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}:{}};return Ng("atomic",()=>{for(let l of this.subscribers)l(s);}),s}};function oa(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 sc(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 aa(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function lc(e,t){return aa(e,t).map(n=>n.name).sort().join(",")}function cc(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 dc="/word/numbering.xml";function Yt(e,t){return e===void 0?void 0:{group:e,before:t}}function ia(e){return e.kind==="package"&&e.before.parts.get(dc)!==e.after.parts.get(dc)?{...e,restoreNumbering:true}:e}var Mr=class{open=null;close(){this.open=null;}admit(t,n,r,o,a){let i=this.open;if(n===void 0)return this.open=null,ia(t);if(i===null||i.group!==n.group||r.at(-1)!==i.pointer){let f=ia(t);return this.open={group:n.group,before:n.before,pointer:f},En$1(n.group,"started"),f}r.pop();let s=t.kind==="story"?o(t.partName):null,l=i.pointer.kind==="story"?o(i.pointer.partName):null,c=i.pointer.kind==="package"?i.pointer.selectionAfter??null:null,d={kind:"package",before:i.before,after:a(),selectionBefore:i.pointer.kind==="package"?i.pointer.selectionBefore??null:l?.selectionBefore??null,selectionAfter:(t.kind==="package"?t.selectionAfter:s?.selectionAfter)??c},m=ia(d);return this.open={...i,pointer:m},En$1(n.group,"extended"),m}};var Ar="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Ym="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function qt(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===Ar&&n.localName===t)return n;return null}function Dr(e,t){return e.attributes.find(n=>n.namespaceUri===Ar&&n.localName===t)?.value}function qm(e){let t=Dr(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function pc(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>pc(n,t))})}function Jm(e){let t=Pa$1(`<w:styles xmlns:w="${Ar}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:Ym});if(!t.ok)return null;let n=qt(t.part.root,"style"),r=n?qt(n,"pPr"):null;return r?pc(r,ab(e)):null}var mc=["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 Qm(e,t){let n=mc.indexOf(t),r=0;return e.forEach((o,a)=>{if(o.kind==="textValue")return;let i=mc.indexOf(o.localName);i!==-1&&i<=n&&(r=a+1);}),r}function uc(e,t){let n=ld$1(e);if(!n)return null;let r=null;for(let c of n.root.children)if(c.kind!=="textValue"&&c.namespaceUri===Ar&&c.localName==="style"&&Dr(c,"type")==="paragraph"&&Dr(c,"styleId")===t){r=c;break}if(!r)return null;let o=qt(r,"name");if(o&&Dr(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let a=Jm(n);if(!a)return null;let i=qt(a,"contextualSpacing");if(!i)return null;let s=qt(r,"pPr"),l;if(s){let c=qt(s,"contextualSpacing");if(c&&qm(c))return e;l=c?ib(n,c.id,i):hb(n,s.id,Qm(s.children,"contextualSpacing"),[i]);}else {let c=r.children.findIndex(d=>d.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(d.localName));l=hb(n,r.id,c===-1?r.children.length:c,[a]);}return l.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,l.part]])}):null}var yc="http://schemas.openxmlformats.org/package/2006/relationships",xc="application/vnd.openxmlformats-package.relationships+xml",tp="http://schemas.openxmlformats.org/package/2006/content-types",fc="/[Content_Types].xml",Ct="/word/numbering.xml",gc="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",In="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",np=`<Override PartName="${Ct}" ContentType="${In}"/>`;function _r(e){return `${e.ownerPart}\0${e.id}`}function kc(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===ye).map(_r)),o=n.externalTargets.filter(s=>s.type===ye&&!r.has(_r(s)));if(o.length===0)return e;let a=new Set(e.map(_r)),i=o.filter(s=>!a.has(_r(s)));return i.length===0?e:Object.freeze([...e,...i])}function Pc(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 Oc(e,t,n=[],r=false){if(e===t)return e;let o=rp(e,t,r);return o=ap(o,t,n),o}function bc(e,t){let n=new Set;for(let o of e.externalTargets)o.type===ye&&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 a=cp(o);!a||a===e.mainDocumentPart||e.parts.has(a)||t.has(a)||e.externalTargets.some(i=>i.ownerPart===a)||n.add(a);}if(n.size===0)return e;let r=e;for(let o of n)r=dp(r,o);return r}function rp(e,t,n){let r=t.parts.get(Ct);if(!r)return e;let o=e.parts.get(Ct),a=n&&o?op(o,r):r,i=kg$1(e,a),s=(t.relationships.get(t.mainDocumentPart)??[]).find(c=>c.type===gc),l=i.relationships.get(i.mainDocumentPart)??[];if(s&&!l.some(c=>c.type===gc)&&!l.some(c=>c.id===s.id)){let c=sp(i,{...s,ownerPart:i.mainDocumentPart});c&&(i=c);}if(i.contentTypes.overrides.get(C(Ct))!==In){let c=mp(i);c&&(i=c);}return i}function op(e,t){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let c=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!c)return null;let d=l.attributes.find(m=>m.namespaceUri===n&&m.localName===c)?.value;return d===void 0?null:`${l.localName}:${d}`},o=new Set(e.root.children.map(r).filter(Boolean)),a=ab(e),i=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=e;for(let l of t.root.children){let c=r(l);if(!c||o.has(c)||l.kind==="textValue")continue;let d=i.indexOf(l.localName),m=s.root.children.findIndex(h=>h.kind!=="textValue"&&h.namespaceUri===n&&i.indexOf(h.localName)>d),f=hb(s,s.root.id,m<0?s.root.children.length:m,[sa(l,a)]);f.ok&&(s=f.part,o.add(c));}return s}function ap(e,t,n){let r=n.filter(a=>a.type===ye);if(r.length===0)return e;let o=e;for(let a of r){let i=ip(e,t,a.ownerPart);if(!i||o.externalTargets.some(c=>c.ownerPart===i&&c.id===a.id)||new Set((o.relationships.get(i)??[]).map(c=>c.id)).has(a.id))continue;let l=lp(o,{ownerPart:i,id:a.id,type:ye,rawTarget:a.rawTarget,sinkSafe:a.sinkSafe},i);l&&(o=l);}return o}function ip(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function sp(e,t){let n=e.mainDocumentPart,r=la(n),o=e.parts.get(r),a=Pa$1(`<Relationships xmlns="${yc}"><Relationship Id="${Y(t.id,"relationship id")}" Type="${Y(t.type,"relationship type")}" Target="${Y(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:xc});if(!a.ok)return null;let i=e.relationships.get(n)??[];if(i.some(c=>c.id===t.id))return null;let s={...t,ownerPart:n,order:i.reduce((c,d)=>Math.max(c,d.order),-1)+1},l=new Map([...e.relationships,[n,[...i,s]]]);return o?Rc(e,o,a.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,a.part]]),relationships:l})}function lp(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=la(r),a=e.parts.get(o),i=Pa$1(`<Relationships xmlns="${yc}"><Relationship Id="${Y(t.id,"relationship id")}" Type="${ye}" Target="${Y(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:xc});if(!i.ok)return null;let s=[...e.externalTargets,t];if(!a)return Object.freeze({...e,parts:new Map([...e.parts,[o,i.part]]),externalTargets:s});let l=Rc(e,a,i.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Rc(e,t,n,r){if(!n)return null;let o=ab(t),a=hb(t,t.root.id,t.root.children.length,[sa(n,o)]);return a.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,a.part]]),relationships:r}):null}function sa(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>sa(n,t))}}function la(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function cp(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 dp(e,t){let n=la(t),r=new Map(e.parts);r.delete(n);let o=new Map(e.partBytes);o.delete(n);let a=new Map(e.relationships);a.delete(t);let i=Object.freeze(e.externalTargets.filter(s=>s.ownerPart!==t));return Object.freeze({...e,parts:r,partBytes:o,relationships:a,externalTargets:i})}function mp(e){let t=e.contentTypes.overrides.get(C(Ct));if(t===In)return e;if(t!==void 0)return null;let n=e.partBytes.get(fc);if(!n)return null;let r=strFromU8(n),o=hc(r);if(!o)return null;let a=r.lastIndexOf(`</${o.rootName}>`);if(a===-1)return null;let i=r.slice(0,a)+np+r.slice(a),s=hc(i);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Ic("Override",{PartName:Ct,ContentType:In})];return s.children.length!==l.length||s.children.some((c,d)=>c!==l[d])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[fc,strToU8(i)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[C(Ct),In]])})})}function hc(e){let t=ea$1(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(":"),a=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[a?`xmlns:${a}`:"xmlns"]!==tp)return null;let i=[];for(let s of r.children)s.type==="element"&&i.push(Ic(s.name,s.attributes));return {rootName:r.name,children:i}}function Ic(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}var Nc=4e3,Sc=64;function vc(e){return gj(e,"footnote")!==null||gj(e,"endnote")!==null}function wc(e,t,n,r){if(!vc(e))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=cb(Cr(t),n.paragraphId);return !o||o.kind!=="paragraph"?true:si(o).some(a=>a.node.kind==="noteReference"&&a.start<n.end&&a.end>n.start)}function Ec(e,t,n,r){if(!vc(e))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=cb(Cr(t),n.blockId);if(!o||o.kind==="textValue")return true;let a=0,i=(s,l)=>{if(a>=Nc||l>Sc)return true;if(a+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return si(s).some(c=>c.node.kind==="noteReference");for(let c of s.children)if(i(c,l+1))return true;return false};return i(o,0)}function Tc(e,t,n){if(n.count>=Nc||t>Sc)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(Tc(r,t+1,n))return true;return false}function Cc(e,t,n,r){if(!e())return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let a=cb(Cr(t),o);return !a||a.kind==="textValue"?true:Tc(a,0,{count:0})}var ca="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",da="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Mc(e,t){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===t);return r?r.type!==ca&&r.type!==da?{ok:false,reason:"wrong-relationship-type",detail:r.type}:pp(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function pp(e,t){let n=N(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 ma=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),pa=new Set(["authorTable","deleteTableRow","deleteTableColumn","mergeTableCells","removeContentControl","removeRepeatingSectionItem","removeToc"]);function Mt(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Dc(e,t){let n=cb(e,t);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function Ac(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=cb(r,n);return !o||o.kind!=="drawing"?null:Re$1(o,{ownerPartName:t,supportedMcRequires:Le,limits:Ke$1,resolveRelationship:Ne(e,t)})}function _c(e,t,n){let r=O(e.relationships.get(t)??[],t,n);return r.mode==="internal"?r.partName:null}function Jt(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let a=Mt(e,o.store);if(a)return a;let{store:i,story:s}=o;return Va$1(e,()=>up(e,i,s,n,r),l=>Wa(l))}function up(e,t,n,r,o){let a=n.partName,i=e.currentPackage(),s=t.checkpoint();t.graftPackage(()=>e.currentPackage());let l=null,c=false,d=false,m=t.transact(y=>{if(o?.commitGuard?.()===false){d=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){c=true;return}let P=r(y,a);if(P===null){y.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=P;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(d)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let f=m.change.created.find(y=>{let P=t.part;return cb(P,y)?.kind==="drawing"});return f&&(l=f),{ok:true,change:e.promoteStoryTransactionToPackageUnit(i,t,s),...l?{drawingNodeId:l}:{}}}function Uc(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Dc(r,n);return o?on(o):null}function ua(e,t,n,r){let o=false;return e.applyPackage(a=>{let i=a.parts.get(t);if(!i)return a;let s=cb(i,n);if(!s||s.kind!=="drawing")return a;let l=Dc(i,n);if(!l)return a;let c=pn$1(l,r),d=fp(s,c),m=ib(i,s.id,d,{deferValidation:true});return m.ok?(o=true,kg$1(a,m.part)):a}),o}function fp(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function Fc(e,t,n){let r=ag(n.widthPoints),o=ag(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let a=e.resolveStory(t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let i=Mt(e,a.store);if(i)return i;let s=a.story.partName,l=await Xf(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let c=l.bytes,d=Zf(e.currentPackage(),s,{bytes:c,mime:n.mime});if(!d.ok)return {ok:false,reason:"invalidArgs",detail:d.reason==="invalid-image"?"invalid-image":d.reason};let m=d.partName,f=Jt(e,t,(h,y)=>{let P=e.currentPackage(),T=Zf(P,y,{bytes:c,mime:n.mime});if(!T.ok)return null;P=T.pkg,m=T.partName;let M;if(n.hyperlink){let x=Xi(P,n.hyperlink,y);if(!x)return null;P=x.pkg,M=x.relationshipId;}if(!h.applyPackage(()=>P))return null;let p=bg({docPrId:T.docPrId,relationshipId:T.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...M?{hyperlinkRelationshipId:M}:{}});return h.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:m}:{ok:true,change:null,mediaPartName:m}:f}async function fa(e,t,n,r,o,a,i){let s=e.resolveStory(t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=Mt(e,s.store);if(l)return l;let c=s.story.partName,d=await Xf(a,r,o);if(!d.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let m=d.bytes,f=Zf(e.currentPackage(),c,{bytes:m,mime:o});return f.ok?Jt(e,t,(h,y)=>{let P=e.currentPackage(),T=Ac(P,c,n),M=T?.picture?.embeddedRelationshipId??null,p=T?.picture?.linkedRelationshipId??null,x=M??p;if(!x)return null;let k=M!==null?_c(P,c,M):null,v=P,A=Zf(v,y,{bytes:m,mime:o});return !A.ok||(v=A.pkg,!h.applyPackage(()=>v))||!h.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:A.relationshipId})?null:(h.applyPackage(O=>dg(O,y,k,x)),n)},{expectedPackageRevision:i.expectedPackageRevision,...i.commitGuard?{commitGuard:i.commitGuard}:{},...i.actorId?{actorId:i.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:f.reason==="invalid-image"?"invalid-image":f.reason}}function Lc(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=Mt(e,r.store);if(o)return o;let a=r.story.partName,i=e.currentPackage(),s=i.parts.get(a),l=Ac(i,a,n)??(s?cn(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let c=l.picture?.embeddedRelationshipId??null,d=l.picture?.linkedRelationshipId??null,m=c??d,f=c!==null?_c(i,a,c):null;return Jt(e,t,(h,y)=>h.apply({op:"deleteDrawing",drawingNodeId:n})?(h.applyPackage(P=>dg(P,y,f,m)),n):null)}function gp(e,t){let n=null,r=a=>{let i=false,s=false,l=(c,d)=>{if(i||c.kind==="textValue")return;if(c.id===t){i=true,s=d;return}let m=d||c.kind==="revisionDelete"||c.kind==="revisionMoveFrom";for(let f of c.children)l(f,m);};return l(a,false),s},o=a=>{if(!(n!==null||a.kind==="textValue")){if(a.kind==="paragraph"){let i=ui(a).spanOf(t);if(i!==null&&i.end>i.start){let s=cb(e,t);if(!s||s.kind!=="drawing"&&!Oe(s))return;n={paragraphId:a.id,start:i.start,end:i.end,alreadyDeleted:r(a)};}return}for(let i of a.children)o(i);}};return o(e.root),n}function $c(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let a=Mt(e,o.store);if(a)return a;let i=e.currentPackage().parts.get(o.story.partName);if(!i)return {ok:false,reason:"unknown-drawing"};let s=gp(i,n);return s?s.alreadyDeleted?{ok:true,change:null}:Jt(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 Bc(e,t,n,r,o,a,i,s){let l=await eg(o,r,a,void 0,i);return l.ok?fa(e,t,n,l.bytes,l.mime,i,{expectedPackageRevision:e.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function Hc(e,t,n,r,o,a){let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let s=Mt(e,i.store);return s||Jt(e,t,(l,c)=>{let d=Uc(e.currentPackage(),c,n),m=null;if(a!==null){let h=Xi(e.currentPackage(),a,c);if(!h||!l.applyPackage(()=>h.pkg))return null;m=h.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...a===null?{hyperlink:null}:{}}))return null;if(a!==null&&m!==null){if(!ua(l,c,n,m))return null}else if(a===null&&!ua(l,c,n,null))return null;let f=false;return l.applyPackage(h=>{let y=Zi(h,c,d);return y===null?(f=true,h):y}),f?null:n})}function Vc(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=Mt(e,r.store);return o||Jt(e,t,(a,i)=>{let s=Uc(e.currentPackage(),i,n.drawingNodeId),l=null;if(n.hyperlink!==null){let d=Xi(e.currentPackage(),n.hyperlink,i);if(!d||!a.applyPackage(()=>d.pkg))return null;l=d.relationshipId;}for(let d of n.ops)if(!a.apply(d))return null;if(!ua(a,i,n.drawingNodeId,n.hyperlink===null?null:l))return null;let c=false;return a.applyPackage(d=>{let m=Zi(d,i,s);return m===null?(c=true,d):m}),c?null:n.drawingNodeId})}function hp(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 jc(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 yp(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 xp(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((a,i)=>!yp(a,o[i])))return false}return true}function kp(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 Pp(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||!hp(r,o))return false}return true}function Op(e,t){return e.contentTypes===t.contentTypes||jc(e.contentTypes.defaults,t.contentTypes.defaults)&&jc(e.contentTypes.overrides,t.contentTypes.overrides)}var Ur=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),Qt=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function Gc(e){for(let[t,n]of e)if(!Ka(t,n)||!La$1(n.root,t.root).idsPreserved)return Qt;return Ur}function bp(e,t){if(e===t)return Ur;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Pp(e.partBytes,t.partBytes)||!xp(e.relationships,t.relationships)||!kp(e.externalTargets,t.externalTargets)||!Op(e,t))return Qt;let n=[];for(let[i,s]of e.parts){let l=t.parts.get(i);if(!l)return Qt;s!==l&&n.push([s,l]);}if(n.length===0)return Ur;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return Gc(n);let a=La$1(o.root,r.root);return a.undecided?Gc(n):a.equal&&a.idsPreserved?Ur:a.equal?a.renamedOutsideParagraphs||a.renamedParagraphIds.length===0?Qt:{equal:false,dirty:a.renamedParagraphIds,dependencyKeys:[l.story],impact:"text-local"}:!a.idsPreserved||a.reach==="outside-paragraph"||a.paragraphIds.length===0?Qt:{equal:false,dirty:a.paragraphIds,dependencyKeys:[l.story],impact:a.reach==="paragraph-text"?"text-local":"flow-structural"}}function ga(e){return {ok:false,reason:"package-invariant",detail:e}}function Rp(e,t){if(!e.parts.get(e.mainDocumentPart))return ga("no-main-document");for(let[r,o]of e.parts){let a=t?.parts.get(r);if(a===o)continue;let i=a?Na$1(a,o):Ma$1(o);if(!i.ok)return ga(`invalid-part:${r}:${i.issues[0]?.code??"invalid"}`)}let n=vg(e);return n.ok?null:ga(n.issues[0]?.code??"package-invariant")}function zc(e,t,n){let r=e.currentPackage(),o=bp(t,r);if(o.equal)return {ok:true,change:null};let a=Rp(t,r);if(a)return a;let i=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===i;return Va$1(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:i}})}},()=>false)}function Ip(e,t,n,r){let o=[...t],a=new Set;for(let i of o)e.parts.has(i)&&a.add(i);for(let i of n)Wc(i,o,a);for(let i of r)Wc(i,o,a);return a}function Np(e,t,n,r,o){let a=new Set(e);a.add(t),a.add(n);for(let i of r)Kc(i,a);for(let i of o)Kc(i,a);return a}function Wc(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 Kc(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);}function Xc(e){let{stories:t,rIdToPartName:n,undoOrder:r,redoOrder:o}=e,a=Ip(e.pkg,t.keys(),r,o);for(let[l]of [...t])if(!a.has(l)){t.delete(l);for(let[c,d]of [...n])d===l&&n.delete(c);}let i=Np(a,e.pkg.mainDocumentPart,e.bodyPartName,r,o),s=bc(e.pkg,i);return {pkg:s,shellHyperlinks:Pc(e.shellHyperlinks,i,s.mainDocumentPart)}}function Yc(e,t,n,r,o,a){return {change:"model-change",fromRevision:Math.max(0,t-1),toRevision:t,commitId:`pkg-commit-${e}`,origin:n,dirty:[],created:[...a],deleted:[],splitJoin:[],dependencyKeys:[],impact:r,story:o}}var qc=64,Nn=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];historyGroups=new Mr;subscribers=new Set;historyLimit;contentLockPolicy;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;storyStoreOptions(){return {historyLimit:this.historyLimit,settingsPart:()=>wf(this.pkg),...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{}}}constructor(t,n,r={}){this.pkg=kg$1(t,n),this.historyLimit=r.historyLimit??200,this.contentLockPolicy=Kk(r.contentLockPolicy),this.maxEditableStoryParts=r.maxEditableStoryParts??qc,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??Bj,this.body=new Tt(this.pkg,n.name,this.storyStoreOptions()),this.body.setStoryRef({kind:"body",partName:n.name}),Fn(this,{current:()=>this.undoOrder.at(-1)??null,split:()=>{this.closeHistoryGroups(),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,a=true;for(let i of this.stories.values()){if(t.storyParts[o]!==i.part){a=false;break}o+=1;}if(a&&o===t.storyParts.length)return t.result}let n=kg$1(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=kg$1(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 Va$1(this,()=>this.commitStoryTransaction(t,n,r),Wa,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:a,story:i}=o,s=this.currentPackage(),l=a.historyPushCount,c=a.compositionActive,d=a.checkpoint(),m=false,f=new Set,h=false,y,P=new Set,T=false,M,p=false,x;a.graftPackage(()=>this.currentPackage());let k=a.transact(O=>{x=sc(O),n({...O,applyTo:(D,F)=>{let w=O.applyTo(D,F);return w&&D!==i.partName&&(p=true),w},applyPackage:D=>O.applyPackage(F=>{let w=D(F);return w!==F&&!p&&(p=cc(F,w,i.partName)),w}),apply:D=>(D.op==="setListNumbering"&&Number(D.numId)>0&&(T=true),D.op==="setParagraphProperties"&&(M??=D.properties.find(F=>F.localName==="pStyle")?.attributes?.val),m||(D.op==="deleteText"&&wc(this.pkg,a,D,f)||D.op==="deleteBlock"&&Ec(this.pkg,a,D,f)||ma.has(D.op)||pa.has(D.op))&&(m=true),h||(D.op==="deleteText"||D.op==="deleteBlock"?h=Cc(()=>y??=Oj(this.pkg),a,D,P):(ma.has(D.op)||pa.has(D.op))&&(h=true)),O.apply(D)),...x.context});},{...r,story:i,...i.kind==="headerFooter"||i.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!k.ok)return {ok:false,reason:k.reason,...k.detail?{detail:k.detail}:{}};this.syncPackageFromStore(a);let v=false;if(k.change&&p&&(this.installPackageSnapshotInternal(a.package,false),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):a.restoreHistoryStacks(d),v=true),T&&M){let O=uc(this.pkg,M);O&&this.replacePackageShell(O);}let A=false;if(k.change&&m){let O=this.currentPackage(),D=this.cascadeNoteReferences(s,O);if(D===null)return a.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};D!==O&&(this.installPackageSnapshotInternal(D),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):a.restoreHistoryStacks(d),A=true);}if(k.change&&h){let O=this.currentPackage(),D=Qj(s,O,{storyPartName:i.partName});if(D===null)return a.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};D!==O&&(this.installPackageSnapshotInternal(D),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):a.restoreHistoryStacks(d),A=true);}if(k.change){this.packageRev+=1;let O=A||v;if(!c&&r.recordsHistory!==false&&(a.historyPushCount>l||O))if(O)this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...x?.snapshot(k.change.caret)},Yt(r.historyGroup,s));else {let F=Yt(r.historyGroup,s);this.pushUndoPointer({kind:"story",partName:i.partName,story:i},F);}let D=O?this.publishSynthetic(k.change.origin,"global",i,k.change.created):k.change;return O||this.publish(D),{ok:true,change:D}}return {ok:true,change:k.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.historyPushCount;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.historyPushCount>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(g.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(t,n={}){let r=()=>this.commitLifecycleOp(t,n.historyGroup);return Rb(n.actorId,()=>Va$1(this,r,Wa,n.historyGroup))}commitLifecycleOp(t,n){let r=this.currentPackage(),o=Nk(wf(r),t);if(o)return {ok:false,reason:o};if(zj(t)){let c=Aj(r,t);if(!c.ok)return {ok:false,reason:c.reason,...c.detail?{detail:c.detail}:{}};if(c.package===r)return {ok:true,change:null};this.installPackageSnapshotInternal(c.package);let d=Yt(n,r);this.pushUndoPointer({kind:"package",before:r,after:c.package},d),this.packageRev+=1;let m={kind:"body",partName:this.body.part.name},f=this.publishSynthetic(g.mutationHuman,c.impact,m,c.createdPartName?[c.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:f}}if(!bj(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let a=cj(r,t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};this.installPackageSnapshotInternal(a.package);let i=Yt(n,r);this.pushUndoPointer({kind:"package",before:r,after:a.package},i),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(g.mutationHuman,a.impact,s,a.createdPartName?[a.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}undo(){let t=this.undoOrder.pop();if(!t)return null;if(this.closeHistoryGroups(),t.kind==="package"){this.installPackageSnapshotInternal(t.before,true,t.restoreNumbering),this.redoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(g.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(this.closeHistoryGroups(),t.kind==="package"){this.installPackageSnapshotInternal(t.after,true,t.restoreNumbering),this.undoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(g.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 oa(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return oa(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return aa(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return lc(this.stories,this.pkg)}insertImage(t,n){return Fc(this,t,n)}applyFragmentPaste(t,n){return ta(this,t,n)}replaceImage(t,n,r,o,a,i){return fa(this,t,n,r,o,a,i)}deleteImage(t,n){return Lc(this,t,n)}deleteImageTracked(t,n,r){return $c(this,t,n,r)}embedExternalImage(t,n,r,o,a,i,s){return Bc(this,t,n,r,o,a,i,s)}setDrawingMetadataWithHyperlink(t,n,r,o,a){return Hc(this,t,n,r,o,a)}applyImageProperties(t,n){return Vc(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 a=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(g.mutationHuman,a?.kind==="headerFooter"?"global":"flow-structural",a??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(t){return t?(this.packageRev+=1,this.publish(t),t):null}adoptPackageUnit(t){this.adoptGroupedPackageUnit(t,void 0);}adoptGroupedPackageUnit(t,n){let r=this.currentPackage();t!==r&&this.pushUndoPointer({kind:"package",before:t,after:r},Yt(n,t));}installPackageSnapshot(t){this.installPackageSnapshotInternal(t);}installAuthoritativePackageSnapshot(t){this.installPackageSnapshotInternal(t,false);}publishRemotePackage(t,n){return zc(this,t,n)}replacePackageShell(t){this.shellHyperlinks=kc(this.shellHyperlinks,this.pkg,t);let n=t;n=kg$1(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=kg$1(n,r.part));this.pkg=n;}installPackageSnapshotInternal(t,n=true,r=false){let o=n?Oc(t,this.pkg,this.shellHyperlinks,r):t,a=o.parts.get(o.mainDocumentPart);if(!a)return;this.body.replacePart(a);for(let[s,l]of this.stories){let c=o.parts.get(s);c&&l.replacePart(c);}this.rIdToPartName.clear();let i=o.relationships.get(o.mainDocumentPart)??[];for(let s of i){if(s.type!==ca&&s.type!==da)continue;let l=N(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=kg$1(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=kg$1(this.pkg,s.part));}openNotesPartStore(t){let n=gj(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=Ob(n),a=new Tt(o,this.storyStoreOptions()),i={kind:"notesPart",partName:o.name,noteKind:t};return a.setStoryRef(i),this.stories.set(o.name,a),o!==n&&(this.pkg=kg$1(this.pkg,o)),{ok:true,story:i,store:a}}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=Mc(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 a=Ob(r.part),i=new Tt(a,this.storyStoreOptions()),s={kind:"headerFooter",partName:a.name,rId:t};return i.setStoryRef(s),this.stories.set(a.name,i),this.rIdToPartName.set(t,a.name),a!==r.part&&(this.pkg=kg$1(this.pkg,a)),{ok:true,story:s,store:i}}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=kg$1(this.pkg,t.part);}closeHistoryGroups(){Cn(this.body,this.stories,null),this.historyGroups.close();}pushUndoPointer(t,n){t=this.historyGroups.admit(t,n,this.undoOrder,r=>(r===this.body.part.name?this.body:this.stories.get(r))?.discardNewestUndoEntry()??null,()=>this.currentPackage()),Cn(this.body,this.stories,t),this.undoOrder.push(t),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let t=Xc({pkg:this.pkg,stories:this.stories,rIdToPartName:this.rIdToPartName,bodyPartName:this.body.part.name,shellHyperlinks:this.shellHyperlinks,undoOrder:this.undoOrder,redoOrder:this.redoOrder});this.pkg=t.pkg,this.shellHyperlinks=t.shellHyperlinks;}publish(t){this.lastChange=t;for(let n of this.subscribers)n(t);}publishSynthetic(t,n,r,o){this.commitCounter+=1;let a=Yc(this.commitCounter,this.packageRev,t,n,r,o);return this.publish(a),a}};function Jc(e,t){let n=e,r=Ta$1(),o=[];for(let[a,i]of t){let s=n.parts.get(a);if(!s)continue;let l=m=>{if(i.removed.has(m.id))return null;if(m.kind==="textValue")return m;let f=i.replaced.get(m.id)??m,h;for(let y=0;y<m.children.length;y+=1){let P=m.children[y],T=l(P);T!==P&&h===void 0&&(h=m.children.slice(0,y)),h!==void 0&&T!==null&&h.push(T);}if(r){for(let y=m.children.length-1;y>=0;y-=1)i.removed.has(m.children[y].id)&&o.push(()=>Za(m.id,y,1,[]));for(let y=0;y<f.attributes.length;y+=1){let P=f.attributes[y];P!==m.attributes[y]&&o.push(()=>Ya(m.id,{namespaceUri:P.namespaceUri,localName:P.localName,...P.prefix===void 0?{}:{prefix:P.prefix}},P.value));}}return h!==void 0||f!==m?Object.freeze({...f,children:h===void 0?m.children:Object.freeze(h)}):m},c=l(s.root);if(c===s.root)continue;if(c===null)return null;let d=Xa(()=>ib(s,s.root.id,c,{deferValidation:true}));if(!d.ok)return null;n=kg$1(n,d.part);}for(let a of o)a();return n}function ha(e){for(let t=e.children.length-1;t>=0;t-=1){let n=e.children[t];if(n.kind==="paragraph")return ef$1(n,ua$1,"paraId")?.toUpperCase()??null}return null}function Qc(e,t,n){return t.length===0?e:Sp(e,t,n,Dj(e))}function Sp(e,t,n,r){let o=ff$1(e,n.storyPartName),a=o===null?void 0:e.parts.get(o);if(!a)return e;let i=[];if(!cf$1(r))return null;df$1(a.root,r,w=>w.kind!=="comment"?false:(ef$1(w,pa$1,"id")!==void 0&&i.push({partName:a.name,node:w}),true));let s=Ej(e,n),l=hf$1(e,[s.extended,s.ids],r);if(r.truncated)return null;let c=e.parts.get(n.storyPartName),d=c===void 0?null:n.noteId===void 0?c.root:Tc$1(c.root).find(w=>Ic$1(w)===n.noteId)??null,m=new Map,f=new Map;for(let w of e.parts.values()){if(!w.name.endsWith(".xml"))continue;if(!cf$1(r))return null;if(w.root===d)continue;let N;if(df$1(w.root,r,S=>{if(S===d)return true;if(!["commentRangeStart","commentRangeEnd","commentReference"].includes(S.kind))return false;let I=ef$1(S,pa$1,"id");return I===void 0||(N??=ff$1(e,w.name)===o,N&&(m.set(`${w.name}\0${S.id}`,I),f.set(I,(f.get(I)??0)+1))),true}),r.truncated)return null}let h=new Map,y=w=>{let N=h.get(w);return N||(N={removed:new Set,replaced:new Map},h.set(w,N)),N},P=w=>{let N=h.get(w.partName);return N?.removed.has(w.node.id)?null:N?.replaced.get(w.node.id)??w.node},T=w=>{y(w.partName).removed.add(w.node.id);let N=S=>{y(w.partName).removed.add(S.id);let I=`${w.partName}\0${S.id}`,_=m.get(I);if(_!==void 0&&(m.delete(I),f.set(_,f.get(_)-1)),S.kind!=="textValue")for(let q of S.children)N(q);};N(w.node);},M=(w,N,S,I)=>{let _=P(w);if(!_)return;let q=_.attributes.map(ee=>ee.kind==="genericExtension"&&ee.namespaceUri===N&&ee.localName===S&&ee.value!==I?{...ee,value:I}:ee);q.some((ee,K)=>ee!==_.attributes[K])&&y(w.partName).replaced.set(_.id,{..._,attributes:q});},p=()=>{let w=new Map,N=new Set;for(let S of i){let I=P(S);if(!I)continue;let _=ef$1(I,pa$1,"id");w.has(_)?N.add(_):w.set(_,{...S,node:I});}return {byId:w,duplicateIds:N}},x=()=>l.flatMap(w=>{let N=P(w);return N?[{...w,node:N}]:[]}),k=()=>Fj(e,n,r,false,{records:p(),metadata:x()}),v=t.every(w=>w.parentCommentId===void 0)?k():null;if(r.truncated)return null;let A=v&&!v.malformed&&v.duplicateIds.size===0?v:null,O=new Set,D=new Map;for(let w of l){let N=ef$1(w.node,$e,"paraId")??ef$1(w.node,af$1,"paraId");if(N===void 0)continue;let S=N.toUpperCase(),I=D.get(S);I?I.push(w):D.set(S,[w]);}let F=w=>{for(let N of w)for(let S of D.get(N)??[])P(S)&&T(S);};for(let w of t){let{commentId:N,parentCommentId:S}=w;if(S!==void 0){let K=p().byId,ae=K.get(N),B=K.get(S);if(!ae||!B||N===S||(O.add(N),(f.get(N)??0)>0))continue;let V=ha(ae.node),z=ha(B.node);for(let ne of K.values())ef$1(ne.node,af$1,"parentId")===N&&M(ne,af$1,"parentId",S);if(V!==null&&z!==null)for(let ne of l){let ie=P(ne);ne.partName===s.extended&&ie&&ef$1(ie,$e,"paraIdParent")?.toUpperCase()===V&&M(ne,$e,"paraIdParent",z);}T(ae),V!==null&&F(new Set([V]));continue}let I=A??k();if(r.truncated)return null;if(!I.records.has(N))continue;let _=Gj(N,I.childrenOf,r);if(r.truncated)return null;let q=new Set,ee=[..._].filter(K=>(f.get(K)??0)===0);for(let K of _)O.add(K);for(let K of ee){let ae=I.records.get(K);if(!ae)continue;let B=ha(ae.node);if(B!==null&&q.add(B),T(ae),A){A.records.delete(K),A.childrenOf.delete(K);let V=A.parentCommentIdByChildId.get(K);if(V!==void 0){let z=A.childrenOf.get(V);z&&A.childrenOf.set(V,z.filter(ne=>ne!==K));}}}F(q);}if(d&&O.size>0){if(!cf$1(r))return null;let w=_if(d,O,r);if(w.truncated)return null;let N=y(n.storyPartName).removed;for(let S of w.emptiedRuns)N.add(S);for(let S of w.doomed)N.add(S);}return Jc(e,h)}var vp=256,wp=65535,Zc=64;function Fr(e,t){return e.length>t}function ed(e){return typeof e!="string"||e.trim().length===0?"invalid-author":Fr(e,vp)?"resource-limit":X(e)?null:"invalid-author"}function td(e){return typeof e!="string"||e.length===0?"invalid-text":Fr(e,wp)?"resource-limit":X(e)?null:"invalid-text"}function ya(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(Fr(t,Zc))return {ok:false,rejection:"resource-limit"};if(!X(t))return {ok:false,rejection:"invalid-date"};let n=Gh(t);return n===null?{ok:false,rejection:"invalid-date"}:Fr(n,Zc)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function pk(e){if(e===void 0)return null;let t=ya(e);return t.ok?null:t.rejection}function xa(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 Ep(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function ka(e,t){if(!e){let i=Sb(t);return i?Ub(new Set,i,Pb):"0"}let n=-1,r=new Set,o=i=>{if(i.kind!=="textValue"){if(i.kind==="comment"){let s=Ep(i,pa$1,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=Pb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of i.children)o(s);}};o(e.root);let a=Sb(t);return a?Ub(r,a,Pb):String(n+1)}function nd(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 a of e.children){let i=nd(a,t);i!==a&&(r=true),o.push(i);}return r?{...e,children:o}:e}function Mp(e,t,n){let r=nd(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:ua$1}]};return ib(e,e.root.id,o,{deferValidation:true})}function rd(e,t,n){let r=new Map;for(let a of t){if(a.stampParagraph===null)continue;let i=r.get(a.commentsPartName);i||(i=new Map,r.set(a.commentsPartName,i)),i.set(a.stampParagraph.id,{paragraph:a.stampParagraph,paraId:a.paraId});}let o=e;for(let[a,i]of r){let s=o.parts.get(a);if(!s)return null;let l=Kb(s.root),c=l??"w14",d=new Map;for(let f of i.values())d.set(f.paragraph.id,n(f.paragraph,f.paraId,c));let m=Mp(s,d,l===null?c:null);if(!m.ok)return null;o=kg$1(o,m.part);}return o}function od(e,t,n){let r=e.root.children.map(o=>o.kind==="textValue"?o:t.get(o.id)??o);return gb(e,e.root.id,[...r,...n],{deferValidation:true})}var sd="/word/comments.xml",ld="/word/commentsExtended.xml",Ia="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Na="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Dp=[Na,"application/vnd.ms-word.commentsExtended+xml"],cd="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Sa="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",kt="http://schemas.microsoft.com/office/word/2012/wordml";function vn(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Zt(e,t){return {kind:"genericExtension",namespaceUri:pa$1,localName:e,prefix:"w",value:t}}function ct(e,t,n,r,o,a,i,s=[]){return {id:e,kind:t,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:a,children:i}}function dd(e,t,n,r,o){let a=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let i of a)for(let s of mg(e,i)){if(s.type!==n)continue;let l=E(i,s.rawTarget);if(!l.ok)continue;if(!e.parts.has(l.partName))return l.partName;let c=ng(e,l.partName);if(c!==null&&(typeof r=="string"?c===r:r.includes(c)))return l.partName}return o}function Pa(e,t,n){let r=e.mainDocumentPart;for(let a of mg(e,r)){if(a.type!==t)continue;let i=E(r,a.rawTarget);if(i.ok&&i.partName===n)return e}let o=sg(e,r);return tg(o,r,t,bk(r,n)).pkg}function va(e,t){return dd(e,t,cd,Ia,sd)}function md(e,t){let n=ff$1(e,t),r=gf$1(e,t,n).extended;return r!==null?r:dd(e,t,Sa,Dp,ld)}function ad(e){let t=new Set;for(let n of e.parts.values())for(let r of Jb(n.root))t.add(r);return t}function Ap(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&vn(o,pa$1,"id")===t){for(let a=o.children.length-1;a>=0;a-=1){let i=o.children[a];if(i.kind!=="paragraph")continue;let s=vn(i,ua$1,"paraId");s!==void 0&&Fb(s)&&(n=s.toUpperCase());return}return}for(let a of o.children)r(a);}};return r(e.root),n}function _p(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&vn(o,pa$1,"id")===t){for(let a=o.children.length-1;a>=0;a-=1){let i=o.children[a];if(i.kind==="paragraph"){n=i;return}}return}for(let a of o.children)r(a);}};return r(e.root),n}function pd(e){let t=Kb(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:ua$1}]},r=ib(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(eb(e.root,n),{part:{...e,root:n},prefix:"w14"})}function ud(e,t,n){return ct(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===ua$1&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:ua$1,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function Up(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let a=pd(o),i=cb(a.part,n);if(!i||i.kind!=="paragraph")return kg$1(e,a.part);let s=ib(a.part,i.id,ud(i,r,a.prefix),{deferValidation:true});return kg$1(e,s.ok?s.part:a.part)}function Fp(e,t,n,r){let o=`${sd}#comment-${e}`,a=n.text!==n.text.trim(),i=ct(`${o}.t`,"text",pa$1,"w","t",a?[{kind:"xmlSpace",namespaceUri:qa,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=ct(`${o}.rPr`,"runProperties",pa$1,"w","rPr",[],[ct(`${o}.rStyle`,"generic",pa$1,"w","rStyle",[Zt("val","CommentReference")],[])]),l=ct(`${o}.r`,"run",pa$1,"w","r",[],[s,i]),c=ct(`${o}.pPr`,"paragraphProperties",pa$1,"w","pPr",[],[ct(`${o}.pStyle`,"generic",pa$1,"w","pStyle",[Zt("val","CommentText")],[])]),d=ct(`${o}.p`,"paragraph",pa$1,"w","p",[{kind:"genericExtension",namespaceUri:ua$1,localName:"paraId",prefix:r,value:t}],[c,l]);return ct(o,"comment",pa$1,"w","comment",[Zt("id",e),Zt("author",n.author),...n.initials===void 0?[]:[Zt("initials",n.initials)],...n.date===void 0?[]:[Zt("date",n.date)]],[d])}function Oa(e,t){let n=Pa$1(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function wa(e,t){for(let M of [ed(t.author),td(t.text)])if(M)return {ok:false,reason:xa(M)};let n;if(t.date!==void 0){let M=ya(t.date);if(!M.ok)return {ok:false,reason:xa(M.rejection)};n=M.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,a=e.part.name,i=va(o,a),s=md(o,a),l=o.parts.get(i),c=ka(l,r.actorId),d=Ib(`${i}#${c}`,ad(o)),m=t.replyToCommentId===void 0?null:Ap(l,t.replyToCommentId),f=t.replyToCommentId!==void 0&&m===null?_p(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&m===null&&!f)return {ok:false,reason:"unknown-revision"};let h=f?Ib(`${i}#parent-${t.replyToCommentId}`,new Set([...ad(o),d])):null,y=m??h,P=t.anchor.endParagraphId??t.anchor.paragraphId,T=e.transact(M=>{let p=bn(M);p.applyPackage(x=>{let k=x.parts.has(i)?x:(()=>{let v=Oa(i,`<w:comments xmlns:w="${pa$1}"/>`);return v?ug(x,i,v,Ia):null})();return k===null?x:Pa(k,cd,i)}),f&&h&&p.applyPackage(x=>Up(x,i,f.id,h)),p.applyPackage(x=>{let k=x.parts.get(i);if(!k)return x;let v=pd(k),A=hb(v.part,v.part.root.id,v.part.root.children.length,[Fp(c,d,r,v.prefix)],{deferValidation:true});return A.ok?kg$1(x,A.part):x}),y!==null&&(p.applyPackage(x=>{let k=x.parts.has(s)?x:(()=>{let v=Oa(s,`<w15:commentsEx xmlns:w15="${kt}"/>`);return v?ug(x,s,v,Na):null})();return k===null?x:Pa(k,Sa,s)}),p.applyPackage(x=>{let k=x.parts.get(s);if(!k)return x;let A=[...Lp(k).has(y.toUpperCase())?[]:[Ra(`${s}#ex-${y}`,y,void 0,false)],Ra(`${s}#ex-${d}`,d,y,false)],O=hb(k,k.root.id,k.root.children.length,A,{deferValidation:true});return O.ok?kg$1(x,O.part):x})),p.applyTo(a,{op:"insertCommentMarker",paragraphId:P,offset:t.anchor.end,commentId:c,marker:"reference"}),p.applyTo(a,{op:"insertCommentMarker",paragraphId:P,offset:t.anchor.end,commentId:c,marker:"end"}),p.applyTo(a,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:c,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return T.ok?{ok:true,commentId:c,change:T.change}:{ok:false,reason:T.reason}}function ba(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 id(e){let t=ba(e);if(!t)return null;let n=vn(t,ua$1,"paraId");return n!==void 0&&Fb(n)?n.toUpperCase():null}function Lp(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===kt&&r.localName==="commentEx"){let o=vn(r,kt,"paraId");o!==void 0&&Fb(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function Sn(e,t){return {kind:"genericExtension",namespaceUri:kt,localName:e,prefix:"w15",value:t}}function $p(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 Bp(e,t,n){let r=[],o=false,a=false;for(let i of e.attributes){if(i.namespaceUri===kt&&i.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:i.namespaceUri,localName:i.localName,...i.prefix===void 0?{}:{prefix:i.prefix},value:n?"1":"0"});continue}i.namespaceUri===kt&&i.localName==="paraIdParent"&&(a=true),r.push(i);}return !a&&t!==void 0&&r.push(Sn("paraIdParent",t)),o||r.push(Sn("done",n?"1":"0")),$p(e,r)}function Ra(e,t,n,r){return {id:e,kind:"generic",namespaceUri:kt,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[Sn("paraId",t),...n===void 0?[]:[Sn("paraIdParent",n)],Sn("done",r?"1":"0")],children:[]}}function Ea(e,t,n){return Hp(e,t,n,bf())}function Hp(e,t,n,r){let o=e.package,a=e.part.name;if(ff$1(o,a)===null)return {ok:false,reason:"unknown-comment"};let s=Hj(o,t,{storyPartName:a},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=jf(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let c=l.used,d=new Map,m=[];for(let P of s.ids){let T=s.records.get(P);if(!T)return {ok:false,reason:"unknown-comment"};if(!ba(T.node))return {ok:false,reason:"unknown-comment"};let p=id(T.node),x=p??Ib(`${T.partName}#done-${P}`,c);p===null&&c.add(x),d.set(P,x);}for(let P of s.ids){let T=s.records.get(P),M=ba(T.node),p=d.get(P),x=id(T.node),k=s.parentCommentIdByChildId.get(P),v=s.parentParaIdByCommentId.get(P)??(k===void 0?void 0:d.get(k)),A=s.commentExByParaId.get(p);m.push({paraId:p,stampParagraph:x===null?M:null,commentsPartName:T.partName,parentParaId:v,existing:A?.node,existingParentParaId:A?.parentParaId,existingDone:A?.done??false});}if(m.length===0)return {ok:false,reason:"unknown-comment"};if(m.every(P=>P.existingDone===n))return {ok:true,changed:false,change:null};let f=s.extendedPartName??ld,h=s.extendedPartName===null,y=e.transact(P=>{bn(P).applyPackage(M=>{let p=rd(M,m,ud);if(p===null)return M;let x=p;if(!x.parts.has(f)){let D=Oa(f,`<w15:commentsEx xmlns:w15="${kt}"/>`);if(!D)return M;let F=ug(x,f,D,Na);x=h?Pa(F,Sa,f):F;}let k=x.parts.get(f);if(!k)return M;let v=new Map,A=[];for(let D of m){let F=D.existingParentParaId??D.parentParaId;D.existing?v.set(D.existing.id,Bp(D.existing,F,n)):A.push(Ra(`${f}#done-${D.paraId}`,D.paraId,F,n));}let O=od(k,v,A);return O.ok?kg$1(x,O.part):M});});return y.ok?{ok:true,changed:true,change:y.change}:{ok:false,reason:y.reason}}function Vp(e,t){let n=va(e,t);return e.parts.has(n)&&ng(e,n)===Ia}function jp(e,t){return va(e,t)}function Gp(e,t){return md(e,t)}var fd={kind:"body"};function zp(e,t,n=fd,r){let o=n.kind==="body"?null:e.resolveStory(n),a=o?.ok?o.store:e.bodyStore(),i=e.currentPackage(),s=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),Va$1(e,()=>{let l=wa(a,t);return l.ok&&(a.restoreHistoryStacks(s),e.replacePackageShell(a.package),e.adoptGroupedPackageUnit(i,r),e.publishStoryWrite(l.change)),l},l=>Wa(l),r)}function Wp(e,t,n,r){let o=e.bodyStore(),a=e.currentPackage(),i=Nk(wf(a),{op:"setCommentResolved"});if(i)return {ok:false,reason:i};let s=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),Va$1(e,()=>{let l=Ea(o,t,n);return !l.ok||!l.changed||(o.restoreHistoryStacks(s),e.replacePackageShell(o.package),e.adoptGroupedPackageUnit(a,r),e.publishStoryWrite(l.change)),l},l=>l.ok&&l.changed,r)}function Kp(e,t,n=fd,r,o){if(t.length===0||Nk(wf(e.currentPackage()),{op:"deleteComments"}))return false;let a=n.kind==="body"?e.bodyStore().part:e.partFor(n);if(!a)return false;let i={storyPartName:a.name,...r===void 0?{}:{noteId:r}},s=e.bodyStore(),l=e.currentPackage(),c=s.checkpoint();return s.graftPackage(()=>e.currentPackage()),Va$1(e,()=>{let d=false,m=false,f=s.transact(h=>{bn(h).applyPackage(P=>{let T=Qc(P,t,i);return T===null?(d=true,P):(m=T!==P,T)});});return d||!f.ok||!m?false:(s.restoreHistoryStacks(c),e.installPackageSnapshot(s.package),e.adoptGroupedPackageUnit(l,o),e.publishStoryWrite(f.change),true)},d=>d,o)}var hd=256*1024,yd=4096;function Xp(e,t){for(let n=db(e.part,t);n;n=db(e.part,n.id)){if(n.kind==="paragraph")return false;if(n.kind.startsWith("revision"))return true}return false}function Ta(e,t,n){let r=t.payload,o=e.part.name,a=n??o;if(r){if(r.data.length>hd)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>yd)return {ok:false,reason:"payload-too-large",detail:"label"}}if(t.revision&&(t.replaceControlId!==void 0||t.replaceUntil!==void 0))return {ok:false,reason:"unsupported",detail:"tracked custom node wrap or rewrite"};let i=t.revision?{revision:t.revision}:{};if(t.replaceControlId!==void 0&&Xp(e,t.replaceControlId))return {ok:false,reason:"unsupported",detail:"custom node inside a pending revision"};let s=new Set(jc$1(e.part.root).map(h=>h.node.id)),l=t.replaceControlId===void 0?[]:xd(e,o,t.replaceControlId),c=null,d,m=e.transact(h=>{if(t.replaceControlId!==void 0){h.apply({op:"removeContentControl",controlId:t.replaceControlId,keepContent:false});for(let T of l)h.applyPackage(M=>jk(M,T.partName,T.nodeId));}let y=t.replaceUntil;if(y!==void 0&&y<=t.offset){c="invalid-range",d="replaceUntil must be past offset";return}if(y!==void 0&&h.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:y}),!r){h.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},...i});return}let P=null;h.applyPackage(T=>{let M=ek(T,a,r.namespaceUri,r.rootLocalName);if(!M.part)return c="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})`,T;if(P=ok(M.part,r.rootLocalName,r.nodeId),!P)return c="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`,T;let p=ik(M.pkg,M.part.partName,{id:r.nodeId,label:r.label,data:r.data});return hk(p,M.part.partName,r.nodeId)?p:(c="store-not-authored",d="the payload node could not be written into the store",T)}),!(c!==null||!P)&&h.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:P,...i});});if(c!==null)return {ok:false,reason:c,...d===void 0?{}:{detail:d}};if(!m.ok)return {ok:false,reason:m.reason,...m.detail===void 0?{}:{detail:m.detail}};let f=Yp(e,s);return {ok:true,change:m.change,...f===void 0?{}:{nodeId:f}}}function Yp(e,t){for(let n of jc$1(e.part.root))if(!t.has(n.node.id))return n.node.id}function xd(e,t,n){let r=jc$1(e.part.root).find(a=>a.node.id===n);if(!r)return [];let o=[];for(let a of ck(e.package,t)){let i=rk(r.node,a.itemId);i!==null&&o.push({partName:a.partName,nodeId:i});}return o}function Ca(e,t){let n=e.part.name,r=xd(e,n,t),o=e.transact(a=>{a.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let i of r)a.applyPackage(s=>jk(s,i.partName,i.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function qp(e,t,n){if(!e.parts.has(t)||n.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let a of n){let i=dk(r,t,a);if(!i)continue;let s=qk(r,i.itemId),l=kk(r,i.partName,s);if(l.pkg===r&&gk(r,i.partName).some(c=>!s.has(c.id)))return {ok:false,reason:`the payload store for ${a} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var gd=new WeakMap;function Jp(e,t){let n=gd.get(e);n||(n=new Map,gd.set(e,n));let r=n.get(t);if(r)return r;let o=ck(e,t).map(a=>({itemId:a.itemId,nodes:new Map(gk(e,a.partName).map(i=>[i.id,i]))}));return n.set(t,o),o}function Qp(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let a=Jp(e,n);if(a.length===0)return r;for(let i of jc$1(o.root))for(let s of a){let l=rk(i.node,s.itemId);if(l===null)continue;let c=s.nodes.get(l);if(c){r.set(i.node.id,{nodeId:l,label:c.label,data:c.data});break}}return r}function Zp(e,t,n){let r=new Map,o=dk(e,t,n);if(!o)return r;for(let a of gk(e,o.partName))r.set(a.id,{label:a.label,data:a.data});return r}var kd={kind:"body"};function Pd(e,t,n,r){let o=t.kind==="body"?null:e.resolveStory(t),a=o?.ok?o.store:e.bodyStore(),i=e.currentPackage(),s=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),Va$1(e,()=>{let l=n(a);return l.ok&&(a.restoreHistoryStacks(s),e.replacePackageShell(a.package),e.adoptGroupedPackageUnit(i,r),e.publishStoryWrite(l.change)),l},l=>Wa(l),r)}function eu(e,t,n=kd,r){return Pd(e,n,o=>Ta(o,t,e.bodyStore().part.name),r)}function tu(e,t,n=kd){return Pd(e,n,r=>Ca(r,t))}var en="http://schemas.openxmlformats.org/package/2006/metadata/core-properties",Lr="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",wn="http://purl.org/dc/elements/1.1/",Ma="application/vnd.openxmlformats-package.core-properties+xml",Da={author:[wn,"creator"],title:[wn,"title"],subject:[wn,"subject"],comments:[wn,"description"],keywords:[en,"keywords"],category:[en,"category"]},Od={...Da,lastAuthor:[en,"lastModifiedBy"]},cP=Object.keys(Od);function $r(e){let t=(e.relationships.get("/")??[]).find(r=>r.type===Lr);if(!t||t.targetMode!=="Internal")return null;let n=E("/",t.rawTarget);return n.ok?e.parts.get(n.partName)??null:null}function dP(e,t){let n=$r(e),[r,o]=Od[t],a=n?.root.children.find(i=>i.kind!=="textValue"&&i.namespaceUri===r&&i.localName===o);return a&&a.kind!=="textValue"?a.children.map(i=>i.kind==="textValue"?i.value:"").join(""):""}function nu(e){if(!e||typeof e!="object"||Array.isArray(e))return false;let t=Object.entries(e);return t.length>0&&t.every(([n,r])=>Object.hasOwn(Da,n)&&typeof r=="string"&&r.length<=4096&&X(r))}function mP(e,t){if(!nu(t)||(e.relationships.get("/")??[]).filter(s=>s.type===Lr).length>1)return null;let n=$r(e);if(n&&(n.contentType!==Ma||n.root.namespaceUri!==en||n.root.localName!=="coreProperties")||!n&&(e.relationships.get("/")??[]).some(s=>s.type===Lr))return null;let r=n?.name??"/docProps/core.xml";if(!n&&(e.parts.has(r)||e.partBytes.has(r)))return null;let o=Pa$1(`<cp:coreProperties xmlns:cp="${en}" xmlns:dc="${wn}">${Object.entries(t).map(([s,l])=>{let[c,d]=Da[s],m=c===en?"cp":"dc";return `<${m}:${d}>${V(l)}</${m}:${d}>`}).join("")}</cp:coreProperties>`,{name:r,contentType:Ma});if(!o.ok)return null;if(n){let s=n,l=ab(n),c=d=>d.kind==="textValue"?{...d,id:l()}:{...d,id:l(),children:d.children.map(c)};for(let d of o.part.root.children){if(d.kind==="textValue")continue;let m=s.root.children.filter(y=>y.kind!=="textValue"&&y.namespaceUri===d.namespaceUri&&y.localName===d.localName);if(m.length>1)return null;let f=m[0],h;if(f&&f.kind!=="textValue"){if(f.children.some(M=>M.kind!=="textValue"))return null;let y=f.children.length===1&&f.children[0]?.kind==="textValue"?f.children[0]:null,P=d.children.find(M=>M.kind==="textValue"),T=y&&P?.kind==="textValue"?[{...y,value:P.value}]:d.children.map(c);h=ib(s,f.id,{...f,children:T});}else {let y=Array.from(s.root.children);y.push(c(d)),h=gb(s,s.root.id,y);}if(!h.ok)return null;s=h.part;}return kg$1(e,s)}let a=ug(e,r,o.part.root,Ma);if(!a.parts.has(r))return null;let i=tg(a,"/",Lr,r.slice(1));return i.ok?i.pkg:null}var ru="{6C3C8BC8-F283-45AE-878A-BAB7291924A1}",ou="{6668398D-A668-4E3E-A5EB-62B293D839F1}",au="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",iu=1024,su=32,lu=1e5,cu=8192,En=32768,du=1e4;function mu(e){let t=new Map;if(e===void 0||e.trim()==="")return t;if(e.length>cu)return null;let n=/xmlns:([^\s=]+)\s*=\s*(?:'([^']*)'|"([^"]*)")/g,r="";for(let o of e.matchAll(n)){let a=o[1];if(!ia$1(a))return null;t.set(a,o[2]??o[3]??""),r+=o[0];}return e.replace(n,"").trim()!==""||r===""?null:t}function bd(e,t){let n=e.indexOf(":");if(n===-1)return ia$1(e)?{namespaceUri:"",localName:e}:null;let r=e.slice(0,n),o=e.slice(n+1),a=t.get(r);return a===void 0||!ia$1(o)?null:{namespaceUri:a,localName:o}}function pu(e,t){if(!e||e.length>iu||!e.startsWith("/"))return null;let n=e.slice(1).split("/");if(n.length===0||n.length>su)return null;let r=[];for(let[o,a]of n.entries()){let i=o===n.length-1,s=a.trim();if(s==="text()"){if(!i||r.length===0)return null;r.push({kind:"text"});continue}if(s.startsWith("@")){let m=i&&r.length>0?bd(s.slice(1),t):null;if(!m)return null;r.push({kind:"attribute",...m});continue}let l=/^([^[\]]+)(?:\[(\d{1,6})\])?$/.exec(s);if(!l)return null;let c=bd(l[1],t),d=l[2]===void 0?1:Number(l[2]);if(!c||d<1||d>lu)return null;r.push({kind:"element",...c,position:d});}return r}function uu(e){return e.kind!=="textValue"}function fu(e){let t="",n=0,r=[e];for(;r.length>0;){let o=r.pop();if(++n>du)return null;if(o.kind==="textValue"){if(t+=o.value,t.length>En)return null;continue}for(let a=o.children.length-1;a>=0;a-=1)r.push(o.children[a]);}return t}function gu(e,t){let n=t[0];if(n?.kind!=="element"||n.position!==1||e.namespaceUri!==n.namespaceUri||e.localName!==n.localName)return null;let r=e;for(let o of t.slice(1)){if(o.kind==="attribute"){let s=r.attributes.find(l=>l.localName===o.localName&&l.namespaceUri===o.namespaceUri);return !s||s.value.length>En?null:s.value}if(o.kind==="text"){let s="";for(let l of r.children)l.kind==="textValue"&&(s+=l.value);return s.length>En?null:s}let a=0,i=null;for(let s of r.children)if(uu(s)&&!(s.localName!==o.localName||s.namespaceUri!==o.namespaceUri)&&(a+=1,a===o.position)){i=s;break}if(!i)return null;r=i;}return fu(r)}function Rd(e){let t=new Map;for(let i of ck(e,e.mainDocumentPart)){let s=e.parts.get(i.partName),l=i.itemId.toUpperCase();s&&!t.has(l)&&t.set(l,s.root);}let n=$r(e);n&&t.set(ru,n.root);let r=(e.relationships.get("/")??[]).find(i=>i.type===au&&i.targetMode!=="External"),o=r?E("/",r.rawTarget):null,a=o?.ok?e.parts.get(o.partName):void 0;return a&&t.set(ou,a.root),t}function Id(e,t){let n=t.storeItemID?.trim().toUpperCase(),r=n?e.get(n):void 0;if(!r)return null;let o=mu(t.prefixMappings);if(!o)return null;let a=pu(t.xpath,o);return a?gu(r,a):null}var hu=96,Br="http://schemas.openxmlformats.org/officeDocument/2006/relationships",yu=new Set([`${Br}/header`,`${Br}/footer`,`${Br}/footnotes`,`${Br}/endnotes`]);function Nd(e){let t=[],n=[{node:e,depth:0}];for(;n.length>0;){let{node:r,depth:o}=n.pop();if(!(r.kind==="textValue"||o>hu)){if(zh(r)&&hc$1(r).dataBinding){t.push(r);continue}for(let a=r.children.length-1;a>=0;a-=1)n.push({node:r.children[a],depth:o+1});}}return t}function xu(e,t){let n=t.replace(/\r\n?/g,`
2
+ `);switch(e.type){case "plainText":return {kind:"text",text:n.replaceAll(`
3
+ `,e.multiLine?oj:"")};case "comboBox":{let r=e.listItems.find(o=>o.value===n);return r?{kind:"listItem",value:r.value}:{kind:"text",text:n}}case "dropDownList":return n===""?{kind:"text",text:n}:{kind:"listItem",value:n};case "checkbox":return n.trim()===""?null:{kind:"text",text:n};case "date":{if(n.trim()==="")return {kind:"text",text:""};let r=/^\s*(\d{4}-\d{2}-\d{2})(?:[T\s]|$)/.exec(n);return r?{kind:"date",iso:r[1]}:null}default:return null}}function ku(e,t){if(t.length>En)return null;let n=xu(e,t);if(!n)return null;if(n.kind==="text"&&n.text==="")return e.placeholderDocPart!==void 0?{text:hm$1(e.type),showingPlaceholder:true}:{text:"",showingPlaceholder:false};if(e.type==="checkbox"){let o=Pu(n.kind==="text"?n.text:"");if(o===null)return null;let a=pm$1(e,{kind:"checkbox",checked:o});return typeof a=="string"?null:a}let r=pm$1(e,n);return typeof r=="string"?null:r}function Pu(e){let t=e.trim().toLowerCase();return t==="true"||t==="1"?true:t==="false"||t==="0"?false:null}function Ou(e,t,n){return n.showingPlaceholder?t.showingPlaceholder:t.showingPlaceholder?false:n.fullDate!==void 0?t.date?.fullDate?.slice(0,10)===n.fullDate.slice(0,10):n.checked!==void 0&&t.checkbox?.checked!==n.checked||n.lastValue!==void 0&&t.lastValue!==void 0&&t.lastValue!==n.lastValue?false:lc$1(e,oj)===n.text}function bu(e,t,n,r,o){let a=e,i=hc$1(n),s=ku(i,r);if(!s||Ou(n,i,s))return a;let l=Bh(n),c=Wk(t,n.id),d=s.showingPlaceholder?[]:s.symbol?Xk(l,s.symbol,s.text,o,c):rm$1(l,s.text,o,c);if(!d||!l)return a;let m=Ah(n),f=qm$1(m,{showingPlaceholder:s.showingPlaceholder,...s.lastValue===void 0?{}:{lastValue:s.lastValue},...s.fullDate===void 0?{}:{fullDate:s.fullDate},...s.checked===void 0?{}:{checked:s.checked}},o),h={...n,children:n.children.map(P=>P.id===l.id?{...l,children:d}:P.id===m?.id?f:P)},y=ib(a,n.id,h);return y.ok?y.part:a}function Ru(e,t,n=Nd(e.root)){if(t.size===0||n.length===0)return e;let r=e,o=null;for(let a of n){let i=hc$1(a).dataBinding,s=Id(t,i);s!==null&&(o??=ab(e,"paste"),r=bu(r,e,a,s,o));}return r}function Aa(e){let t=[e.mainDocumentPart];for(let a of e.relationships.get(e.mainDocumentPart)??[]){if(!yu.has(a.type)||a.targetMode==="External")continue;let i=E(e.mainDocumentPart,a.rawTarget);i.ok&&!t.includes(i.partName)&&t.push(i.partName);}let n=[];for(let a of t){let i=e.parts.get(a),s=i?Nd(i.root):[];i&&s.length>0&&n.push({part:i,controls:s});}if(n.length===0)return e;let r=Rd(e);if(r.size===0)return e;let o=e;for(let{part:a,controls:i}of n){let s=Ru(a,r,i);s!==a&&(o=kg$1(o,s));}return o}var Iu=256,Nu=2e3,Sd=/[\p{L}\p{N}_]/u;function _a(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],a=o.toLowerCase();n+=a.length===1?a:o;}return n}function vd(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&Sd.test(r)||o!==void 0&&Sd.test(o))}function wd(e){return typeof e=="string"&&e.length>0&&e.length<=256}function Su(e,t,n,r={}){let o={matches:[],truncated:false};if(!wd(t)||e.length===0||n<=0)return o;let a=r.matchCase===true,i=r.wholeWord===true,s=a?t:_a(t),l=a?e:_a(e),c=Math.max(0,r.from??0),d=Math.min(e.length,r.to??e.length),m=[],f=l.indexOf(s,c);for(;f>=0;){let h=f+s.length;if(h>d)return {matches:m,truncated:false};if(!i||vd(e,f,h)){if(m.length>=n)return {matches:m,truncated:true};m.push({start:f,length:s.length});}f=l.indexOf(s,h);}return {matches:m,truncated:false}}var vu=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),wu=96;function Ua(e,t){return e.kind!=="textValue"&&e.namespaceUri===pa$1&&e.localName===t}function Eu(e){return e.kind==="textValue"&&e.value.trim()===""}function Tu(e){let t=[],n=(r,o,a)=>{if(r.kind==="textValue"||a>wu)return;if(zh(r)){let s=Bh(r),l=hc$1(r);if(s&&l&&s.children.every(Eu)&&vu.has(l.type)){t.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let i=o||r.kind==="paragraph"||Ua(r,"p");for(let s of r.children)n(s,i,a+1);};return n(e,false,0),t}function Cu(e){return nm$1(e,"rPr",{kind:"runProperties",children:[nm$1(e,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function Mu(e){let t=e.find(r=>r.kind==="paragraph"||Ua(r,"p"));if(!t||t.kind==="textValue")return null;let n=t.children.filter(r=>r.kind!=="paragraphProperties"&&!Ua(r,"pPr"));return n.length>0?n:null}function Fa(e,t){let n=Tu(t.root);if(n.length===0)return t;let r=null,o=c=>{if(c!==void 0)return r??=Ti(e),r.find(d=>d.name===c)},a=ab(t,"paste"),i=new Set(Jb(t.root)),s={value:0},l=t;for(let[c,d]of n.entries()){let m=o(d.docPart),f=Lb(t,d.control),h=null;if(m){let p=m.blocks.map((x,k)=>Nb(Ih(x,a),i,Tb(`${d.control.id}:placeholder:${c}:${k}`),s,f));h=d.inline?Mu(p):p;}if(!h){let p=om$1(a,hm$1(d.kind),Cu(a));h=d.inline?[p]:[Nb(nm$1(a,"p",{kind:"paragraph",children:[p]}),i,Tb(`${d.control.id}:placeholder:${c}`),s,f)];}let y=qm$1(Ah(d.control),{showingPlaceholder:true},a),P={...d.content,children:h},T=d.control.children.map(p=>p.id===d.content.id?P:p.kind!=="textValue"&&p.localName==="sdtPr"?y:p),M=gb(l,d.control.id,T);M.ok&&(l=M.part);}return l}function Ed(e,t,n){let r=t.filter(i=>i.node.localName==="tblGridChange"&&n.has(i.node.id));if(!r.length)return new Set;let o=new Map;for(let i of t){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(i.node.localName))continue;let s=i.parent;for(;s&&s.kind!=="table";)s=db(e,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(i.node.id),o.set(s.id,l);}let a=new Set;for(let i of r){let s=i.parent&&db(e,i.parent.id),l=s&&o.get(s.id);l?.some(c=>n.has(c))&&l.some(c=>!n.has(c))&&a.add(i.node.id);}return a}function Td(e){if(e.kind==="textValue")return;let t=r=>e.attributes.find(o=>o.namespaceUri===pa$1&&o.localName===r)?.value,n=t("author");return n===void 0?void 0:`${n}\0${t("date")??""}`}function Du(e){let t=[],n=r=>{if(r.kind!=="textValue"){if(r.kind==="paragraph"){let o=[],a=[],i=s=>{if(s.kind!=="textValue"){if(s.localName==="txbxContent")return n(s);a.push(s);for(let l of s.children)i(l);}};for(let s of r.children){if(s.localName!=="pPr"){i(s);continue}for(let l of s.children)if(l.kind!=="textValue"&&l.localName==="rPr")for(let c of l.children)c.kind!=="textValue"&&c.localName==="moveTo"&&o.push(c);}t.push({marks:o,inline:a});return}for(let o of r.children)n(o);}};return n(e),t}function Cd(e,t){let n=[];if(t.size===0)return n;for(let r of Du(e))for(let o of r.marks){if(!t.has(o.id))continue;let a=Td(o),i=r.inline.filter(s=>t.has(s.id)&&Td(s)===a);i.length>0&&n.push([o.id,...i.map(s=>s.id)]);}return n}var Au=new Set(["tblPrChange","tblGridChange","tblPrExChange","trPrChange","tcPrChange"]);function _u(e,t,n,r,o){let a=Md(e,t,n,r,o);for(let l=0;n&&l<3&&a.partial?.length&&a.result.skipped.some(c=>c.reason==="incomplete-group");l++)n=[...new Set([...n,...a.partial])],a=Md(e,t,n,r,o);let{partial:i,...s}=a;return s}function Md(e,t,n,r,o){let a=r??e.root,i=a.kind==="textValue"?e:{...e,root:a},s=Yl$1(i),l=n===void 0?Il$1(i):[],c=[...$k(i,l),...l.filter(g=>g.node.localName==="numberingChange").map(g=>g.node.id)],d=c.length?[{op:"acceptAllRevisions",siteNodeIds:c,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||s.length===0)return {ops:d,result:{resolved:[],skipped:[...new Set(n??[])].map(g=>({key:g,reason:"unknown-revision"})),remaining:s.length}};let m=new Set(n??s.map(gl$1)),f=new Map(s.map(g=>[gl$1(g),g])),h=new Set;for(let g of m){let u=f.get(g);if(u)for(let E of fl$1(u))h.add(E);}let y=Il$1(i),P=cl$1(a,y,h,t);for(let g of P.selected)h.add(g);let T=[...sl$1(a).values()],M=Kl$1(a,y),p=g=>{let u=cb(i,g);return u&&u.kind!=="textValue"?Bl$1(u,"author"):void 0},x=al$1(i,y),k=new Set(s.map(fl$1).filter(g=>g.some(u=>x.has(u))).flat()),v=new Set(h),A=new Set([...v].map(p)),O=Fl$1(i,y,t).filter(g=>{let u=g.slice(0,-1),E=p(g.at(-1));return !u.every(L=>p(L)===E)&&!u.some(L=>v.has(L))?false:o?.explicit?k.has(g.at(-1))&&!u.some(L=>v.has(L))?false:g.some(L=>v.has(L))||u.every(L=>A.has(p(L))):true}),D=[...y.some(g=>g.node.localName==="cellMerge")?Gl$1(i,t):[],...Cd(a,M),...O,...bl$1(i,y)];if(o?.explicit){let g=[...T.map(u=>u.wrappers.map(E=>E.id)),...D,...D.length?s.map(fl$1).filter(u=>!u.some(E=>k.has(E))):[]];for(let u=true,E=0;u&&E<=g.length;E++){u=false;for(let L of g)if(L.some(Q=>h.has(Q)))for(let Q of L)h.has(Q)||(u=!!h.add(Q));}}for(let g of s){let u=fl$1(g);u.length&&u.every(E=>h.has(E))&&m.add(gl$1(g));}let F=new Map(y.map((g,u)=>[g.node.id,u])),w=y.map((g,u)=>u),N=g=>{for(;w[g]!==g;)w[g]=w[w[g]],g=w[g];return g},S=(g,u)=>{w[N(u)]=N(g);};for(let g of P.dependencies){let u=g.flatMap(E=>F.has(E)?[F.get(E)]:[]);for(let E of u)S(u[0],E);}let I=new Map;for(let g of s){let u=fl$1(g).flatMap(E=>{let L=F.get(E);return L===void 0?[]:[L]});for(let E of u)S(u[0],E);}let _=y.filter(g=>h.has(g.node.id)),q=new Set(Cl$1(e,_,t).keys()),ee=new Map,K=new Set,ae=new Map,B=(g,u)=>{K.add(g),ae.set(g,u);},V=new Set(ul$1(e,y,t)),z=g=>!g.refused&&!V.has(g.node.id);for(let[g,u]of y.entries()){if(h.has(u.node.id)&&z(u)&&!u.paragraphMark&&!M.has(u.node.id)&&(t==="accept"?u.node.kind==="revisionDelete"||u.node.kind==="revisionMoveFrom":u.node.kind==="revisionInsert"||u.node.kind==="revisionMoveTo")&&B(u.node.id,g),t==="reject"&&u.propertyChange&&u.parent&&h.has(u.node.id))for(let L of u.parent.children)Yk(u.node.localName,L)||(I.set(L.id,g),L.id!==u.node.id&&z(u)&&B(L.id,g));let E=t==="accept"?u.node.localName==="del"||u.node.localName==="moveFrom":u.node.localName==="ins"||u.node.localName==="moveTo";if(u.paragraphMark&&u.parent&&E&&!M.has(u.node.id)&&h.has(u.node.id)){let L=db(e,u.parent.id),Q=L&&db(e,L.id),fe=Q&&db(e,Q.id);if(L&&Q&&fe){let ge=ee.get(fe.id);ge||(ge=yl$1(fe.children,q),ee.set(fe.id,ge)),ge.has(Q.id)&&(I.set(L.id,g),z(u)&&B(L.id,g));}}if(h.has(u.node.id)&&Dl$1(e,u,t)){let L=Dl$1(e,u,t);L&&!u.refused&&(I.set(L.id,g),z(u)&&B(L.id,g));}}for(let[g,u]of El$1(e,_,t)){let E=cb(e,g),L=F.get(u[0]);if(!(E?.kind!=="tableCell"||L===void 0)){for(let Q of E.children)if(Q.localName==="tcPr")for(let fe of Q.children)fe.kind==="textValue"||Al$1.has(fe.localName)||I.set(fe.id,L);}}let ne=em$1(e),ie=g=>{for(let u=db(e,y[g].node.id);u;u=db(e,u.id))if(ne.has(u.id))return true;return false},Ne=new Map,Xe=g=>{let u=Ne.get(g);return u===void 0&&(u=fm$1(e,[y[g].node.id],t)!==null,Ne.set(g,u)),u},Ce=(g,u)=>ne.size>0&&["revisionInsert","revisionDelete"].includes(y[u].node.kind)&&["revisionInsert","revisionDelete"].includes(y[g].node.kind)&&ie(u)&&Xe(g)&&!Xe(u),Ve=xl$1(i,[...F.keys(),...I.keys()]),J=(g,u)=>{if(!Ve.has(g.id))return;let E=F.get(g.id),L=I.get(g.id);E!==void 0&&L!==void 0&&S(L,E);let Q=E??L,fe=o?.explicit===true&&Q!==void 0&&(E===void 0||L===void 0||L===E)&&y[Q].node.localName==="rPrChange"||Q!==void 0&&u!==void 0&&Ce(u,Q);Q!==void 0&&u!==void 0&&!fe&&S(u,Q);let ge=Q??u;if(g.kind!=="textValue")for(let je of g.children)J(je,ge);};J(a);for(let g of T){let u=g.wrappers.flatMap(E=>{let L=F.get(E.id);return L===void 0?[]:[L]});for(let E of u)S(u[0],E);}for(let g of D){let u=g.flatMap(E=>{let L=F.get(E);return L===void 0?[]:[L]});for(let E of u)S(u[0],E);}let Me=new Map,ue=()=>{Me.clear();for(let[g,u]of y.entries()){let E=N(g),L=Me.get(E)??[];L.push(u),Me.set(E,L);}};ue();let At=g=>g.kind==="revisionInsert"||g.kind==="revisionDelete"||g.kind==="revisionMoveFrom"||g.kind==="revisionMoveTo",dt=g=>{if(!g||g.kind==="textValue"||!At(g))return false;let u=g.children.filter(E=>E.kind!=="textValue"&&!tl$1(E));return u.length>0&&u.every(E=>K.has(E.id))},Pe=g=>{if(!o?.explicit||!K.size)return false;for(let u=db(e,g);u;u=db(e,u.id))if(K.has(u.id))return true;return dt(cb(e,g))},tt=new Set([...T.map(g=>g.wrappers.map(u=>u.id)),...D,...P.dependencies,...s.map(fl$1)].filter(g=>g.some(u=>h.has(u)||Pe(u))).flat()),nn=g=>{if(tt.has(g.node.id)||I.has(g.node.id))return false;for(let u=db(e,g.node.id);u;u=db(e,u.id))if(I.has(u.id)||K.has(u.id))return false;return !dt(g.node)},Oe=new Map,b=new Map,U=dm$1(e),$=new Map,j=g=>{if(!U)return null;let u=g.map(Q=>Q.node.id),E=u.join("\0"),L=$.get(E);return L===void 0&&(L=fm$1(e,u,t),$.set(E,L)),L},X=()=>{Oe.clear(),b.clear();for(let[g,u]of Me){let E=u.some(ge=>h.has(ge.node.id)),L=u.find(ge=>ge.refused),Q=t==="reject"&&u.some(ge=>ge.propertyChange&&_k(ge.node)===null),fe=!L&&!Q&&j(u);if(L||Q||fe)Oe.set(g,"unsupported-revision"),b.set(g,L?.refusal??(fe||"unrecorded-properties"));else {let ge=u.find(je=>!h.has(je.node.id)&&!Pe(je.node.id)&&!(o?.explicit&&k.has(je.node.id))&&!(E&&nn(je)));ge&&(Oe.set(g,"incomplete-group"),b.set(g,Z(ge)));}}},Z=g=>{if(tt.has(g.node.id))return "paired-change";for(let E=db(e,g.node.id);E;E=db(e,E.id)){if(K.has(E.id))return "removed-content";if(I.has(E.id))return "replaced-properties"}return dt(g.node)?"emptied-change":[...h].some(E=>{for(let L=db(e,E);L;L=db(e,L.id))if(L.id===g.node.id)return true;return false})?"enclosing-change":"grouped-change"},de=()=>{for(let g of s)if(g.readOnly)for(let u of fl$1(g)){let E=F.get(u);E!==void 0&&(Oe.set(N(E),"unsupported-revision"),b.has(N(E))||b.set(N(E),"read-only"));}},we=()=>{for(;;){X(),de();let g=[...ae].filter(([,u])=>Oe.get(N(u))==="unsupported-revision");if(!g.length)return;for(let[u]of g)K.delete(u),ae.delete(u);}};we();let xe=y.filter((g,u)=>h.has(g.node.id)&&!Oe.has(N(u))),De=false,Ye=Cl$1(e,xe,t);for(let[g,u]of Ye){if(I.has(g))continue;let E=F.get(u[0]);E!==void 0&&(I.set(g,E),B(g,E),De=true);}De&&(J(a),ue(),we());let Ae=[],_e=[],le=new Set,me=new Set(V);for(let g of me){let u=db(e,g);for(;u;){if(Ye.has(u.id)){me.delete(g);break}u=db(e,u.id);}}for(let g of m){let u=f.get(g);if(!u){_e.push({key:g,reason:"unknown-revision"});continue}let E={key:g,author:u.author,partName:e.name,revisionKind:u.revisionKind,...u.formattingKind?{formattingKind:u.formattingKind}:{}},L=fl$1(u),Q,fe;for(let ge of L){let je=F.get(ge);if(Q=je===void 0?"incomplete-group":Oe.get(N(je)),fe=je===void 0?void 0:b.get(N(je)),Q)break}if(L.length||(Q="unsupported-revision",fe="no-sites"),Q)_e.push({key:g,reason:Q,revision:E,...fe?{detail:fe}:{}});else {L.some(ge=>me.has(ge))?_e.push({key:g,reason:"retained-structure",revision:E,detail:"nested-table"}):Ae.push(E);for(let ge of L)me.has(ge)||le.add(ge);}}let qe=Ed(e,y,le),mt=new Set;for(let g of s){let u=fl$1(g);if(g.formattingKind!=="tblGridChange"&&u.length>1)for(let E of u)qe.has(E)&&mt.add(E);}let R=[...le].filter(g=>!P.implicit.has(g)&&!mt.has(g));for(let[g,u]of ae)Oe.has(N(u))&&(K.delete(g),ae.delete(g));let G=o?.explicit?s.filter(g=>{if(m.has(gl$1(g)))return false;let u=fl$1(g);return u.length>0&&u.every(Pe)}):[],W=g=>{for(let u=db(e,g);u;u=db(e,u.id))if(q.has(u.id))return true;return Pe(g)},re=g=>{let u=F.get(g);return u!==void 0&&Au.has(y[u].node.localName)},Y=o?.explicit?s.filter(g=>{if(m.has(gl$1(g)))return false;let u=fl$1(g),E=u.filter(L=>!W(L));return E.length<u.length&&E.length>0&&E.every(re)&&!u.some(L=>k.has(L))}):[];for(let g of G)Ae.push({key:gl$1(g),author:g.author,partName:e.name,revisionKind:g.revisionKind,...g.formattingKind?{formattingKind:g.formattingKind}:{}});let se=s.length-Ae.length;if(se>0&&R.length&&o?.countRemaining!==false){let g={...e,root:{...e.root}},u=Ll$1(g,t,void 0,{siteNodeIds:R,...r?{scopeRootId:r.id}:{}});if(u.ok&&u.part){let E=r?cb(u.part,r.id):u.part.root;se=E&&E.kind!=="textValue"?Yl$1({...u.part,root:E}).length:0;}}return {...G.length?{swept:G.map(gl$1)}:{},...Y.length?{partial:Y.map(gl$1)}:{},ops:le.size?[...d,{op:t==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:R,...r?{scopeRootId:r.id}:{}}]:d,result:{resolved:Ae,skipped:_e,remaining:se}}}var Pt=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",fontTable:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",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(a=>a.type===n);if(o){let a=N(o);if(a.mode==="Internal"&&a.target.ok){let i=e.parts.get(a.target.partName);if(i)return i}}return e.parts.get(r)}function Gb(e){let t=gg(e);if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let n=Aa(t.package),r=n.parts.get(n.mainDocumentPart);if(!r)return {ok:false,reason:"no-main-document-tree",detail:n.mainDocumentPart};let o=new Nn(n,Fa(n,Ob(r)));return {ok:true,view:Uu(o)}}function Uu(e){let t=()=>e.currentPackage(),n=()=>e.bodyStore().part,r=(c,d)=>La(t(),t().mainDocumentPart,c,d)?.root??null,o=Object.freeze(je(null)),a=null,i=Vj,s=null;return Object.freeze({part:n,currentPackage:t,packageRevision:()=>e.packageRevision,stylesRoot:()=>r(Pt.styles,"/word/styles.xml"),numberingRoot:()=>r(Pt.numbering,"/word/numbering.xml"),settingsRoot:()=>r(Pt.settings,"/word/settings.xml"),documentThemeFonts(){let c=t();return a!==c&&(o=Object.freeze(je(r(Pt.theme,"/word/theme/theme1.xml"),r(Pt.settings,"/word/settings.xml"),r(Pt.fontTable,"/word/fontTable.xml"))),a=c),o},documentProperties(){let c=t();if(s!==c){let d=La(c,"/",Pt.coreProperties,"/docProps/core.xml"),m=La(c,"/",Pt.extendedProperties,"/docProps/app.xml");i=Wj(d?.root??null,m?.root??null),s=c;}return i},headerFooterPartsBySection:()=>of$1(t()),headerFooterResolutionBySection:()=>nf$1(t()),relationshipTarget:c=>Yi(t(),n().name,c)})}var Fu=new Set(["unsupported-effect","renderer-required","unverified-3d","saved-fallback","inspection-limit","projection-diagnostic"]);function Dd(e,t){return e==="placeholder"?"unrendered":e==="fallback"||t.some(n=>Fu.has(n.code)&&!n.detail.startsWith("wrap-polygon"))?"partial":"native"}var Lu=new Set(["alphaModFix","biLevel","grayscl","lum","extLst"]),$u=new Set(["glow","innerShdw","reflection","softEdge"]),Bu=new Set(["blur","fillOverlay","prstShdw"]),Ad="http://schemas.openxmlformats.org/markup-compatibility/2006",Hu="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function et(e,t,n){return Object.freeze({code:t,nodeId:e.id,namespaceUri:e.namespaceUri,localName:e.localName,detail:n})}function tn(e,t){let n=[{node:e,fallback:false}],r=0;for(;n.length&&++r<=4096;){let o=n.pop();if(o.node.id===t)return {...o,complete:true};for(let a of o.node.children)a.kind!=="textValue"&&n.push({node:a,fallback:o.fallback||a.namespaceUri===Ad&&a.localName==="Fallback"});}return {node:e,fallback:false,complete:n.length===0}}function _d(e,t){let n=tn(e,t),r=[];n.complete||r.push(et(e,"inspection-limit","drawing-selection-budget")),n.fallback&&r.push(et(e,"saved-fallback","mc:Fallback"));let o=[{node:n.node,parent:"",depth:0}],a=0;for(;o.length;){let{node:i,parent:s,depth:l}=o.pop();if(++a>4096||l>64){r.push(et(i,"inspection-limit","drawing-source-budget"));break}if(!(i.namespaceUri===Hu&&i.localName==="txbxContent")&&!(i.namespaceUri===Ad&&i.localName==="AlternateContent")){i.namespaceUri===va$1?i.localName==="effectDag"||s==="blip"&&!Lu.has(i.localName)||s==="effectLst"&&Bu.has(i.localName)?r.push(et(i,"unsupported-effect",`a:${i.localName}`)):s==="effectLst"&&$u.has(i.localName)&&!Yd$1().effects?r.push(et(i,"renderer-required",`a:${i.localName}`)):(i.localName==="scene3d"||i.localName==="sp3d")&&r.push(et(i,"unverified-3d",`a:${i.localName}`)):i.namespaceUri==="http://schemas.microsoft.com/office/drawing/2010/main"&&i.localName==="imgProps"&&r.push(et(i,"unsupported-effect","a14:imgProps"));for(let c=i.children.length-1;c>=0;c--){let d=i.children[c];d.kind!=="textValue"&&o.push({node:d,parent:i.namespaceUri===va$1?i.localName:"",depth:l+1});}}}return Object.freeze(r)}var Vu=new Map([["http://schemas.openxmlformats.org/drawingml/2006/picture","picture"],["http://schemas.openxmlformats.org/drawingml/2006/chart","chart"],["http://schemas.microsoft.com/office/drawing/2014/chartex","chart"],["http://schemas.openxmlformats.org/drawingml/2006/diagram","diagram"],["http://schemas.microsoft.com/office/word/2010/wordprocessingGroup","group"],["http://schemas.microsoft.com/office/word/2010/wordprocessingShape","textbox"],["http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas","canvas"]]),ju="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Gu="urn:schemas-microsoft-com:vml";function zu(e){return Vu.get(e)}function $a(e){let t=[e],n=0,r=false;for(;t.length&&++n<=4096;){let o=t.pop();if(o.namespaceUri===va$1&&o.localName==="graphicData"){let a=oa$1(o.attributes,"uri");return a&&zu(a)||"graphic"}if(!(o.namespaceUri===ju&&o.localName==="txbxContent")){r||=o.namespaceUri===Gu;for(let a=o.children.length-1;a>=0;a--){let i=o.children[a];i.kind!=="textValue"&&t.push(i);}}}return r?"shape":"graphic"}function Qb(e,t){return $a(tn(e,t).node)}var Tn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Wu="http://schemas.openxmlformats.org/markup-compatibility/2006",Ku=new Set(["document","hdr","ftr","footnotes","endnotes"]),Ud=new Set(["drawing","pict","object"]);function Xu(e,t){return e?e.hidden||e.footprintOnly?"hidden":e.chartSummary?.shownAs==="fallback"||t?"fallback":e.picture||e.vectorShape||e.groupPicture||e.textboxStory||e.textArt||e.legacyGraphic||e.horizontalRule||e.groupTextboxes?.length?"projected":"placeholder":"unplaced"}function Yu(e){let t=oe$1(e),n=[],r=true,o=0;for(let a of e.parts.values()){if(a.root.namespaceUri!==Tn||!Ku.has(a.root.localName))continue;let i=new Map(Te(a,{stylesPart:ld$1(e),resolveRelationship:Ne(e,a.name),resolveSchemeColor:t.resolveSchemeColor,resolveStyleMatrixReference:t.resolveStyleMatrixReference,resolveDiagramParts:Fe(e,a.name)}).map(c=>[`${a.name}\0${c.drawingNodeId}`,c])),s=[{node:a.root,depth:0}],l=new Map;for(;s.length;){let{node:c,depth:d}=s.pop();if(++o>1e6||d>128){r=false;break}let m=c.namespaceUri===Tn&&Ud.has(c.localName),f=c.namespaceUri===Wu&&c.localName==="AlternateContent";if(m||f){let h=i.get(`${a.name}\0${c.id}`),y=m,P=[c],T=0;for(;P.length;){let M=P.pop();if(++T>4096||++o>1e6){r=false;break}if(!(M.namespaceUri===Tn&&M.localName==="txbxContent")){y||=M.namespaceUri===Tn&&Ud.has(M.localName),h??=i.get(`${a.name}\0${M.id}`);for(let p of M.children)p.kind!=="textValue"&&P.push(p);}}if(y&&l.set(c,h),h){let p=[tn(c,h.drawingNodeId).node],x=0;for(;p.length&&++x<=4096&&++o<=1e6;){let k=p.pop();if(k.namespaceUri===Tn&&k.localName==="txbxContent"){s.push({node:k,depth:d+1});continue}for(let v of k.children)v.kind!=="textValue"&&p.push(v);}p.length&&(r=false);}continue}for(let h=c.children.length-1;h>=0;h--){let y=c.children[h];y.kind!=="textValue"&&s.push({node:y,depth:d+1});}}for(let[c,d]of l){let m=tn(c,d?.drawingNodeId??c.id),f=[..._d(c,d?.drawingNodeId??c.id)];d||f.push(et(c,"unplaced-drawing","no-layout-projection"));let h=Xu(d,m.fallback);for(let y of d?.diagnostics??[])y.code==="unsupported-graphic"&&h!=="placeholder"||f.push(Object.freeze({...et(m.node,"projection-diagnostic",y.code),nodeId:y.nodeId}));f.some(y=>y.code==="inspection-limit")&&(r=false),n.push(Object.freeze({ownerPartName:a.name,nodeId:c.id,drawingNodeId:d?.drawingNodeId??null,state:h,support:Dd(h==="placeholder"||h==="unplaced"?"placeholder":h==="fallback"?"fallback":"rendered",f),graphicKind:$a(m.node),source:c,issues:Object.freeze(f)}));}if(!r&&o>1e6)break}return Object.freeze({entries:Object.freeze(n),complete:r,coverage:"explicit-source-effects"})}var Dt="http://schemas.openxmlformats.org/wordprocessingml/2006/main",qu="urn:schemas-microsoft-com:office:office",Hr="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ju="http://schemas.openxmlformats.org/package/2006/relationships",Qu="http://schemas.openxmlformats.org/package/2006/content-types",Zu="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",Ba="application/vnd.openxmlformats-package.relationships+xml",ef=new Set(["drawing","pict","object"]),tf=new Set(["oleObject","package","control","vbaProject","attachedTemplate","externalLinkPath","subDocument","frame"].map(e=>`${Hr}/${e}`)),nf=["styles","theme","settings","fontTable"].map(e=>`${Hr}/${e}`),rf=`${Hr}/diagramData`,of=4,af='<w:pPr><w:spacing w:before="0" w:after="0" w:line="240" w:lineRule="auto"/><w:ind w:left="0" w:right="0" w:firstLine="0"/><w:jc w:val="left"/></w:pPr>',ja=1e5;function sf(e,t){let n=cb(e,t);if(!n||n.kind==="textValue")return null;let r=null,o=n;for(let a=0;o&&a<64&&(o.namespaceUri===Dt&&ef.has(o.localName)&&(r=o),o.namespaceUri===sa$1&&o.localName==="AlternateContent"&&(r=o),!(o.namespaceUri===Dt&&(o.localName==="r"||o.localName==="p")));a++)o=db(e,o.id);return r}function Fd(e,t,n){let r=[e],o=0;for(;r.length&&++o<=ja;){let a=r.pop();for(let{namespaceUri:i,localName:s,value:l}of a.attributes)((n?s===n:i===ya$1)||!n&&i===qu&&s==="relid")&&t.add(l);for(let i of a.children)i.kind!=="textValue"&&r.push(i);}}function lf(e,t){let n=Fa$1(t),{rootBindings:r,declarations:o}=Ia$1(n),a=[];Ga(e,n,r,false,o,a);let i=new TextDecoder;return a.map(s=>typeof s=="string"?s:i.decode(s)).join("")}var cf=new Set(["extent","effectExtent","docPr","cNvGraphicFramePr"]),df=635,Bd="urn:schemas-microsoft-com:vml";function Hd(e,t=0,n=false){if(t>32||e.namespaceUri===Dt&&e.localName==="txbxContent")return e;if(n&&e.namespaceUri===Bd){let a=e.attributes.map(i=>i.namespaceUri===""&&i.localName==="style"?{...i,value:uf(i.value)}:i);return {...e,attributes:a}}if(e.namespaceUri===wa$1&&e.localName==="anchor")return {id:e.id,kind:"generic",namespaceUri:wa$1,localName:"inline",namespaceBindings:e.namespaceBindings,attributes:e.attributes.filter(a=>a.namespaceUri===""&&/^dist[TBLR]$/.test(a.localName)),children:e.children.filter(a=>a.kind!=="textValue"&&(a.namespaceUri===wa$1&&cf.has(a.localName)||a.namespaceUri===va$1&&a.localName==="graphic"))};let r=false,o=e.children.map(a=>{if(a.kind==="textValue")return a;let i=e.namespaceUri===Dt&&(e.localName==="pict"||e.localName==="object"),s=Hd(a,t+1,i);return r||=s!==a,s});return r?{...e,children:o}:e}var mf=/^(position|left|top|margin-(left|top|right|bottom)|z-index|mso-position-.*)$/,pf={pt:1,in:72,cm:72/2.54,mm:72/25.4,pc:12,px:.75,"":.75};function uf(e){return e.split(";").filter(t=>!mf.test(t.split(":")[0].trim().toLowerCase())).join(";")}function Ld(e,t){for(let n of e.split(";")){let[r,o]=n.split(":");if(r?.trim().toLowerCase()!==t||o===void 0)continue;let a=/^\s*([0-9]+(?:\.[0-9]+)?)\s*(pt|in|cm|mm|pc|px|)\s*$/i.exec(o);return a?Number(a[1])*pf[a[2].toLowerCase()]*20:null}return null}function ff(e){let t=[{node:e,inWrapper:false}],n=0;for(;t.length&&++n<=ja;){let{node:r,inWrapper:o}=t.shift();if(o&&r.namespaceUri===Bd&&r.localName!=="shapetype"){let i=r.attributes.find(c=>c.namespaceUri===""&&c.localName==="style")?.value,s=i?Ld(i,"width"):null,l=i?Ld(i,"height"):null;if(s!==null&&l!==null&&(s>0||l>0)){let c=Number(/(?:^|;)\s*rotation\s*:\s*(-?[0-9.]+)/i.exec(i)?.[1]??0),d=(Number.isFinite(c)?c:0)*Math.PI/180,m=Math.abs(Math.cos(d)),f=Math.abs(Math.sin(d)),h=y=>Math.min(31680,Math.max(1,Math.ceil(y)));return {width:h(s*m+l*f),height:h(s*f+l*m)}}}let a=r.namespaceUri===Dt&&(r.localName==="pict"||r.localName==="object");for(let i of r.children)i.kind!=="textValue"&&t.push({node:i,inWrapper:a});}return null}function gf(e){let t=[e],n=0;for(;t.length&&++n<=ja;){let r=t.pop();if(r.namespaceUri===wa$1&&(r.localName==="anchor"||r.localName==="inline")){let o=(l,c)=>{let d=r.children.find(h=>h.kind!=="textValue"&&h.namespaceUri===wa$1&&h.localName===l),m=d&&d.kind!=="textValue"?d.attributes.find(h=>h.localName===c)?.value:void 0,f=m===void 0?0:Number(m);return Number.isFinite(f)?f:0},a=o("extent","cx")+o("effectExtent","l")+o("effectExtent","r"),i=o("extent","cy")+o("effectExtent","t")+o("effectExtent","b");if(a<=0&&i<=0)return null;let s=l=>Math.min(31680,Math.max(1,Math.ceil(l/df)));return {width:s(a),height:s(i)}}for(let o of r.children)o.kind!=="textValue"&&t.push(o);}return null}function hf(e){return `<w:sectPr><w:pgSz w:w="${e.width}" w:h="${Math.min(31680,e.height+120)}"/><w:pgMar w:top="0" w:right="0" w:bottom="0" w:left="0" w:header="0" w:footer="0" w:gutter="0"/></w:sectPr>`}function Ha(e,t){let n;for(let r of e?.children??[])r.kind!=="textValue"&&r.namespaceUri===Dt&&r.localName===t&&(n=r);return n}function yf(e){let t=Ha(e.parts.get(e.mainDocumentPart)?.root,"body"),n=Ha(t,"sectPr"),r=(o,a)=>{let i=Ha(n,"pgSz")?.attributes.find(l=>l.localName===o)?.value,s=i===void 0?NaN:Number(i);return Number.isInteger(s)&&s>0&&s<=31680?s:a};return `<w:sectPr><w:pgSz w:w="${r("w",12240)}" w:h="${r("h",15840)}"/><w:pgMar w:top="0" w:right="0" w:bottom="0" w:left="0" w:header="0" w:footer="0" w:gutter="0"/></w:sectPr>`}function Va(e){let t=e.map(({id:n,type:r,target:o})=>`<Relationship Id="${V(n)}" Type="${V(r)}" Target="${V(o)}"/>`).join("");return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${Ju}">${t}</Relationships>`}function $d(e){return e.startsWith("/word/")?e.slice(6):e}function xf(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function kf(e,t,n={}){let r=n.maxParts??64,o=n.maxBytes??64*1024*1024,a=e.parts.get(t.ownerPartName),i=a?sf(a,t.nodeId):null;if(!a||!i)return {ok:false,reason:"drawing-not-found"};let s=new Map,l=new Map,c=[],d=0,m=new TextEncoder,f=null,h=S=>{if(S.targetMode==="External"||tf.has(S.type))return null;let I=N(S);if(I.mode!=="Internal"||!I.target.ok)return null;let _=I.target.partName;return e.parts.has(_)||e.partBytes.has(_)?_:null},y=(S,I,_)=>s.has(S)?true:(s.size>=r?f="too-many-parts":d+I.byteLength>o&&(f="too-large"),f?false:(s.set(S,I),d+=I.byteLength,_&&l.set(S,_),true)),P=(S,I)=>{if(f||s.has(S)||S==="/word/document.xml")return;let _=e.parts.get(S),q=_?m.encode(Ha$1(_)):e.partBytes.get(S);if(!q)return;let ee=K(e.contentTypes,S);if(!y(S,q,ee.ok?ee.contentType:null)||(c.push(S),!_||I>=of))return;let K$1=[];for(let ae of e.relationships.get(S)??[]){let B=h(ae);B&&(K$1.push({id:ae.id,type:ae.type,target:ae.rawTarget}),P(B,I+1));}K$1.length&&y(xf(S),m.encode(Va(K$1)),Ba);},T=new Set;Fd(i,T);let M=e.relationships.get(a.name)??[],p=[],x=S=>{let I=h(S);if(!I||p.some(q=>q.id===S.id))return;p.push({id:S.id,type:S.type,target:$d(I)}),P(I,1);let _=e.parts.get(I);if(S.type===rf&&_){let q=new Set;Fd(_.root,q,"relId");for(let ee of M)q.has(ee.id)&&x(ee);}};for(let S of M)T.has(S.id)&&x(S);let k=0;for(let S of e.relationships.get(e.mainDocumentPart)??[]){if(!nf.includes(S.type))continue;let I=h(S);I&&(p.push({id:`rIdPreviewContext${++k}`,type:S.type,target:$d(I)}),P(I,1));}if(f)return {ok:false,reason:f};let v=gf(i)??ff(i),A=`xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:mc="${sa$1}" mc:Ignorable="w14 wp14 w15"`,O=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="${Dt}" ${A}><w:body><w:p>${af}<w:r>${lf(Hd(i),a.root)}</w:r></w:p>${v?hf(v):yf(e)}</w:body></w:document>`;if(!y("/word/document.xml",m.encode(O),Zu)||!y("/word/_rels/document.xml.rels",m.encode(Va(p)),Ba))return {ok:false,reason:f??"too-large"};let D=Va([{id:"rId1",type:`${Hr}/officeDocument`,target:"word/document.xml"}]),F=[...l].map(([S,I])=>`<Override PartName="${V(S)}" ContentType="${V(I)}"/>`).join(""),w=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${Qu}"><Default Extension="rels" ContentType="${Ba}"/><Default Extension="xml" ContentType="application/xml"/>${F}</Types>`,N$1=new Map([["/[Content_Types].xml",m.encode(w)],["/_rels/.rels",m.encode(D)]]);for(let[S,I]of s)N$1.set(S,I);return {ok:true,docx:Xe(N$1),pageFitsDrawing:v!==null,copiedParts:Object.freeze(c)}}
4
+ export{jp as $,_o as A,_u as Aa,nm as B,Gb as Ba,ol as C,Uu as Ca,al as D,Dd as Da,am as E,_d as Ea,fn as F,zu as Fa,kg as G,Qb as Ga,kr as H,Yu as Ha,Pr as I,kf as Ia,ml as J,Rg as K,ll as L,vm as M,ea as N,tc as O,ta as P,Tt as Q,qc as R,Nn as S,ed as T,td as U,ya as V,pk as W,ka as X,wa as Y,Ea as Z,Vp as _,Vd as a,Gp as aa,Qs as b,zp as ba,ur as c,Wp as ca,vt as d,Kp as da,fr as e,hd as ea,gr as f,yd as fa,Re as g,Ta as ga,Wd as h,Ca as ha,wt as i,qp as ia,pn as j,Qp as ja,hr as k,Zp as ka,un as l,eu as la,yr as m,tu as ma,vo as n,cP as na,wo as o,$r as oa,Eo as p,dP as pa,qd as q,nu as qa,Jd as r,mP as ra,Co as s,Aa as sa,el as t,Iu as ta,Qd as u,Nu as ua,To as v,_a as va,Zd as w,vd as wa,Mo as x,wd as xa,Do as y,Su as ya,Ao as z,Fa as za};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkV7CO55DO_cjs=require('./chunk-V7CO55DO.cjs'),chunkTXIO5WYQ_cjs=require('./chunk-TXIO5WYQ.cjs'),chunkNKZVMMHU_cjs=require('./chunk-NKZVMMHU.cjs'),chunkE5BKDHIP_cjs=require('./chunk-E5BKDHIP.cjs'),chunkA5BTVPET_cjs=require('./chunk-A5BTVPET.cjs');var St=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u;function Y(e){let t=new Map;for(let n of e)if(Array.isArray(n)){for(let o of n.slice(0,2048)){if(typeof o!="string"||!St.test(o))continue;let r=o.toLowerCase();if(t.has(r)||t.set(r,o),t.size===2048)break}if(t.size===2048)break}return Object.freeze([...t.values()])}function mn(e){let t=e&&"failures"in e?e.failures:void 0;return e==null||(e.sources?.length??0)===0&&(e.substitutions?.length??0)===0&&(t===void 0||Array.isArray(t)&&t.length===0)?void 0:e}var nt=64,ce=Object.freeze({family:"Calibri",sizeHalfPoints:22}),gn=ce;function ee(e,...t){let n=[e,...t],o=[],r=new Set;for(let l of n)for(let u of l.sources??[]){let c=chunkTXIO5WYQ_cjs.h(u.request);r.has(c)||(r.add(c),o.push(u));}let i=[],s=new Set;for(let l of n)for(let u of l.substitutions??[]){let c=chunkTXIO5WYQ_cjs.h(u.from);r.has(c)||s.has(c)||(s.add(c),i.push(u));}let a=Y(n.map(l=>l.supportedFamilies));return Object.freeze({...a.length?{supportedFamilies:a}:{},epoch:e.epoch??0,maxFontBytes:e.maxFontBytes??chunkTXIO5WYQ_cjs.a,sources:Object.freeze(o),...i.length>0?{substitutions:Object.freeze(i)}:{},defaultFont:e.defaultFont??ce,...e.language!==void 0?{language:e.language}:{}})}var Ot=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u;function te(e){let t=e?.defaultFont?.family;return t!==void 0&&Ot.test(t)?t:ce.family}function G(e){let t="deferred"in e?e.deferred:void 0;if(t===void 0)return {now:e};let{deferred:n,...o}=e;if(typeof t?.then!="function")return {now:o};let r=Promise.resolve(t);return r.catch(()=>{}),{now:o,later:r}}var rt=new WeakSet;function At(e){return e&&rt.add(e),e}function it(e,t){if(!t)return e;let n=e?fe(e):void 0,o=t.deferred?{deferred:t.deferred}:{},r=rt.has(t),i=r?t.supportedFamilies??[]:[...t.supportedFamilies??[],...n?.supportedFamilies??[]];return {...n,sources:r?t.sources??[]:[...t.sources??[],...n?.sources??[]],substitutions:r?t.substitutions??[]:[...t.substitutions??[],...n?.substitutions??[]],supportedFamilies:i.length>0?[...new Set(i)]:void 0,...o}}function Rt(e){return !!e&&((e.sources?.length??0)>0||(e.substitutions?.length??0)>0||e.deferred!==void 0)}function st(e){let t=e&&"failures"in e?e.failures:void 0;return Array.isArray(t)?t.slice(0,256):[]}function at(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((n,o)=>{let r=()=>o(t.reason);t.addEventListener("abort",r,{once:true}),Promise.resolve(e).then(i=>{t.removeEventListener("abort",r),n(i);},i=>{t.removeEventListener("abort",r),o(i);});}):Promise.resolve(e)}async function lt(e,t,n){let o="failures"in e?e.failures:void 0,r=s=>o===void 0?s:{...s,failures:o},i=e;for(let s=0;s<ot;s+=1){let{now:a,later:l}=G(i);if(!l)return r(a);let u;try{u=await at(l,n);}catch(c){if(n?.aborted)throw n.reason;return t(c),r(a)}for(let c of st(u))t(c);i=it(a,u)??a;}return t(new RangeError(`Font loading stopped after ${ot} deferred steps`)),r(G(i).now)}var ot=256;function fe(e){if(!("failures"in e))return e;let{failures:t,...n}=e;return n}async function de(e,t,n,o){let r=t.flatMap((a,l)=>a?[a.then(u=>({originIndex:l,ok:true,value:u??void 0}),u=>({originIndex:l,ok:false,cause:u}))]:[]);if(r.length===0)return;let i=await at(Promise.race(r),n).catch(()=>{});if(!i||n?.aborted)return;if(i.ok)for(let a of st(i.value))o.report(i.originIndex,a);else o.report(i.originIndex,i.cause);if(!i.ok||!Rt(i.value)){let a=t.map((l,u)=>u===i.originIndex?void 0:l);return de(e,a,n,o)}let s=[];for(let a=0;a<Math.max(e.length,t.length);a+=1){let l=e[a],u=t[a];s.push(a===i.originIndex?it(l,i.value):u?{...l??{sources:[]},deferred:u}:l);}try{return At(await o.compose(s))}catch(a){n?.aborted||o.report(i.originIndex,a);return}}var kt="docx-editor.dev/font-resolver",ft=Symbol.for("docx-editor.dev/font-resolver");function En(e){let t={value:true,enumerable:false,configurable:true};try{Object.defineProperty(e,ft,t),Object.defineProperty(e,kt,t);}catch(n){throw new TypeError("defineFontResolver cannot mark a frozen or sealed function; mark it before freezing, or wrap it in a fresh function and mark that.",{cause:n})}return e}function Cn(e){return typeof e=="function"&&e[ft]===true}var ge=class extends RangeError{constructor(n,o,r){super(`Font source ${n.family} (${o} bytes) exceeds the shaping byte ceiling (${r} bytes)`);this.request=n;}request},pe=class extends AggregateError{causes;constructor(t){let n=Object.freeze(t.slice(0,chunkTXIO5WYQ_cjs.b*2));super(n,`Font origin rejected all ${n.length} face and substitution candidates`),this.causes=n;}},ne=e=>`${e.family.trim().toLowerCase()} ${e.weight} ${e.style}`;function Tt(e,t,n){let o=new Map(e.map(r=>[ne(r),r]));for(let[r,i]of t)o.set(r,i);for(let r of n)o.has(ne(r.to))&&o.set(ne(r.from),r.from);return [...o.values()]}async function Sn(e,t,n={}){return ye(e,t,n)}async function On(e,t,n={}){return ye(e,t,n)}async function ye(e,t,n){let o=n.maxExecutionFontBytes??chunkTXIO5WYQ_cjs.a;if(!Number.isSafeInteger(o)||o<=0||o>chunkTXIO5WYQ_cjs.a)throw new RangeError("Font execution byte ceiling is outside the supported range");let r=e.map(Mt),i,s=[],a=[],l=new Map,u=new Set,c=0,f=[],d=new Set,b=[],v=t.resolvedFaces??[],T=t.defaultFamily,S=[],P=[],g=new Set(n.placeholderOrigins??[]),E;for(let F=0;F<e.length;F+=1){dt(t.signal);let k=e[F],X=Tt(v,l,f),q,B;try{let w=r[F],p;if(w){let m=await ct(w,t.signal);if(!m.ok)throw m.cause;p=m.value;}else if(typeof k=="function"){let m=await ct(Promise.resolve(k(Lt(t,T,X,c))).then(_=>({ok:!0,value:_}),_=>({ok:!1,cause:_})),t.signal);if(!m.ok)throw m.cause;p=m.value;}else p=k;if(p==null)continue;if(typeof p=="function"){K(n,k,F,new TypeError("A font origin answered with a function; pass the resolver itself rather than a function returning one"));continue}if(n.awaitDeferred){let m=G(p);m.later&&ut(m.now,m.now)&&g.add(F),p=await lt(p,_=>K(n,k,F,_),t.signal);}else {let m=G(p);p=m.now,B=m.later;}let C="failures"in p?p.failures:void 0,O=[];if(Array.isArray(C)){let m=Math.min(C.length,chunkTXIO5WYQ_cjs.b);for(let _=0;_<m;_++)O.push(C[_]);C.length>m&&O.push(new Error("Additional font-origin failures were omitted"));}else C!==void 0&&O.push(C);let A;try{A=vt(p,u,c,d,i?"maxFontBytes"in i&&i.maxFontBytes!==void 0?i.maxFontBytes:chunkTXIO5WYQ_cjs.a:void 0,n.reserveOwnedBytes,n.instrumentation,o);}catch(m){for(let _ of new Set(O))K(n,k,F,_);throw m}q=A;for(let m of new Set([...A.dropped,...O]))K(n,k,F,m);let x=A.fragment;x.supportedFamilies&&s.push(x.supportedFamilies),b.push(...O);let U=(x.sources??[]).map(m=>(chunkTXIO5WYQ_cjs.h(m.request),[ne(m.request),m.request])),W=[...x.substitutions??[]];B!==void 0&&ut(x,p)&&g.add(F);let $=g.has(F);!i&&!$&&"defaultFont"in x&&(T=te(x)),!i&&!$&&(i=x),$&&(E??=x);let z=new Set(A.sourceKeys);if(z.size>0){f=f.filter(m=>!z.has(chunkTXIO5WYQ_cjs.h(m.from)));for(let m of z)d.delete(m);}a.push(...x.sources??[]);for(let m of A.sourceKeys)u.add(m);c+=A.ownedBytes;for(let[m,_]of U)l.set(m,_);for(let m of W)f.push(m),d.add(chunkTXIO5WYQ_cjs.h(m.from));S[F]=fe(x),B&&(P[F]=B);}catch(w){if(q?.releaseOwnedBytes?.(),t.signal?.aborted)throw t.signal.reason??w;if(w instanceof oe)throw w.cause;if(K(n,k,F,w),B){let p=new Error("Font origin skipped, so its background faces were not loaded");K(n,k,F,p);}continue}}let y=P.some(Boolean)?de(S,P,t.signal,{compose:F=>ye(F,t,{...n,placeholderOrigins:g}),report:(F,k)=>K(n,e[F],F,k)}):void 0;if(i??=E,!i)return y?{sources:[],deferred:y}:void 0;let{epoch:M,...R}=ee({...i,supportedFamilies:Y(s),sources:a,substitutions:f}),D=y?{...R,deferred:y}:R;return b.length===0?D:{...D,failures:Object.freeze(b)}}function ut(e,t){return (e.sources?.length??0)===0&&(e.substitutions?.length??0)===0&&!("defaultFont"in t)&&!("maxFontBytes"in t)}var oe=class extends Error{constructor(n){super("Unable to reserve owned font bytes");this.cause=n;this.name="FontOwnershipReservationError";}cause},re=class extends RangeError{};async function ct(e,t){if(!t)return e;dt(t);let n,o=new Promise((i,s)=>{n=s;}),r=()=>n?.(t.reason);t.addEventListener("abort",r,{once:true});try{return await Promise.race([e,o])}finally{t.removeEventListener("abort",r);}}function Mt(e){if(e===null||typeof e!="object")return;let t;try{t=e.then;}catch(n){return Promise.resolve({ok:false,cause:n})}if(typeof t=="function")return Promise.resolve(e).then(n=>({ok:true,value:n}),n=>({ok:false,cause:n}))}function vt(e,t,n,o,r,i,s,a=chunkTXIO5WYQ_cjs.a){let l=e.sources??[],u=e.substitutions??[],c="maxFontBytes"in e?e.maxFontBytes:void 0,f="defaultFont"in e?e.defaultFont:void 0,d="epoch"in e?e.epoch:void 0,b="language"in e?e.language:void 0;if(!Array.isArray(l)||!Array.isArray(u))throw new TypeError("Font origin sources and substitutions must be arrays");let v=l.length,T=u.length;if(v>chunkTXIO5WYQ_cjs.b)throw new RangeError(`Font source count must not exceed ${chunkTXIO5WYQ_cjs.b}`);if(T>chunkTXIO5WYQ_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkTXIO5WYQ_cjs.b}`);let S=c??chunkTXIO5WYQ_cjs.a;if(!Number.isSafeInteger(S)||S<=0||S>chunkTXIO5WYQ_cjs.a)throw new RangeError(`Font byte ceiling must be a positive safe integer no greater than ${chunkTXIO5WYQ_cjs.a}`);let P=Math.min(r??S,a),g=0,E=[],y=new Set,M=[],R=[];for(let w=0;w<v;w+=1){let p=l[w];try{let C=me(p.request),O=chunkTXIO5WYQ_cjs.h(C);if(t.has(O)||y.has(O))continue;let A=p.availability,x=p.faceIndex,U=p.hash,W=p.id;if(A!==void 0&&A!=="available"&&A!=="forbidden")throw new TypeError("Font source availability must be available or forbidden");if(!Number.isSafeInteger(x)||x<0)throw new RangeError("Font face index must be a non-negative safe integer");if(typeof U!="string"||U.length===0)throw new TypeError("Font source hash must be a non-empty string");let $;if(A!=="forbidden"){if(typeof W!="string"||W.length===0)throw new TypeError("Font source id must be a non-empty string");$=p.bytes;let z=chunkTXIO5WYQ_cjs.e($);if(z>P)throw z<=(r??S)?new ge(C,z,a):new RangeError(`Font source ${C.family} (${z} bytes) exceeds the effective base byte ceiling (${P} bytes)`);if(t.has(O)||y.has(O))continue;if(n+g+z>chunkTXIO5WYQ_cjs.c)throw new RangeError(`Font sources exceed the aggregate byte ceiling of ${chunkTXIO5WYQ_cjs.c}`);g+=z;}else $=new Uint8Array(0);if(t.has(O)||y.has(O))continue;if(t.size+y.size>=chunkTXIO5WYQ_cjs.b)throw new re(`Font source count must not exceed ${chunkTXIO5WYQ_cjs.b}`);y.add(O),E.push(O),M.push(Object.freeze({request:C,id:W,bytes:$,hash:U,faceIndex:x,...A?{availability:A}:{}}));}catch(C){if(C instanceof re)throw C;R.push(C);}}let D=new Set,F=[];for(let w=0;w<T;w+=1){let p=u[w];try{let C=me(p.from),O=me(p.to);chunkTXIO5WYQ_cjs.h(C),chunkTXIO5WYQ_cjs.h(O);let A=p.lineMetrics,x=A?Object.freeze({heightEm:A.heightEm,baselineEm:A.baselineEm}):void 0;if(x&&(!Number.isFinite(x.heightEm)||!Number.isFinite(x.baselineEm)||x.heightEm<=0||x.heightEm>4||x.baselineEm<0||x.baselineEm>x.heightEm))throw new RangeError("Font substitution line metrics must fit within a bounded em box");let U=chunkTXIO5WYQ_cjs.h(C);if(t.has(U)||y.has(U)||o.has(U)||D.has(U))continue;D.add(U),F.push(Object.freeze({from:C,to:O,...x?{lineMetrics:x}:{}}));}catch(C){R.push(C);}}if((v>0||T>0)&&M.length===0&&F.length===0&&R.length>0)throw R.length===1?R[0]:new pe(R);let k=o.size;for(let w of y)o.has(w)&&(k-=1);if(k+D.size>chunkTXIO5WYQ_cjs.b)throw new RangeError(`Font substitution count must not exceed ${chunkTXIO5WYQ_cjs.b}`);let X;if(f!==void 0){let w=f.family,p=f.sizeHalfPoints;if(chunkTXIO5WYQ_cjs.h({family:w,weight:400,style:"normal"}),!Number.isSafeInteger(p)||p<=0)throw new RangeError("Default font size must be a positive safe integer in half-points");X=Object.freeze({family:w,sizeHalfPoints:p});}if(d!==void 0&&(!Number.isSafeInteger(d)||d<0))throw new RangeError("Font configuration epoch must be a non-negative safe integer");if(b!==void 0&&typeof b!="string")throw new TypeError("Font shaping language must be a string");let q;if(g>0&&i)try{q=i(g);}catch(w){throw new oe(w)}let B;try{B=M.map(w=>chunkTXIO5WYQ_cjs.f(w,s));}catch(w){throw q?.(),w}return {fragment:Object.freeze({supportedFamilies:Y([e.supportedFamilies]),sources:Object.freeze(B),substitutions:Object.freeze(F),...d!==void 0?{epoch:d}:{},...c!==void 0?{maxFontBytes:c}:{},...X?{defaultFont:X}:{},...b!==void 0?{language:b}:{}}),sourceKeys:Object.freeze(E),ownedBytes:g,dropped:Object.freeze(R),releaseOwnedBytes:q}}function _t(e){return !Number.isSafeInteger(e)||e<=0?0:e>chunkTXIO5WYQ_cjs.c?chunkTXIO5WYQ_cjs.c:e}function Lt(e,t,n,o){let{committedSourceBytes:r,...i}=e,s=_t(o);return {...i,defaultFamily:t,...n.length>0?{resolvedFaces:n}:{},...s>0?{committedSourceBytes:s}:{}}}function me(e){return Object.freeze({family:e.family,weight:e.weight,style:e.style})}function dt(e){if(e?.aborted)throw e.reason??new DOMException("Font resolution was aborted","AbortError")}function K(e,t,n,o){let r;try{typeof t=="function"&&t.name.length>0&&(r=t.name);}catch{}try{o instanceof Error&&o.stack;}catch{}let i=Object.freeze({originIndex:n,...r!==void 0?{originName:r}:{},cause:o});if(e.onOriginFailure)try{let a=e.onOriginFailure(i);Promise.resolve(a).catch(l=>{console.warn("[fonts] font-origin diagnostic callback failed",l);});return}catch(a){console.warn("[fonts] font-origin diagnostic callback failed",a);}let s="";try{o instanceof Error&&o.message.length>0&&(s=`: ${o.message}`);}catch{}console.warn(`[fonts] a font origin failed and was skipped${s}`,o);}function Nt(e,t,n){let o="";for(let r=t;r+1<t+n&&r+1<e.length;r+=2){let i=e[r]|e[r+1]<<8;if(i===0)break;o+=String.fromCharCode(i);}return o}function Pt(e,t,n){let o="";for(let r=t;r<t+n&&r<e.length&&e[r]!==0;r++)o+=String.fromCharCode(e[r]);return o}function It(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||n.getUint32(0,true)!==1)return;let o=0;for(let r=0;r<1e5&&o+8<=e.length;r++){let i=n.getUint32(o,true),s=n.getUint32(o+4,true);if(s<8||s%4!==0||o+s>e.length||(i===82&&s>=104&&t(Nt(e,o+40,64)),i===14))return;o+=s;}}function Dt(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=e.length>=22&&n.getUint32(0,true)===2596720087?22:0;if(!(o+18>e.length||n.getUint16(o+2,true)!==9)){o+=18;for(let i=0;i<1e5&&o+6<=e.length;i++){let s=n.getUint32(o,true),a=n.getUint16(o+4,true);if(s<3||o+s*2>e.length||(a===763&&s*2>=25&&t(Pt(e,o+6+18,Math.min(32,s*2-6-18))),a===0))return;o+=s*2;}}}function mt(e,t){let n=new Map,o=i=>{if(i.trim().toLowerCase()==="system")return;let s=t(i.trim());if(s===null||n.size>=16)return;let a=s.toLowerCase();n.has(a)||n.set(a,s);},r=0;for(let[i,s]of e.partBytes){let a=i.toLowerCase();if(!a.startsWith("/word/")||a.startsWith("/word/glossary/"))continue;let l=a.endsWith(".emf"),u=a.endsWith(".wmf");if(!(!l&&!u)){if(++r>64||n.size>=16)break;l?It(s,o):Dt(s,o);}}return [...n.values()]}var Bt=2e5,pt=32,Ut=new Set(["latin","ea","cs"]);function zt(e,t){let n=/^\+(mn|mj)-(lt|ea|cs)$/.exec(e);if(!n)return;let o=n[1]==="mj";return n[2]==="ea"?o?t.majorEastAsia:t.minorEastAsia:n[2]==="cs"?o?t.majorBidi:t.minorBidi:o?t.major:t.minor}var gt=new WeakMap;function qt(e){let t=gt.get(e);if(t)return t;let n=[],o=new Set,r=[e],i=0;for(;r.length>0&&++i<=Bt&&n.length<pt;){let s=r.pop();if(s.namespaceUri===chunkA5BTVPET_cjs.va&&Ut.has(s.localName)){let a=chunkA5BTVPET_cjs.oa(s.attributes,"typeface");a&&!o.has(a)&&(o.add(a),n.push(a));continue}for(let a=s.children.length-1;a>=0;a-=1){let l=s.children[a];l.kind!=="textValue"&&r.push(l);}}return gt.set(e,n),n}function Nn(e,t={}){let n=new Map,o=r=>{let i=r?chunkNKZVMMHU_cjs.b(r):null;if(i===null||n.size>=pt)return;let s=i.toLowerCase();n.has(s)||n.set(s,i);};for(let r of e.parts.values()){let i=r.root;if(!(i.namespaceUri!==chunkA5BTVPET_cjs.qe&&i.namespaceUri!==chunkA5BTVPET_cjs.Ee)){o(t.minor);for(let s of qt(i))s.startsWith("+")?o(zt(s,t)):o(s);}}for(let r of mt(e,chunkNKZVMMHU_cjs.b))o(r);return [...n.values()]}var jt=256,Xt=Object.freeze([]);function ie(e){let t=new WeakMap;return (n,o)=>{let r=new Set;for(let i of n){let s=[{node:i,context:o,next:0}],a=l=>{s.pop();let u=s.at(-1)?.found??r;for(let c of l)u.add(c);};for(;s.length;){let l=s[s.length-1],u=t.get(l.node);if(u?.key===l.context.key){a(u.families);continue}if(!l.children){let d=e(l.node,l.context);l.children=d.children,l.found=new Set(d.families);}let c=l.children[l.next++];if(c){s.push({...c,next:0});continue}let f=l.found.size===0?Xt:[...l.found];f.length<=jt&&chunkA5BTVPET_cjs.Bb(l.node)?t.set(l.node,{key:l.context.key,families:f}):t.delete(l.node),a(f);}}return [...r]}}function se(e,t){return e.children.flatMap(n=>n.kind==="textValue"?[]:[{node:n,context:t}])}var yt=new WeakMap,$t=4096;function Ft(e,t){let n=`${e.baseKey}|${e.depth+1}|${JSON.stringify(t)}`,o=yt.get(e);o||yt.set(e,o=new Map);let r=o.get(n);if(r)return r;let i={...e,depth:e.depth+1,cellStyle:t,key:n};return o.size<$t&&o.set(n,i),i}function Vt(e,t){let{styles:n,theme:o,supplementalFamilies:r,depth:i}=t;if(e.kind==="table"){let l=chunkTXIO5WYQ_cjs.re(e,468,i,n),u=[];for(let c of l?.rows??[])for(let f of c.cells){let d=Ft(t,f.styleFormatting);for(let b of f.blocks)u.push({node:b,context:d});}return {children:u.reverse()}}let s=new Set;if(e.kind==="paragraph"){let l=e.children.find(c=>c.kind==="paragraphProperties"),u=chunkTXIO5WYQ_cjs.lf(n,l,t.cellStyle).runProperties;for(let c of chunkTXIO5WYQ_cjs.kd(e,u,void 0,(f,d)=>chunkTXIO5WYQ_cjs.of(f,d,n),void 0,void 0,"all-markup",void 0,void 0,o)){if(!c.text||c.fontSlot!=="eastAsia"&&!r.has(c.style.fontFamily??""))continue;let f=chunkNKZVMMHU_cjs.b((c.fontSlot==="eastAsia"?c.style.fontFamilyEastAsia:c.style.fontFamily)??void 0);f&&s.add(f);}}let a=e.localName==="txbxContent"?{...t,cellStyle:void 0,key:`${t.baseKey}|${i}|undefined`}:t;return {families:[...s],children:se(e,a).reverse()}}function Ht(){let e=ie(Vt),t,n,o=(i,s)=>{if(!t||n!==i||t.theme!==s){let a=chunkTXIO5WYQ_cjs.kf(i,s);n=i,t={key:`${a.cacheToken}|0|undefined`,baseKey:a.cacheToken,styles:a,theme:s,depth:0,supplementalFamilies:new Set([...Object.values(s.majorSupplemental??{}),...Object.values(s.minorSupplemental??{})])};}return t};return Object.assign((i,s,a)=>e([...i].reverse(),o(s,a)),{warmTableRows(i,s,a,l,u){let c=o(l,u),f=chunkTXIO5WYQ_cjs.re(i,468,c.depth,c.styles)?.rows??[];for(let d of f.slice(s,a))for(let b of d.cells)e(b.blocks,Ft(c,b.styleFormatting));return f.length}})}function Xn(e,t,n){return Ht()(e,t,n)}function Fe(e,t){return e.attributes.find(n=>n.localName===t)?.value}var Kt=ie((e,t)=>{let n=[];if(e.namespaceUri===chunkA5BTVPET_cjs.pa){if(e.localName==="fldSimple"){let o=chunkTXIO5WYQ_cjs.ie(Fe(e,"instr")??"")?.font;o&&n.push(o);}if(e.localName==="p")for(let o of Wt(e))n.push(o);}return {families:n,children:se(e,t)}});function to(e){let t=new Map;for(let n of Kt(e,{key:""})){let o=chunkNKZVMMHU_cjs.b(n);o!==null&&!t.has(o.toLowerCase())&&t.set(o.toLowerCase(),o);}return [...t.values()]}function Wt(e){let t=[],n=chunkTXIO5WYQ_cjs.Nc(),o=[];for(let r=e.children.length-1;r>=0;r-=1){let i=e.children[r];i.kind!=="textValue"&&o.push({node:i,containerDepth:0});}for(;o.length>0;){let{node:r,containerDepth:i}=o.pop();if(i>=chunkA5BTVPET_cjs.Aa||r.namespaceUri===chunkA5BTVPET_cjs.pa&&r.localName==="p")continue;if(r.namespaceUri===chunkA5BTVPET_cjs.pa&&r.localName==="fldChar"){let a=Fe(r,"fldCharType");a==="begin"?chunkTXIO5WYQ_cjs.Qc(n):a==="separate"?(n.nesting===1&&ht(n,t),chunkTXIO5WYQ_cjs.Sc(n)):a==="end"&&(n.nesting===1&&ht(n,t),chunkTXIO5WYQ_cjs.Tc(n));continue}if(r.namespaceUri===chunkA5BTVPET_cjs.pa&&(r.localName==="instrText"||r.localName==="delInstrText")){chunkTXIO5WYQ_cjs.Rc(n,Yt(r),r.localName==="delInstrText");continue}if(r.namespaceUri===chunkA5BTVPET_cjs.pa&&r.localName==="fldSimple"){let a=chunkTXIO5WYQ_cjs.ie(Fe(r,"instr")??"");a?.font&&t.push(a.font);}let s=chunkA5BTVPET_cjs.Ba(r,i);for(let a=r.children.length-1;a>=0;a-=1){let l=r.children[a];l.kind!=="textValue"&&o.push({node:l,containerDepth:s});}}return chunkTXIO5WYQ_cjs.Oc(n),t}function ht(e,t){let n=chunkTXIO5WYQ_cjs.Pc(e);if(n.overflow)return;let o=chunkTXIO5WYQ_cjs.ie(n.instruction);o?.font&&t.push(o.font);}function Yt(e){let t="",n=[...e.children].reverse();for(;n.length>0&&t.length<=256;){let o=n.pop();if(o.kind==="textValue")t+=o.value;else for(let r=o.children.length-1;r>=0;r-=1)n.push(o.children[r]);}return t}var Gt=()=>true,Jt=/[ᄀ-ᇿ⺀-鿿ꥠ-꥿가-퟿豈-﫿︰-﹏＀-￯]/u;function no(e,t,n,o){if(!t)return [];let r=chunkTXIO5WYQ_cjs.nd(t),i=chunkTXIO5WYQ_cjs.kf(n,o),s=new Map;for(let a of e)for(let l of Qt(a)){let u=chunkA5BTVPET_cjs.gd(l.children),c=f=>{if(f)for(let d of f.values()){let b=d.markerText===void 0||Jt.test(d.markerText);for(let v of [d.markerStyle.fontFamily,b?d.markerStyle.fontFamilyEastAsia:null]){let T=chunkNKZVMMHU_cjs.b(v??void 0);if(T===null)continue;let S=T.toLowerCase();s.has(S)||s.set(S,T);}}};c(chunkTXIO5WYQ_cjs.Md(u,r,i,Gt));for(let f of u){let d=chunkTXIO5WYQ_cjs.Lf(f);for(let b of d.contents)c(chunkTXIO5WYQ_cjs.Kf(b,r,i));}}return [...s.values()].sort((a,l)=>a.localeCompare(l))}function Qt(e){if(e.localName==="document"){for(let t of e.children)if(t.kind!=="textValue"&&t.localName==="body")return [t];return []}if(e.localName==="footnotes"||e.localName==="endnotes"){let t=[];for(let n of e.children)n.kind!=="textValue"&&(n.localName==="footnote"||n.localName==="endnote")&&t.push(n);return t}return [e]}var Zt="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",wt=256,en=31;function J(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunkA5BTVPET_cjs.pa}function ae(e,t){return e.attributes.find(n=>n.localName===t&&n.namespaceUri===chunkA5BTVPET_cjs.pa)?.value}function xt(e){let t=(e.relationships.get(e.mainDocumentPart)??[]).find(i=>i.type===Zt),n=t?chunkA5BTVPET_cjs.N(t):void 0,r=((n?.mode==="Internal"&&n.target.ok?e.parts.get(n.target.partName):void 0)??e.parts.get("/word/fontTable.xml"))?.root;return r&&J(r,"fonts")?r:void 0}function bt(e,t){let n=e.children.find(o=>J(o,t));return n&&n.kind!=="textValue"?ae(n,"val"):void 0}function Et(e){let t=xt(e),n=new Map;if(!t)return n;let o=0;for(let r of t.children){if(!J(r,"font"))continue;if(++o>wt)break;let i=chunkE5BKDHIP_cjs.c(ae(r,"name"));if(!i)continue;let s=chunkV7CO55DO_cjs.S(bt(r,"family"),bt(r,"pitch")),a=i.trim().toLowerCase();s&&!n.has(a)&&n.set(a,s);}return n}function Ct(e){let t=xt(e),n=new Map;if(!t)return n;let o=0;for(let r of t.children){if(!J(r,"font"))continue;if(++o>wt)break;let i=chunkE5BKDHIP_cjs.c(ae(r,"name"));if(!i)continue;let s=r.children.find(c=>J(c,"altName")),a=s&&s.kind!=="textValue"?ae(s,"val"):void 0,l=a!==void 0&&a.length<=en?chunkE5BKDHIP_cjs.a(a):null,u=i.trim().toLowerCase();l&&!n.has(u)&&n.set(u,l);}return n}function Co(e,t,n,o=[]){let r=new Set,i=new Set((o??[]).map(a=>a.from.family.trim().toLowerCase())),s=new Map;for(let a of e.substitutions??[]){let l=a.from.family.trim().toLowerCase();s.has(l)||s.set(l,a.to.family.trim().toLowerCase());}for(let a of e.substitutions??[]){let l=a.from.family.trim().toLowerCase(),u=a.to.family.trim().toLowerCase(),c=[t.alternates.get(l),t.fallbacks.get(l)].some(f=>{let d=f?.trim().toLowerCase();return d!==void 0&&d!==l&&(d===u||s.get(d)===u)});u!==l&&!i.has(l)&&c&&!(n.resolve(a.from)instanceof chunkTXIO5WYQ_cjs.d)&&r.add(a.from.family.toLowerCase());}return r}function tn(e,t){return e.attributes.find(n=>n.localName===t&&n.namespaceUri===chunkA5BTVPET_cjs.pa)?.value}var nn=new Set(["document","hdr","ftr","footnotes","endnotes","comments","styles","numbering","glossaryDocument"]),on=new Set(["t","delText","instrText","delInstrText"]),rn=2e6;function sn(e,t){let n=e.stylesRoot(),o=e.documentThemeFonts(),r=[...chunkTXIO5WYQ_cjs.F(n),...n?chunkTXIO5WYQ_cjs.xd(n).run:[]],i=chunkTXIO5WYQ_cjs.ma(r,o),s=chunkE5BKDHIP_cjs.a(i.fontFamily??void 0)??t,a=chunkE5BKDHIP_cjs.a(chunkTXIO5WYQ_cjs.Bc([{text:"\xE9",props:r,style:i,start:0,end:1}],o)[0]?.style.fontFamily??void 0)??s,l=chunkE5BKDHIP_cjs.a(i.fontFamilyEastAsia??void 0),u=chunkE5BKDHIP_cjs.a(i.complexLane?.fontFamily??void 0)??o.minorBidi??t,c=Et(e.currentPackage()),f=g=>c.get(g.trim().toLowerCase())??chunkV7CO55DO_cjs.T(g),d=(g,E)=>{let y=f(g);if(!y)return E;let M=f(E);return M===void 0||M===y?E:chunkV7CO55DO_cjs.U[y]},b=new Map,v=new Map,T=0;for(let g of e.currentPackage().parts.values()){if(g.root.namespaceUri!==chunkA5BTVPET_cjs.pa||!nn.has(g.root.localName))continue;let E=[g.root];for(;E.length>0&&T<rn;){T++;let y=E.pop();if(y.kind!=="textValue"){if(y.namespaceUri===chunkA5BTVPET_cjs.pa){if(on.has(y.localName))continue;if(y.localName==="rFonts"){for(let[M,R]of [["ascii",s],["hAnsi",a],["eastAsia",l],["cs",u]]){let D=chunkE5BKDHIP_cjs.a(chunkE5BKDHIP_cjs.b(tn(y,M))??void 0);if(!D||!R)continue;let F=D.trim().toLowerCase(),k=b.get(F)??new Set,X=M==="ascii"||M==="hAnsi",q=X?d(D,R):R;if(k.add(q),b.set(F,k),X&&f(D)){let B=v.get(F)??new Set;B.add(q),v.set(F,B);}}continue}}for(let M of y.children)E.push(M);}}}for(let g of chunkA5BTVPET_cjs.a)b.delete(g);let S=new Map,P=[];for(let[g,E]of b){let y=v.get(g);E.size===1?S.set(g,[...E][0]):y?.size===1?S.set(g,[...y][0]):P.push(g);}return {fallbacks:S,ambiguousFamilies:P,defaults:new Map([...b].map(([g,E])=>[g,[...E]]))}}function an(e,t,n=[],o="Calibri"){let r=Ct(e.currentPackage()),i=sn(e,o),s=t.flatMap(u=>{let c=r.get(u.trim().toLowerCase());return c?[c]:[]}),a=new Map,l=t.flatMap(u=>i.defaults.get(u.trim().toLowerCase())??[]).filter(u=>u.trim().toLowerCase()!==o.trim().toLowerCase());for(let u of [...t,...s,...n,...l]){let c=chunkE5BKDHIP_cjs.a(u);if(c&&!a.has(c.trim().toLowerCase())&&a.set(c.trim().toLowerCase(),c),a.size===nt)break}return {families:[...a.values()],alternates:r,fallbacks:i.fallbacks,ambiguousFamilies:i.ambiguousFamilies}}function So(e,t,n){let o=te(n),r=an(e,t,[],o);return {plan:r,request:{families:r.families,defaultFamily:o}}}function Oo(e,t,n=t.fallbacks){let o=new Map(e.sources.map(u=>[chunkTXIO5WYQ_cjs.h(u.request),u.request])),r=[],i=new Set((e.substitutions??[]).map(u=>chunkTXIO5WYQ_cjs.h(u.from))),s=new Map((e.substitutions??[]).map(u=>[chunkTXIO5WYQ_cjs.h(u.from),u])),a=u=>{let c=o.get(chunkTXIO5WYQ_cjs.h(u));if(c)return {to:c};let f=s.get(chunkTXIO5WYQ_cjs.h(u)),d=f&&o.get(chunkTXIO5WYQ_cjs.h(f.to));if(!(!f||!d))return f.lineMetrics?{to:d,lineMetrics:f.lineMetrics}:{to:d}},l=Math.max(0,chunkTXIO5WYQ_cjs.b-i.size);for(let u of t.families){let c=u.trim().toLowerCase(),f=t.alternates.get(c),d=n.get(c),b=chunkA5BTVPET_cjs.ge(u);for(let v of [400,700])for(let T of ["normal","italic"]){let S={family:u,weight:v,style:T};if(o.has(chunkTXIO5WYQ_cjs.h(S)))continue;let P=s.has(chunkTXIO5WYQ_cjs.h(S));for(let g of P?[b,f]:[b,f,d]){if(!g||g.trim().toLowerCase()===c)continue;let E={family:g,weight:v,style:T},y=o.get(chunkTXIO5WYQ_cjs.h(E)),M=P?y?{to:y}:void 0:a(E);if(!M)continue;if(!i.has(chunkTXIO5WYQ_cjs.h(S))){if(l===0)break;l--;}let R=chunkV7CO55DO_cjs.R(u)?.em;r.push({from:S,...M,...R?{lineMetrics:R}:{}});break}}}return ee({...e,substitutions:[...r,...e.substitutions??[]]})}function Ao(e,t,n){let o=new Set((e.substitutions??[]).map(i=>chunkTXIO5WYQ_cjs.h(i.from))),r=new Set;for(let i of t.substitutions??[]){if(o.has(chunkTXIO5WYQ_cjs.h(i.from)))continue;let s=i.from.family.trim().toLowerCase(),a=i.to.family.trim().toLowerCase();[n.alternates.get(s),n.fallbacks.get(s)].some(u=>u?.trim().toLowerCase()===a)||r.add(s);}return r}function Ro(e,t){let n=new Map;for(let[o,r]of e)t(o)||n.set(o,r);return n}var ln={regular:{weight:400,style:"normal"},bold:{weight:700,style:"normal"},italic:{weight:400,style:"italic"},boldItalic:{weight:700,style:"italic"}};function Mo(e,t){let n=[],o=[],r=0;for(let i of e){let s=i.bytes.byteLength;if(!Number.isSafeInteger(s)||s>t||s>chunkTXIO5WYQ_cjs.a||s>chunkTXIO5WYQ_cjs.c-r){o.push(i);continue}r+=s,n.push(i);}return {sources:n,dropped:o}}function vo(e,t,n){let o=t.reduce((i,s)=>i+s.bytes.byteLength,0),r=new Set(t.filter(i=>i.request.family.trim().length>0).map(i=>chunkTXIO5WYQ_cjs.h(i.request)));return un(e,{maxFontBytes:n,aggregateBudget:Math.max(0,chunkTXIO5WYQ_cjs.c-o),shadowedRequests:r})}function un(e,t){let n=[],o=[],r=t.aggregateBudget,i=new Set;for(let s of e){let a=ln[s.style],l=Object.freeze({family:s.family,weight:a.weight,style:a.style});if(s.family.trim().length===0){o.push({request:l,partName:s.partName,reason:"malformed"});continue}let u=chunkTXIO5WYQ_cjs.h(l);if(!(t.shadowedRequests?.has(u)||i.has(u))){if(i.add(u),s.bytes.byteLength>t.maxFontBytes||s.bytes.byteLength>r){o.push({request:l,partName:s.partName,reason:"overLimit"});continue}r-=s.bytes.byteLength,n.push({request:l,id:`embedded:${s.partName}#${s.style}`,bytes:s.bytes,hash:chunkA5BTVPET_cjs.f(s.bytes),faceIndex:0});}}return {sources:n,dropped:o}}
2
+ exports.A=Wt;exports.B=no;exports.C=Co;exports.D=an;exports.E=So;exports.F=Oo;exports.G=Ao;exports.H=Ro;exports.I=Mo;exports.J=vo;exports.K=un;exports.a=Y;exports.b=mn;exports.c=nt;exports.d=ce;exports.e=gn;exports.f=ee;exports.g=te;exports.h=G;exports.i=it;exports.j=Rt;exports.k=st;exports.l=fe;exports.m=kt;exports.n=ft;exports.o=En;exports.p=Cn;exports.q=ge;exports.r=pe;exports.s=Sn;exports.t=On;exports.u=Nn;exports.v=ie;exports.w=se;exports.x=Ht;exports.y=Xn;exports.z=to;
@@ -0,0 +1 @@
1
+ import {Eb,cb,ib,kg,ig,Sa,Ra,Dm,pa,Ob,Gb,Fb,Ua,qa}from'./chunk-6MF5PN2E.js';var K=new Set(["document","hdr","ftr","footnotes","endnotes"]),rr=24,H=512,z=Eb(rr);function G(t){let n=t.root;return n.namespaceUri===pa&&K.has(n.localName)}function tr(t){let n=[],e=r=>{if(r.kind!=="textValue"){r.namespaceUri===pa&&r.localName==="p"&&n.push(r);for(let a of r.children)e(a);}};return e(t.root),n}function X(t){let n=Ob(t);let e=[],r=new Set;for(let a of tr(n)){let i=Gb(a);if(!i||!Fb(i))continue;let o=i.toUpperCase();if(r.has(o))continue;r.add(o);let l=Dm(n,a.id);l!==null&&e.push(Object.freeze({paragraphId:o,nodeId:a.id,text:l}));}return Object.freeze(e)}function er(t){let n=z.get(t.root);if(n)return n;let e=W(t,"byParagraphId");return z.set(t.root,e),e}function W(t,n){let e=Ob(t);let r=new Map,a=new Set,i=o=>{if(o.kind!=="textValue"){if(o.namespaceUri===pa&&o.localName==="p"){let l=Gb(o);if(l&&Fb(l)){let s=l.toUpperCase();a.has(s)||(a.add(s),o.kind==="paragraph"&&(n==="byParagraphId"?r.set(s,o.id):r.set(o.id,s)));}}for(let l of o.children)i(l);}};return i(e.root),r}function V(t,n){if(t.length!==n.length)return false;for(let e=0;e<t.length;e+=1)if(t[e].root!==n[e])return false;return true}function $(t){let n=new Map,e=null,r=(o,l,s)=>{for(n.delete(o),n.set(o,{partName:l.name,root:l.root,nodeId:s});n.size>H;){let d=n.keys().next();if(d.done)break;n.delete(d.value);}},a=(o,l)=>{let s=n.get(o);if(!s)return null;let d=l.find(k=>k.name===s.partName);if(!d)return null;if(d.root===s.root)return {part:d,nodeId:s.nodeId};let u=cb(d,s.nodeId);if(!u||u.kind!=="paragraph")return null;let x=Gb(u);return !x||x.toUpperCase()!==o?null:(r(o,d,s.nodeId),{part:d,nodeId:s.nodeId})};return Object.assign(o=>{let l=t(),s=a(o,l);if(s)return s;if(e&&e.ids.has(o)&&V(l,e.roots))return null;for(let d of l){let u=er(d).get(o);if(u!==void 0)return r(o,d,u),{part:d,nodeId:u}}return (!e||!V(l,e.roots))&&(e={roots:l.map(d=>d.root),ids:new Set}),e.ids.size<H&&e.ids.add(o),null},{forgetIds(o){for(let{paragraphId:l,nodeId:s}of o)n.get(l)?.nodeId!==s&&n.delete(l);},forgetAll(){n.clear();},hasHints(){return n.size>0}})}function Y(t,n,e){if(!t.hasHints())return;let r=[...e.dirty,...e.created];if(e.impact!=="text-local"||r.length===0)return t.forgetAll();let a=[];for(let i of r){let o=n.find(d=>i.startsWith(`${d.name}#`)),l=o?cb(o,i):null,s=l?.kind==="paragraph"?Gb(l):null;if(!s)return t.forgetAll();a.push({paragraphId:s.toUpperCase(),nodeId:i});}t.forgetIds(a);}function q(t){let n=null;return e=>{let r=t();n?.root!==r.root&&(n={root:r.root,byNodeId:W(r,"byNodeId")});let a=n.byNodeId.get(e);if(a===void 0)return null;let i=Dm(r,e);return i===null?null:Object.freeze({paragraphId:a,nodeId:e,text:i})}}function Z(t,n){return Ua(t,n)}var or=Object.freeze({kind:"body"}),ar=1e6;function A(t,n){if(n<=0||n>=t.length)return false;let e=t.charCodeAt(n-1),r=t.charCodeAt(n);return e>=55296&&e<=56319&&r>=56320&&r<=57343}function ir(t,n,e){if(n===e)return [];let r=0,a=Math.min(n.length,e.length);for(;r<a&&n.charCodeAt(r)===e.charCodeAt(r);)r+=1;for(;r>0&&(A(n,r)||A(e,r));)r-=1;let i=0;for(;i<n.length-r&&i<e.length-r&&n.charCodeAt(n.length-i-1)===e.charCodeAt(e.length-i-1);)i+=1;for(;i>0&&(A(n,n.length-i)||A(e,e.length-i));)i-=1;let o=n.length-r-i,l=e.slice(r,e.length-i),s=[];return o>0&&s.push({op:"deleteText",paragraphId:t,start:r,end:r+o}),l.length>0&&s.push({op:"insertText",paragraphId:t,offset:r,text:l}),Object.freeze(s)}function lr(t){let n=r=>!!r&&r.kind!=="textValue"&&r.namespaceUri===pa&&r.localName==="t"&&r.attributes.every(a=>a.namespaceUri===qa&&a.localName==="space")&&r.children.every(a=>a.kind==="textValue"),e=[];for(let r of t){let a=e.at(-1);if(!n(a)||!n(r)){e.push(r);continue}let i=a.children.map(o=>o.kind==="textValue"?o.value:"").join("")+r.children.map(o=>o.kind==="textValue"?o.value:"").join("");e[e.length-1]={...a,attributes:/^\s|\s$/.test(i)?[{kind:"xmlSpace",namespaceUri:qa,localName:"space",prefix:"xml",value:"preserve"}]:[],children:[{id:a.children[0]?.id??`${a.id}/text`,kind:"textValue",value:i}]};}return e}function F(t){if(t.kind==="textValue")return t;let n=false,e=t.children.map(r=>{let a=F(r);return a!==r&&(n=true),a});if(t.namespaceUri===pa&&t.localName==="r"){let r=lr(e);(r.length!==e.length||r.some((a,i)=>a!==e[i]))&&(e=[...r],n=true);}return n?{...t,children:e}:t}function sr(t,n,e){let r=t.parts.get(n);if(!r)return t;let a=false,i=new Set;for(let o of e)(o.op==="insertText"||o.op==="deleteText")&&!o.revision&&i.add(o.paragraphId);for(let o of i){let l=cb(r,o);if(!l||l.kind==="textValue")continue;let s=F(l);if(s===l)continue;let d=ib(r,o,s,{deferValidation:true});d.ok&&(r=d.part,a=true);}return a?kg(t,r):t}function dr(t,n){let e=n.documentId.trim();if(e.length===0||e.length>256)throw new TypeError("documentId must contain 1 to 256 characters");let r=()=>X(t.bodyStore().part),a,i=()=>{let p=t.bodyStore().part,c=t.currentPackage();if(a?.pkg===c&&a.body===p)return a.parts;let g=[p];for(let m of c.parts.values())m===p||!G(m)||g.push(m);return a={pkg:c,body:p,parts:Object.freeze(g)},a.parts},o=$(i),l=t.packageRevision,s=t.lastModelChange,d=()=>{let p=t.packageRevision,c=t.lastModelChange;p===l&&c===s||(p===l+1&&c!==null&&c!==s?Y(o,i(),c):o.forgetAll(),l=p,s=c);},u=q(()=>t.bodyStore().part),x=(p,c)=>{if(p.length===0)return {ok:true,changed:false};let g=r(),m=new Set,O=[];for(let h of p){if(typeof h.text!="string"||h.text.length>ar)return {ok:false,reason:"collaboration-text-limit"};if(typeof h.paragraphId!="string"||h.paragraphId.length===0||h.paragraphId.length>256)return {ok:false,reason:"unknown-paragraph-id"};let f=h.paragraphId.toUpperCase();if(m.has(f))return {ok:false,reason:"duplicate-paragraph-id"};m.add(f);let D=g.filter(Q=>Q.paragraphId===f);if(D.length!==1)return {ok:false,reason:"unknown-paragraph-id"};let w=D[0];O.push(...ir(w.nodeId,w.text,h.text));}if(O.length===0)return {ok:true,changed:false};let v=t.transact(or,h=>{for(let f of O)h.apply(f);h.applyPackage(f=>sr(f,f.mainDocumentPart,O));},{origin:c.origin,actorId:c.actorId,operationId:c.operationId,recordsHistory:false});return v.ok?{ok:true,changed:v.change!==null}:{ok:false,reason:v.detail??v.reason}},k={documentId:e,interactive:n.interactive===true,paragraphs:r,paragraphByNodeId:u,paragraphTextOf(p){for(let c of i()){let g=Dm(c,p);if(g!==null)return g}return null},paragraphByStableId(p){let c=p.toUpperCase();d();let g=o(c);if(!g)return null;let m=Dm(g.part,g.nodeId);return m===null?null:Object.freeze({paragraphId:c,nodeId:g.nodeId,text:m})},applyParagraphText(p,c,g){return x([{paragraphId:p,text:c}],g)},applyParagraphTexts:x,applyRemotePackage(p,c){let g=t.publishRemotePackage(p,c);return g.ok?{ok:true,changed:g.change!==null}:{ok:false,reason:g.detail??g.reason}},revision:()=>t.packageRevision,subscribe:p=>t.subscribe(p),observePrimitiveJournal:p=>Z(t,p),hasPendingJournals:()=>Ra(t),flushPendingJournals:()=>{Sa(t);},save:()=>ig(t.currentPackage()),binaryPart(p){let c=t.currentPackage();return c.partBytes.get(p)??c.partBytes.get(p.startsWith("/")?p.slice(1):`/${p}`)??null}};return Object.freeze(k)}function pr(t,n,e){if(n===e||t>n.length)return Math.min(t,e.length);let r=0;for(;r<n.length&&r<e.length&&n[r]===e[r];)r+=1;let a=0;for(;a<n.length-r&&a<e.length-r&&n[n.length-1-a]===e[e.length-1-a];)a+=1;if(t<=r)return Math.min(t,e.length);if(t>n.length-a)return Math.min(e.length,t+e.length-n.length);let i=ur(n,e,r,a),o=i.offsets.get(t);return o===void 0&&(o=(i.table?mr(i.table,t,n,e,r):null)??yr(t,n,e,r,a)??r,i.offsets.set(t,o)),o}var b=[],cr=16;function ur(t,n,e,r){let a=b.findIndex(o=>o.before===t&&o.after===n);if(a>=0){let[o]=b.splice(a,1);return b.push(o),o}let i={before:t,after:n,table:hr(t,n,e,r),offsets:new Map};return b.length>=cr&&b.shift(),b.push(i),i}var gr=1<<18;function hr(t,n,e,r){let a=t.length-r-e,i=n.length-r-e;if(a*i>gr)return null;let o=i+1,l=new Uint32Array((a+1)*o);for(let s=a-1;s>=0;s-=1)for(let d=i-1;d>=0;d-=1)l[s*o+d]=t[e+s]===n[e+d]?l[(s+1)*o+d+1]+1:Math.max(l[(s+1)*o+d],l[s*o+d+1]);return {lengths:l,width:o,columns:i}}function mr(t,n,e,r,a){let{lengths:i,width:o,columns:l}=t,s=n-a,d=0,u=0;for(;d<s;)u<l&&e[a+d]===r[a+u]?(d+=1,u+=1):u>=l||i[(d+1)*o+u]>=i[d*o+u+1]?d+=1:u+=1;return a+u}var fr=[32,16,8,4];function yr(t,n,e,r,a){let i=e.slice(r,e.length-a),o=l=>{let s=i.indexOf(l);return s>=0&&i.indexOf(l,s+1)<0?s:null};for(let l of fr){let s=n.slice(Math.max(r,t-l),t);if(s.length===l){let u=o(s);if(u!==null)return r+u+s.length}let d=n.slice(t,Math.min(n.length-a,t+l));if(d.length===l){let u=o(d);if(u!==null)return r+u}}return null}export{sr as a,dr as b,pr as c};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkA5BTVPET_cjs=require('./chunk-A5BTVPET.cjs');var w=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u,j="Cambria";function $(e){return e!==void 0&&e.trim().length>0&&w.test(e)?e:null}function Q(e){if(e===void 0||e.trim().length===0)return null;if(e.length>1024)return j;let n=v(e);return n.length===0?null:w.test(n)?n:n.startsWith("@")||n.startsWith("\uFF20")?n.length<=128?n:null:j}function Z(e){return e===void 0||e.length>1024?null:$(v(e))}function v(e){let n=e.indexOf(",");return (n<0?e:e.slice(0,n)).trim()}function W(e){return e.kind!=="textValue"}function S(e,n){for(let l of e.children)if(W(l)&&l.localName===n)return l}function V(e,n){return e.attributes.find(l=>l.localName===n)?.value}function ne(e){let n=S(e,"pPr"),l=n?S(n,"outlineLvl"):void 0;if(l){let o=V(l,"val");return o!==void 0&&/^[0-8]$/.test(o)?Number(o):null}let t=S(e,"name"),i=t?/^heading\s+([1-9])$/i.exec(V(t,"val")?.trim()??""):null;return i?Number(i[1])-1:null}function R(e,n=0,l=e.length,t){let i=new Set,o=new Map,d=new Map,u=t?[t]:[];t&&i.add(t);for(let s=n;s<l;s+=1){let r=e[s].node;if(chunkA5BTVPET_cjs.Vg(r,"begin")){u.push(r.id);continue}if(chunkA5BTVPET_cjs.Vg(r,"separate")){let a=u[u.length-1];a&&(i.add(a),o.set(r.id,a));continue}if(chunkA5BTVPET_cjs.Vg(r,"end")){let a=u.pop();a&&(i.add(a),d.set(r.id,a));}}return {activeBegins:i,separateBegin:o,endBegin:d}}function b(e,n,l){if(chunkA5BTVPET_cjs.Vg(l,"begin"))return n.activeBegins.has(l.id)&&e.push({beginId:l.id,separated:false}),true;if(chunkA5BTVPET_cjs.Vg(l,"separate")){let t=n.separateBegin.get(l.id),i=e[e.length-1];return t&&i?.beginId===t&&(i.separated=true),true}if(chunkA5BTVPET_cjs.Vg(l,"end")){let t=n.endBegin.get(l.id),i=e[e.length-1];return t&&i?.beginId===t&&e.pop(),true}return false}function g(e){for(let n of e)if(!n.separated)return false;return true}function ie(e,n){let l=[];chunkA5BTVPET_cjs.fh(e,l,n);let t=R(l),i=[];return {consume:o=>b(i,t,o),visible:()=>g(i)}}function C(e,n){return e==="original"?n.hiddenInOriginal:e==="current"&&n.hiddenInCurrent}var U=4096,H=chunkA5BTVPET_cjs.gh*16;function k(){return {out:[],runs:[],symbols:[],symbolDisplays:[],length:0}}function X(e,n,l,t){if(n.length===0||l===t)return;let i=e.runs[e.runs.length-1];if(i?.runId===n&&i.end===l){e.runs[e.runs.length-1]={runId:n,start:i.start,end:t};return}e.runs.push({runId:n,start:l,end:t});}function O(e,n,l,t){let i=chunkA5BTVPET_cjs.eh(n);if(i.length>t.left)return false;if(t.left-=i.length,i.length>0){let o=e.length;chunkA5BTVPET_cjs.ob(n)&&(e.symbols.push(o),e.symbolDisplays.push(chunkA5BTVPET_cjs.Sl(n))),e.out.push(i),e.length+=i.length,X(e,l,o,e.length);}return true}function z(e,n){let l=e.length;n.text.length>0&&e.out.push(n.text),e.length+=n.text.length;for(let t of n.runs)X(e,t.runId,l+t.start,l+t.end);for(let t of n.symbols??[])e.symbols.push(l+t);for(let t of n.symbolDisplays??[])e.symbolDisplays.push(t);}function T(e){let n=e.out.join("");return e.symbols.length>0?{text:n,runs:e.runs,symbols:e.symbols,symbolDisplays:e.symbolDisplays}:{text:n,runs:e.runs}}var G=Object.freeze({text:"",runs:[]});function M(){return {text:chunkA5BTVPET_cjs.Qg,runs:[]}}function q(e,n,l,t){let i=[];if(!chunkA5BTVPET_cjs.fh(e,i,l))return null;let o=i.reverse(),d=k();for(;o.length>0;){let u=o.pop();if(!C(n,u)){if(chunkA5BTVPET_cjs.Yg(u.node)){let s=[];if(!chunkA5BTVPET_cjs.fh(u.node,s,l))return null;for(let r=s.length-1;r>=0;r-=1)o.push(s[r]);continue}if(!chunkA5BTVPET_cjs.Wg(u.node)&&!O(d,u.node,u.runId,t))return null}}return T(d)}function J(e,n,l,t,i){let o=k(),d=[],u=R(e);for(let s of e){let r=s.node;if(!b(d,u,r)&&!chunkA5BTVPET_cjs.Wg(r)&&g(d)&&!C(n,s)){if(chunkA5BTVPET_cjs.Yg(r)){let a=i>=chunkA5BTVPET_cjs.hh?q(r,n,l,t):Y(r,n,l,t,i+1);if(a===null)return null;z(o,a);continue}if(!O(o,r,s.runId,t))return null}}return T(o)}function Y(e,n,l,t,i){let o=[];return chunkA5BTVPET_cjs.fh(e,o,l)?J(o,n,l,t,i):null}function K(e,n,l){let t=n.node;return e.owned.has(t.id)&&(e.nodesLeft-=1,e.nodesLeft<0&&(e.overflow=true)),t.id===e.endId?true:(t.id===e.span.node.id||b(e.states,e.markers,t)||e.overflow||chunkA5BTVPET_cjs.Wg(t)||chunkA5BTVPET_cjs.Yg(t)||!e.owned.has(t.id)||!g(e.states)||C(l,n)||O(e.result,t,n.runId,e.chars)||(e.overflow=true),false)}function ae(e,n,l="allMarkup"){let t=new Map,i=new Map,o=new Map;for(let r of n)r.kind==="complex"?i.set(r.node.id,r):o.set(r.node.id,r);let d=[];chunkA5BTVPET_cjs.fh(e,d);let u=new Map;for(let r=0;r<d.length;r+=1)u.set(d[r].node.id,r);let s=null;for(let r=0;r<d.length;r+=1){let a=d[r],y=o.get(a.node.id);if(y)if(s!==null&&!g(s.states))t.set(y.node.id,G);else {let f={left:U},I={left:H},m=Y(y.node,l,f,I,0);t.set(y.node.id,m??M());}if(s===null){let f=i.get(a.node.id);if(!f)continue;let I=new Set(f.removeNodeIds),m=-1;for(let N=f.removeNodeIds.length-1;N>=0;N-=1){let F=u.get(f.removeNodeIds[N]);if(!(F===void 0||F<=r)&&chunkA5BTVPET_cjs.Vg(d[F].node,"end")){m=F;break}}let E=d[m];if(!E){t.set(f.node.id,M());continue}s={span:f,owned:I,states:[{beginId:f.node.id,separated:false}],markers:R(d,r+1,m,f.node.id),endId:E.node.id,result:k(),chars:{left:H},nodesLeft:U,overflow:false};}K(s,a,l)&&(t.set(s.span.node.id,s.overflow?M():T(s.result)),s=null);}return s!==null&&t.set(s.span.node.id,M()),t}exports.a=$;exports.b=Q;exports.c=Z;exports.d=ie;exports.e=U;exports.f=ae;exports.g=ne;