@docx-editor.dev/core 2.24.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +46 -16
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +8 -8
- package/dist/binding.js +1 -1
- package/dist/chunk-2BK4G4ZN.js +2 -0
- package/dist/chunk-2SJX44PC.cjs +2 -0
- package/dist/chunk-5BIASAN3.js +1 -0
- package/dist/{chunk-2LXGB2X7.js → chunk-6SEIXJTX.js} +1 -1
- package/dist/chunk-73PG6L2X.js +1 -0
- package/dist/chunk-7RJSH72J.cjs +5 -0
- package/dist/chunk-AGKIHLWQ.cjs +1 -0
- package/dist/chunk-AN6WM4X4.js +2 -0
- package/dist/chunk-ANZ44KQT.cjs +12 -0
- package/dist/chunk-CYT3OQFZ.cjs +1 -0
- package/dist/chunk-DDGGSBAN.js +12 -0
- package/dist/chunk-EEAV3WIN.js +3 -0
- package/dist/{chunk-JDAAGZNE.cjs → chunk-ELQFXMJ5.cjs} +1 -1
- package/dist/chunk-EYK4K2J6.js +1 -0
- package/dist/chunk-JNTETUNZ.cjs +1 -0
- package/dist/chunk-L6V3IJ3S.js +5 -0
- package/dist/chunk-LWCI65EL.js +1 -0
- package/dist/chunk-LZDI4P6I.cjs +1 -0
- package/dist/chunk-NS22DVWT.cjs +2 -0
- package/dist/chunk-QIE3YTU4.cjs +2 -0
- package/dist/chunk-QVBFPAGO.js +5 -0
- package/dist/chunk-RCCOLZEQ.js +2 -0
- package/dist/chunk-SUN62YU6.cjs +5 -0
- package/dist/chunk-TKR2MXX4.cjs +3 -0
- package/dist/chunk-UJL2GDIM.cjs +25 -0
- package/dist/chunk-WQTADNHK.cjs +27 -0
- package/dist/chunk-XSHXBJ2J.js +25 -0
- package/dist/chunk-YXZEBTDF.js +27 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +4 -4
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +3 -3
- package/dist/contracts/document.d.ts +2 -2
- package/dist/contracts/editor.d.ts +8 -8
- package/dist/contracts/modules.d.ts +6 -6
- package/dist/contracts/types.d.ts +1 -1
- package/dist/{custom-node-writes-77rvPW2-.d.ts → custom-node-writes-Cy9imOjA.d.ts} +2 -2
- package/dist/{document-protection-CYIjO-li.d.ts → document-protection-Bp19Ad4I.d.ts} +1 -1
- package/dist/{editor-BU6rjQZz.d.ts → editor-DYUlyKmb.d.ts} +145 -9
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +15 -1
- package/dist/editor.d.ts +179 -34
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +12 -12
- package/dist/export.js +2 -2
- package/dist/{font-resolver-CPO7wtg6.d.ts → font-resolver-u_nE0PI1.d.ts} +5 -3
- package/dist/{headless-document-view-Cc3fFWhv.d.ts → headless-document-view-R9bzzepb.d.ts} +2 -2
- package/dist/{image-resources-DkuzBnTM.d.ts → image-resources-DfagDguq.d.ts} +1 -1
- package/dist/{index-BOkQYOsZ.d.ts → index-Docw8Dcb.d.ts} +333 -308
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-BOOxnLxF.d.ts → layout-shaping-DWitwY73.d.ts} +2 -2
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +99 -33
- package/dist/layout.js +1 -1
- package/dist/{note-properties-DMfKK3QU.d.ts → note-properties-CmfvOJsi.d.ts} +1 -1
- package/dist/{omml-equation-BY7OdfGY.d.ts → omml-equation-CZ6IG2ja.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +7 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-CPAakntQ.d.ts → protocol-DniKeDb8.d.ts} +71 -23
- package/dist/{review-paragraph-order-B0BP_wJP.d.ts → review-paragraph-order-Dc8Q6tfM.d.ts} +6 -2
- package/dist/{revision-projection-CVJeA2jp.d.ts → revision-projection-DfWxdBqA.d.ts} +1 -1
- package/dist/{semantic-cell-selection-BtO2s2Za.d.ts → semantic-cell-selection-Dy_BmmpL.d.ts} +25 -7
- package/dist/{semantic-interaction-COMnWyBQ.d.ts → semantic-interaction-CvFAj0GR.d.ts} +1 -1
- package/dist/{semantic-paint-C032N0ps.d.ts → semantic-paint-Bk9wIXdZ.d.ts} +2 -2
- package/dist/{semantic-records-BSjo-xck.d.ts → semantic-records-COqi8pjP.d.ts} +83 -76
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +90 -41
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-BIyGh6L8.d.ts → tree-package-fragment-YPyYC1aD.d.ts} +9 -4
- package/dist/{tree-session-contract-CHcCnz3W.d.ts → tree-session-contract-AeY2v0x9.d.ts} +8 -6
- package/dist/{types-barrel-DN_-gaRX.d.ts → types-barrel-BO73JqHG.d.ts} +44 -30
- package/package.json +4 -4
- package/dist/chunk-3OMDEMLL.js +0 -1
- package/dist/chunk-6CPYOVRT.cjs +0 -1
- package/dist/chunk-AKF5KM2W.cjs +0 -4
- package/dist/chunk-BOGQGMMU.cjs +0 -1
- package/dist/chunk-CVNDMQIX.cjs +0 -26
- package/dist/chunk-DF7F7TNU.cjs +0 -1
- package/dist/chunk-G765WG4R.js +0 -1
- package/dist/chunk-IEXYOLNR.cjs +0 -5
- package/dist/chunk-J3EM5ZEA.js +0 -18
- package/dist/chunk-JNE6QF47.js +0 -26
- package/dist/chunk-JQTVFP72.cjs +0 -2
- package/dist/chunk-JXL25DRU.js +0 -11
- package/dist/chunk-KPSGB64S.js +0 -1
- package/dist/chunk-P4SBMHHO.cjs +0 -5
- package/dist/chunk-QQAF64KN.js +0 -5
- package/dist/chunk-SI5FLZGU.js +0 -4
- package/dist/chunk-SOUJNWXV.js +0 -1
- package/dist/chunk-T4TKRNZT.cjs +0 -11
- package/dist/chunk-TBFZZX7Z.cjs +0 -1
- package/dist/chunk-VPKKYCZI.cjs +0 -2
- package/dist/chunk-W3ZUPQIZ.cjs +0 -18
- package/dist/chunk-XMWH2R23.js +0 -5
- package/dist/chunk-XWXJB4J7.js +0 -1
- package/dist/chunk-YIBEBHT3.js +0 -2
- package/dist/chunk-ZSM6X52G.cjs +0 -1
- package/dist/chunk-ZXAGLAY2.js +0 -2
package/dist/chunk-XMWH2R23.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {c,d,$g,p,f,k,j,i,fa,if as _if,uj,eg,Pd as Pd$1,Ua,Qd as Qd$1,N,x,Ta,tj,Ve,Vg,La,Nd as Nd$1,za,Wd as Wd$1,Vd as Vd$1,Ud as Ud$1,Ld as Ld$1,Ea,Fa,ib,b,Vf,Ni as Ni$1,Oi,xa,Xd as Xd$1,Ej,Ug,jh,Sg,Tg,Of,Pf,Cj,E,gb,O,Ye,jb,kb,hb,cb,Na,Wg,Xg,_g,Zg,hh,ih,Ab,Eh,zh,Jh,Dh,Ch,xh,Mh,yh,Lh,Fh,Bh as Bh$1,mi,oi,ki,dh,eh,Ha,db,rj,_e as _e$1,Zi as Zi$1,Ti as Ti$1,Yi as Yi$1,_i as _i$1,Te,Ma,yi,ni,Bi as Bi$1,si,pi,Ka,wi as wi$1,ti,ui,Ja,Ai as Ai$1,vi,ri,ji as ji$1,Ci as Ci$1,Kf,fe,ge,ph,oh,Ff,w,sa,Jf,a,Dd as Dd$1,Td as Td$1,Xi as Xi$1,Pi,Ri,Wh,ai,Mi as Mi$1,bh,ia,sj,oj,df,fh,Cc as Cc$1,Oa,Fd as Fd$1,Ad as Ad$1,Cd as Cd$1,Gd as Gd$1,Id as Id$1,bj,Jd as Jd$1,Qc as Qc$1,Yg,wh,eb,$a,Za,qe as qe$1,md as md$1,zd as zd$1,qi as qi$1,qj,ed as ed$1,Yc as Yc$1,Zc as Zc$1,$c as $c$1,F,va,g,wa,u,li,qg,Se,Ue,yb,Wi as Wi$1,Vi as Vi$1,ff,mg,ng,lb,ad as ad$1,ua,P,hf,X,pj,Lf,kj,lj,ga,xd as xd$1,yd as yd$1,wd as wd$1}from'./chunk-JXL25DRU.js';import {strFromU8,strToU8}from'fflate';var fd=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],gd=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,hd=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Si(e){return gd.test(e)||hd.test(e)}function Mn(e,t){if(!Si(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 yd=/^(\d+)\.(\d+)\.(\d+)$/;function it(e){let t=yd.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 Dn(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 An(e,t){let n=it(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=it(r.slice(1));return Dn(n,o)<0?false:o.major>0?n.major===o.major:o.minor>0?n.major===0&&n.minor===o.minor:n.major===0&&n.minor===0}if(r.includes(" ")){let o=r.split(/\s+/);if(o.length!==2)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let i=true;for(let a of o){let s=a.startsWith(">=")?">=":a.startsWith("<")?"<":null;if(!s)throw new Error(`unsupported version range: ${JSON.stringify(t)}`);let l=it(a.slice(s.length)),d=Dn(n,l);s===">="?i=i&&d>=0:i=i&&d<0;}return i}return Dn(n,it(r))===0}var ye=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Dr=(e,t)=>`${e}:${t}`;function xd(e,t={}){let n=new Map;for(let d of e){if(Mn(d.id,"extension"),wi(d.version,d.id),n.has(d.id))throw new ye("duplicate-extension",`duplicate extension id ${d.id}`,[d.id]);n.set(d.id,d);for(let c of d.contributions)Mn(c.id,c.kind),wi(c.version,`${d.id} \u2192 ${c.id}`),c.replaces&&Pd(c.replaces.targetRange,`${d.id} \u2192 replaces ${c.replaces.targetId}`);}for(let d of e){for(let c of d.dependencies??[])if(!n.has(c))throw new ye("missing-dependency",`${d.id} requires missing extension ${c}`,[d.id,c]);for(let c of d.conflicts??[])if(n.has(c)){let u=[d.id,c].sort();throw new ye("conflict",`extensions ${u[0]} and ${u[1]} conflict`,u)}}Rd(n);let r=new Set(t.availablePorts??[]);for(let d of e)for(let c of d.contributions)c.kind==="runtimePort"&&r.add(c.id);for(let d of e)for(let c of d.requiredPorts??[])if(!r.has(c))throw new ye("missing-port",`${d.id} requires unavailable port ${c}`,[d.id,c]);let o=new Map,i=new Map,a=new Map;for(let d of e)for(let c of d.contributions){let u=Dr(c.kind,c.id);if(c.replaces){let p=Dr(c.kind,c.replaces.targetId),R=a.get(p)??[];R.push({ext:d.id,c}),a.set(p,R);continue}if(i.has(u)){let p=[o.get(u),d.id].sort();throw new ye("id-collision",`${c.kind} id ${c.id} registered by both ${p[0]} and ${p[1]}`,p)}i.set(u,c),o.set(u,d.id);}let s=new Map(i);for(let[d,c]of a){let u=i.get(d);if(!u){let m=c[0];throw new ye("replacement-target-missing",`${m.ext} replaces missing target ${m.c.replaces.targetId}`,[m.ext,m.c.replaces.targetId])}let p=u.replaceable??{kind:"none"};for(let{ext:m,c:g}of c){if(!An(u.version,g.replaces.targetRange))throw new ye("replacement-version-mismatch",`${m} replaces ${g.replaces.targetId}@${u.version} outside range ${g.replaces.targetRange}`,[m,g.replaces.targetId]);if(p.kind==="none")throw new ye("unauthorized-replacement",`${g.replaces.targetId} does not authorize replacement (attempted by ${m})`,[m,g.replaces.targetId])}let R=kd(u,c);s.set(d,R);}return {extensions:n,contributions:s,get:(d,c)=>s.get(Dr(d,c))}}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)),i=o[0].c.replaces.priority??0,a=o.filter(s=>(s.c.replaces.priority??0)===i);if(a.length>1){let s=a.map(l=>l.ext).sort();throw new ye("ambiguous-replacement",`multiple replacers of ${e.id} share top priority ${i}: ${s.join(", ")}`,s)}return o[0].c}let r=t.map(o=>o.ext).sort();throw new ye("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function Rd(e){let o=new Map,i=[],a=s=>{o.set(s,1),i.push(s);let l=[...e.get(s)?.dependencies??[]].sort();for(let d of l){let c=o.get(d)??0;if(c===1){let u=i.indexOf(d),p=[...i.slice(u),d];throw new ye("dependency-cycle",`dependency cycle: ${p.join(" -> ")}`,p)}c===0&&a(d);}i.pop(),o.set(s,2);};for(let s of [...e.keys()].sort())(o.get(s)??0)===0&&a(s);}function wi(e,t){try{it(e);}catch{throw new ye("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function Pd(e,t){try{An("0.0.0",e);}catch{throw new ye("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var st=class extends Error{constructor(t){super(t),this.name="BudgetError";}},zt=class e{constructor(t,n){this.label=t;this.capacity=n;this.used=new p(`${t}.budget`,n);}label;capacity;used;children=new Set;activeReservations=0;cleanups=[];disposed=false;carveAmount=0;parent;get inUse(){return this.used.current}get available(){return this.used.remaining}get isDisposed(){return this.disposed}reserve(t){this.assertLive(),this.used.add(t),this.activeReservations+=1;let n=false,r=this;return {amount:t,get released(){return n},release(){n||(n=true,r.used.release(t),r.activeReservations-=1);}}}child(t,n){this.assertLive(),this.used.add(n);let r=new e(t,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(t){this.assertLive(),this.cleanups.push(t);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new st(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new st(`${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 st(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new st(`${this.label}: budget already released`)}};var _n=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},Kt=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 _n(t.derivedOnly,t._reason)}}}};var Fn=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},Ar=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 Fn(t);return this.ports.get(t)}missing(t){return t.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(f.clock)}identity(){return this.resolve(f.identity)}},_r=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}},Fr=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function vd(e){let t=k(e.limits),n=Object.freeze({...e.config??{}}),r=e.capacity??t.maxDecompressedBytes,o=e.id??"op",i={id:o,limits:t,config:n,ports:e.ports,budget:new zt(`op:${o}`,r),cancellation:new Kt};return Object.freeze(i)}function Od(e){e.budget.dispose();}var $r=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"}}),Ni=Object.keys($r);function Id(e,t){return new p(`${$r[t].phase}:${t}`,e[t])}var Lr=class{counter;current=0;peak=0;constructor(t){this.counter=new p("memory",t);}allocate(t){this.counter.add(t),this.current+=t,this.current>this.peak&&(this.peak=this.current);}free(t){this.counter.release(t),this.current=Math.max(0,this.current-t);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function bd(){for(let e of Ni){let t=j[e],n=i[e];if(!Number.isFinite(t)||t<=0)throw new Error(`default ${e} must be finite > 0`);if(!Number.isFinite(n)||n<=0)throw new Error(`ceiling ${e} must be finite > 0`);if(t>n)throw new Error(`default ${e} exceeds ceiling`)}}function Gt(e,t=new Set){let n=new WeakSet,r=[],o=i=>{if(i===null)return "null";let a=typeof i;if(a==="boolean")return i?"true":"false";if(a==="number"){let l=i;if(!Number.isFinite(l))throw new Error(`non-finite number is not comparable: ${l}`);return Object.is(l,-0)?"0":String(l)}if(a==="string")return JSON.stringify(i);if(a==="bigint")return `${i.toString()}n`;if(Array.isArray(i))return `[${i.map((l,d)=>{r.push(d);try{return o(l)}finally{r.pop();}}).join(",")}]`;if(a==="object"){let l=i;if(n.has(l))throw new Error("cannot canonicalize a cyclic structure");n.add(l);let c=Object.keys(l).filter(u=>!t.has(u)).sort().map(u=>{r.push(u);try{return `${JSON.stringify(u)}:${o(l[u])}`}finally{r.pop();}}).join(",");return n.delete(l),`{${c}}`}let s=r.length>0?` at ${r.map(String).join(".")}`:"";throw new Error(`unsupported value type in comparator input: ${a}${s}`)};return o(e)}function Ur(e,t){return Sd(Gt(e,t))}function Sd(e){let t=3421674724,n=2216829733;for(let r=0;r<e.length;r++){n=(n^e.charCodeAt(r))>>>0;let o=n*435,i=Math.floor(o/4294967296);t=Math.imul(t,435)+Math.imul(n,256)+i>>>0,n=o>>>0;}return t.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var $e="dev.docx-editor.core.comparator",Br={authoredState:{id:`${$e}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${$e}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${$e}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${$e}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${$e}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${$e}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${$e}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${$e}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${$e}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${$e}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function jr(e,t,n,r={}){let o=Br[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:Ei(t,n,r.epsilon)}}case "exact":case "canonical-exact":{let i=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=Gt(t,i),s=Gt(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function Hr(e,t){let n=Br[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 Ur(t,r)}function Ei(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)=>Ei(r,t[o],n)):false}var Ci=new Set([...c,...d]),Ti=/^[0-9a-f]{16}$/,wd=/^[0-9a-f]*$/;function Vr(e){let t=[],n=o=>t.push(o);e.formatVersion!==1&&n(`unsupported formatVersion ${e.formatVersion}`),e.documentId||n("documentId is required"),e.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(e.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;e.steps.forEach((o,i)=>{let a=`step[${i}]`;Ci.has(o.origin)||n(`${a}: unknown origin ${o.origin}`),(!Number.isInteger(o.baseRevision)||o.baseRevision<0)&&n(`${a}: baseRevision must be a non-negative integer`),o.baseRevision<r&&n(`${a}: baseRevision regressed below ${r}`);let s=o.expect;s.outcome==="applied"?(s.committedRevision===void 0?n(`${a}: applied step needs committedRevision`):s.committedRevision<=o.baseRevision?n(`${a}: committedRevision ${s.committedRevision} must exceed baseRevision ${o.baseRevision}`):r=s.committedRevision,s.modelChange&&Nd(s.modelChange,a,n)):(s.committedRevision!==void 0&&n(`${a}: ${s.outcome} step must not commit a revision`),s.authoredStateHash!==void 0&&n(`${a}: ${s.outcome} step must not change authored state`)),s.authoredStateHash!==void 0&&!Ti.test(s.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!Ti.test(s.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...e.snapshots??[],...e.updates??[]])o.documentId!==e.documentId&&n(`envelope documentId ${o.documentId} != ${e.documentId}`),wd.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 Nd(e,t,n){Ci.has(e.origin)||n(`${t}: modelChange origin ${e.origin} unknown`),e.toRevision<=e.fromRevision&&n(`${t}: modelChange revision must advance`);}function Ed(e,t){let n=Vr(e);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return t.init(e),e.steps.forEach((o,i)=>{let a=`step[${i}]`,s=t.applyStep(o),l=o.expect;if(s.outcome!==l.outcome){r.push(`${a}: outcome ${s.outcome} != expected ${l.outcome}`);return}if(l.outcome==="applied"&&(s.committedRevision!==l.committedRevision&&r.push(`${a}: revision ${s.committedRevision} != expected ${l.committedRevision}`),l.authoredStateHash!==void 0))if(s.authoredState===void 0)r.push(`${a}: store returned no authored state to hash`);else {jr("authoredState",s.authoredState,s.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let c=Mi(s.authoredState);c!==l.authoredStateHash&&r.push(`${a}: authoredStateHash ${c} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function Mi(e){return Hr("authoredState",e)}function Xt(e){let t=[...e];for(;t.length;){let n=t.pop();if(n.kind!=="textValue"){if(n.namespaceUri===fa&&n.localName==="object")return true;for(let r of n.children)t.push(r);}}return false}var lt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Td="http://schemas.openxmlformats.org/package/2006/relationships",Cd="http://schemas.openxmlformats.org/drawingml/2006/main",_i="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",Fi="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",Li="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",$i="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",Ui="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",Wr="application/vnd.openxmlformats-package.relationships+xml",zr=`${lt}/styles`,Kr=`${lt}/numbering`,Bi=`${lt}/footnotes`,ji=`${lt}/endnotes`,Hi=`${lt}/officeDocument`,Md=`${lt}/theme`;function _e(e){return e.kind!=="textValue"}function Di(e,t){return {...e,children:t}}function qe(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)qe(n,t);}var Dd=new Set(["pStyle","rStyle","tblStyle"]);function Gr(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue"&&Dd.has(r.localName)&&r.namespaceUri===fa){let o=Ve(r,"val");o&&t.add(o);}});}function Xr(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===fa){let o=Ve(r,"val");o&&t.add(o);}});}function Yr(e){let t=new Set;return Yt(e,t),t}function Yt(e,t){for(let n of e)qe(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===lt&&o.value.length>0&&t.add(o.value);});}function Ce(e){return /^\d+$/.test(e)?e.replace(/^0+(?=\d)/,""):e}function $n(e,t){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)qe(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",d=Ve(s,"id");if(d===void 0)return;let c=Ce(d);n[l].has(c)||(n[l].add(c),r.push({kind:l,id:c}));});};for(o(e);r.length>0;){let i=r.pop(),a=t(i.kind,i.id);a!==null&&o([a]);}return n}function Jr(e,t,n){if(e.kind==="textValue")return e;let r=[],o=false;for(let i of e.children){if(i.kind!=="textValue"&&i.namespaceUri===fa&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?t:n,d=Ve(i,"id");if(i.kind!=="noteReference"||d===void 0||!l.has(Ce(d))){o=true;continue}}let s=Jr(i,t,n);s!==i&&(o=true),r.push(s);}return o?{...e,children:r}:e}function Ad(e,t){for(let n of Pd$1(e,t)){if(n.type!==zr||n.targetMode==="External")continue;let r=w(n.ownerPart,n.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return e.parts.get("/word/styles.xml")??null}function Vi(e,t,n){for(let r of Pd$1(e,t)){if(r.type!==n||r.targetMode==="External")continue;let o=w(r.ownerPart,r.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return null}function Wi(e,t){let n=Ad(e,t),r=new Map,o=[],i=null;if(n&&_e(n.root))for(let a of n.root.children){if(!_e(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===fa){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==fa)continue;let s=Ve(a,"styleId");s&&r.set(s,a),(Ve(a,"default")==="1"||Ve(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var _d=new Set(["basedOn","link","next"]);function zi(e,t){let n=new Set,r=[...t];for(let a of e.defaults){let s=Ve(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=e.byId.get(a);if(s){o.push(s);for(let l of s.children)if(_e(l)&&_d.has(l.localName)&&l.namespaceUri===fa){let d=Ve(l,"val");d&&r.push(d);}}}if(!e.part||!_e(e.part.root))return o;let i=new Map;return e.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function qr(e,t,n){let r=Vi(e,t,Kr)??e.parts.get("/word/numbering.xml")??null;if(!r||!_e(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!_e(s)||s.localName!=="num"||s.namespaceUri!==fa)continue;let l=Ve(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let d of s.children)if(_e(d)&&d.localName==="abstractNumId"){let c=Ve(d,"val");c&&i.add(c);}}}let a=[];for(let s of r.root.children){if(!_e(s)||s.localName!=="abstractNum"||s.namespaceUri!==fa)continue;let l=Ve(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var Ln={latin:null,eastAsia:null,cs:null};function Ki(e,t){let n=Vi(e,t,Md);if(!n)return {major:Ln,minor:Ln};let r={major:{...Ln},minor:{...Ln}};return qe(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==Cd||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!_e(a))continue;let s=Ve(a,"typeface");s&&(a.localName==="latin"?i.latin=s:a.localName==="ea"?i.eastAsia=s:a.localName==="cs"&&(i.cs=s));}}),{major:r.major,minor:r.minor}}function Fd(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 Ld=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],Ai=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Qe(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===fa){let i=[],a=new Map;for(let s of e.attributes){let l=Ld.find(([d])=>d===s.localName);if(l&&s.namespaceUri===fa){let d=Fd(t,s.value);d&&a.set(l[1],d);continue}i.push(s);}for(let[s,l]of a)i.some(d=>d.localName===s)||i.push({kind:"genericExtension",namespaceUri:fa,localName:s,prefix:"w",value:l});n=i;}else e.attributes.some(i=>Ai.has(i.localName)&&i.namespaceUri===fa&&e.attributes.some(a=>a.localName==="val"))&&(n=e.attributes.filter(i=>!(Ai.has(i.localName)&&i.namespaceUri===fa)));let r=e.children.map(i=>Qe(i,t)),o=r.some((i,a)=>i!==e.children[a]);return n===e.attributes&&!o?e:{...e,attributes:n,children:r}}function Gi(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Xi(e,t){if(e.root.kind==="document"){let r=e.root.children.find(i=>i.kind==="body"),o=r&&_e(r)?Di(r,t):{id:"fragment#body",kind:"body",namespaceUri:fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return Di(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:fa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:fa,localName:"document",prefix:"w",namespaceBindings:_e(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function Jt(e){let t=e.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${N(n.id)}" Type="${N(n.type)}" Target="${N(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${Td}">${t}</Relationships>`}function Yi(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Ji(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Un(e,t){return {...e,children:t}}function Bn(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function qt(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)qt(n,t);return t}function qi(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=qi(n,t);if(r)return r}return null}function $d(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&Bn(n,"vMerge")){if(Ve(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===fa)),{kind:"wmlVal",namespaceUri:fa,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||Bn(n,"tc");return Un(n,n.children.map(i=>t(i,o)))};return Un(e,e.children.map(n=>t(n,false)))}function Qi(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(Bn(e,"tr")){t.push(e);return}for(let n of e.children)Qi(n,t);}}function Zi(e,t,n){if(e.kind==="textValue"||e.kind==="table")return {node:e,hadRows:false,keptRows:false};if(Bn(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let a=n.value?$d(e):e;return n.value=false,{node:a,hadRows:true,keptRows:true}}let r=false,o=false,i=[];for(let a of e.children){let s=Zi(a,t,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&i.push(s.node);}return r?{node:o?Un(e,i):null,hadRows:true,keptRows:o}:{node:e,hadRows:false,keptRows:false}}function es(e,t,n){let r=[];for(let l of e.children)Qi(l,r);let o=new Set(qt(e).filter(l=>t.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let d=qt(l);return d.length>0&&d.every(c=>t.covered.has(c))}),a=new Set(i.flatMap(l=>qt(l)));if(i.length>0&&o.size===a.size&&[...o].every(l=>a.has(l))){let l={value:true},d=new Set(i),c=[];for(let u of e.children){let p=Zi(u,d,l);p.node!==null&&c.push(p.node);}n.push(Un(e,c));return}for(let l of qt(e)){if(!t.inRange.has(l))continue;let d=qi(e,l);d&&n.push(d);}}var Ud="http://schemas.openxmlformats.org/package/2006/content-types",Bd=5e4;function ze(e){return e.kind!=="textValue"}function ts(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)ts(n,t);return t}function Qr(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=Qr(n,t);if(r)return r}return null}function We(e,t){return {...e,children:t}}function jd(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function Hd(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 Vd(e,t){return ts(e).some(n=>t.has(n))}function Zr(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"){es(r,t,n);continue}if(r.kind==="contentControl"){let o=r.children.find(i=>i.kind==="contentControlContent");o&&ze(o)&&Zr(o.children,t,n);continue}Vd(r,t.inRange)&&Zr(r.children,t,n);}}var Wd=new Set(["commentRangeStart","commentRangeEnd"]);function zd(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function eo(e){if(e.kind==="textValue")return e;if(Wd.has(e.localName)&&e.namespaceUri===fa||zd(e)||jd(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=eo(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?We(e,n):e}function Kd(e){let t=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let d of l.children)if(d.kind==="fldChar"){let c=Ve(d,"fldCharType");t.push({nodeId:d.id,type:c==="separate"||c==="end"?c:"begin"});}else d.kind==="instrText"&&t.push({nodeId:d.id,type:"instr"});return}for(let d of l.children)n(d);}};for(let l of e)n(l);if(t.length===0)return e;let r=new Set,o=[],i=null,a=[];for(let l of t){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let c=o[o.length-1];c?c.separateId=l.nodeId:i=l.nodeId;continue}if(l.type==="instr"){let c=o[o.length-1];c?c.instrIds.push(l.nodeId):i===null&&a.push(l.nodeId);continue}if(!o.pop()){r.add(l.nodeId),i!==null&&r.add(i);for(let c of a)r.add(c);i=null,a=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let d of l.instrIds)r.add(d);}i!==null&&r.add(i);for(let l of a)r.add(l);if(r.size===0)return e;let s=l=>{if(l.kind==="textValue")return l;if(r.has(l.id))return null;let d=[],c=false;for(let u of l.children){let p=s(u);if(p===null){c=true;continue}p!==u&&(c=true),d.push(p);}return c?We(l,d):l};return e.map(l=>s(l)).filter(l=>l!==null)}function to(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=to(n);return t}function Gd(e,t){let n=[];for(let r of e.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=t.get(r.id),i=to(r);if(o===void 0||i>=o){n.push(r);continue}if(i===0)continue;let a=r.children.find(s=>s.kind==="contentControlContent");a&&ze(a)?n.push(...a.children):n.push(r);}return We(e,n)}function Xd(e){let t=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=Ve(a,"id");s!==void 0&&t.add(s);}if(a.kind==="bookmarkEnd"){let s=Ve(a,"id");s!==void 0&&n.add(s);}for(let s of a.children)r(s);}};for(let a of e)r(a);let o=new Set([...t].filter(a=>n.has(a)));if(o.size===t.size&&o.size===n.size)return e;let i=a=>{if(a.kind==="textValue")return a;if(a.kind==="bookmarkStart"||a.kind==="bookmarkEnd"){let d=Ve(a,"id");return d!==void 0&&o.has(d)?a:null}let s=[],l=false;for(let d of a.children){let c=i(d);if(c===null){l=true;continue}c!==d&&(l=true),s.push(c);}return l?We(a,s):a};return e.map(a=>i(a)??a)}function Yd(e,t,n){let r=e.parts.get(t.partName);if(!r)return {ok:false,reason:"unknown-part"};if(t.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o=t.paragraphIds[0],i=t.paragraphIds[t.paragraphIds.length-1],a=new Map;for(let S of [o,i]){let L=Qr(r.root,S);if(!L)return {ok:false,reason:"empty-range"};for(let H of L.children)H.kind==="contentControl"&&a.set(H.id,to(H));}let s=r,l=Qr(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let d=_if(l);if(t.endOffset<d){let S=uj(s,{op:"deleteText",paragraphId:i,start:t.endOffset,end:d},{deferValidation:true});if(!S.ok)return {ok:false,reason:"trim-refused"};s=S.part;}if(t.startOffset>0){let S=uj(s,{op:"deleteText",paragraphId:o,start:0,end:t.startOffset},{deferValidation:true});if(!S.ok)return {ok:false,reason:"trim-refused"};s=S.part;}let c=Hd(s);if(!c)return {ok:false,reason:"unknown-part"};let u={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},p=[];if(Zr(c.children,u,p),p.length===0)return {ok:false,reason:"empty-range"};if(p.length>Bd)return {ok:false,reason:"resource-limit"};let R=p.map(S=>eo(S)).filter(S=>S!==null).map(S=>S.kind!=="paragraph"||S.id!==o&&S.id!==i?S:Gd(S,a));R=[...Kd(R)],R=[...Xd(R)];let m=eg(e,"footnote"),g=eg(e,"endnote"),h=(S,L)=>ze(S)&&S.namespaceUri===fa&&S.localName===L,k=$n(R,(S,L)=>{let H=S==="footnote"?m:g;if(!H||!ze(H.root))return null;for(let Q of H.root.children){if(!h(Q,S))continue;let ae=Ve(Q,"id");if(ae!==void 0&&Ce(ae)===L)return Q}return null}),f=k.footnote,v=k.endnote;f.size===0&&(m=null),v.size===0&&(g=null);let O=(S,L,H)=>{if(!S||!ze(S.root))return [];let Q=[];for(let ae of S.root.children){if(!h(ae,L))continue;let q=Ve(ae,"id"),et=Ve(ae,"type");if(et==="separator"||et==="continuationSeparator"){Q.push(ae);continue}if(q!==void 0&&H.has(Ce(q))){let ht=eo(ae);ht&&ze(ht)&&Q.push(ht);}}return Q},P=O(m,"footnote",f),y=O(g,"endnote",v),T=[...P,...y];if(Xt(R)||Xt(T))return {ok:false,reason:"unsupported-content"};let N$1=[...R,...T],j=new Set;Gr(N$1,j);let z=Wi(e,e.mainDocumentPart),ee=new Set;Xr(N$1,ee);let X=[],_=qr(e,e.mainDocumentPart,ee);for(;;){let S=j.size,L=ee.size;X=zi(z,j),Xr(X,ee),_=qr(e,e.mainDocumentPart,ee);let H=[..._.nums,..._.abstracts];Gr(H,j);for(let Q of H)qe(Q,ae=>{if(ae.kind!=="textValue"&&(ae.localName==="styleLink"||ae.localName==="numStyleLink")&&ae.namespaceUri===fa){let q=Ve(ae,"val");q&&j.add(q);}});if(j.size===S&&ee.size===L)break}let B=Ki(e,e.mainDocumentPart),ie=X.map(S=>Qe(S,B)),be=z.docDefaults?Qe(z.docDefaults,B):null;R=R.map(S=>Qe(S,B));let $=P.map(S=>Qe(S,B)),U=y.map(S=>Qe(S,B)),Y=new Set;Yt(R,Y);let w$1=Pd$1(e,r.name).filter(S=>Y.has(S.id)),I=new Map,D=0,K=S=>{let L=new Set;for(let H of S){if(H.targetMode==="External")continue;let Q=w(H.ownerPart,H.rawTarget);if(!Q.ok){L.add(H.id);continue}if((Qd$1(e,Q.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let q=e.partBytes.get(Q.partName)??e.partBytes.get(Q.partName.replace(/^\//,""));q?(I.set(Q.partName,q),D+=q.byteLength):L.add(H.id);continue}L.add(H.id);}return L},te=K(w$1),se=(S,L)=>{if(S.kind==="textValue")return S;if(S.kind==="drawing"||S.namespaceUri===fa&&(S.localName==="pict"||S.localName==="object")){let ae=new Set;Yt([S],ae);for(let q of ae)if(L.has(q))return null;return S}let H=[],Q=false;for(let ae of S.children){let q=se(ae,L);if(q===null){Q=true;continue}q!==ae&&(Q=true),H.push(q);}return Q?We(S,H):S};te.size>0&&(R=R.map(S=>se(S,te)).filter(S=>S!==null));let G=w$1.filter(S=>!te.has(S.id)),Ue=(S,L)=>{if(!S)return [];let H=new Set;Yt(L,H);let Q=Pd$1(e,S.name).filter(q=>H.has(q.id)),ae=K(Q);if(ae.size>0)for(let q=0;q<L.length;q+=1){let et=se(L[q],ae);et!==null&&(L[q]=et);}return Q.filter(q=>!ae.has(q.id))},ge=Ue(m,$),ln=Ue(g,U),Ne=new Map,ft=[],Ft=new Map,gt=(S,L,H)=>{let Q=Gi(S,L,H);Ne.set(S.slice(1),Ua(sa(Q))),ft.push([S,L]),Ft.set(S,Q);},Lt=(S,L)=>S.map(H=>{if(H.targetMode==="External")return {...H,ownerPart:L};let Q=w(H.ownerPart,H.rawTarget);return {...H,ownerPart:L,rawTarget:Q.ok?Q.partName:H.rawTarget}}),b=Lt(G,"/word/document.xml"),M=Lt(ge,"/word/footnotes.xml"),C=Lt(ln,"/word/endnotes.xml"),F=new Set(b.map(S=>S.id)),W=9001,J=(S,L)=>{let H=Yi(F,W);W+=1,F.add(H),b.push({ownerPart:"/word/document.xml",id:H,type:S,rawTarget:L,targetMode:"Internal",order:b.length});},ce=Xi(s,R);if(gt("/word/document.xml",_i,ce),z.part&&(ie.length>0||be)){let S=We(z.part.root,[...be?[be]:[],...ie]);gt("/word/styles.xml",Fi,S),J(zr,"styles.xml");}if(_.part&&(_.nums.length>0||_.abstracts.length>0)){let S=We(_.part.root,[..._.abstracts.map(L=>Qe(L,B)),..._.nums]);gt("/word/numbering.xml",Li,S),J(Kr,"numbering.xml");}m&&$.length>0&&(gt("/word/footnotes.xml",$i,We(m.root,$)),J(Bi,"footnotes.xml"),M.length>0&&Ne.set("word/_rels/footnotes.xml.rels",Ua(Jt(M)))),g&&U.length>0&&(gt("/word/endnotes.xml",Ui,We(g.root,U)),J(ji,"endnotes.xml"),C.length>0&&Ne.set("word/_rels/endnotes.xml.rels",Ua(Jt(C))));let pe=new Map;for(let[S,L]of I){Ne.set(S.slice(1),L);let H=Ji(S);H&&!pe.has(H)&&pe.set(H,Qd$1(e,S)??"application/octet-stream");}let V={ownerPart:"/",id:"rId1",type:Hi,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Ne.set("word/_rels/document.xml.rels",Ua(Jt(b))),Ne.set("_rels/.rels",Ua(Jt([V])));let de=[`<Default Extension="rels" ContentType="${Wr}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...pe].map(([S,L])=>`<Default Extension="${N(S)}" ContentType="${N(L)}"/>`)].join(""),Se=ft.map(([S,L])=>`<Override PartName="${N(S)}" ContentType="${N(L)}"/>`).join("");Ne.set("[Content_Types].xml",Ua(`<Types xmlns="${Ud}">${de}${Se}</Types>`));let le=new Map;le.set("/",[V]),le.set("/word/document.xml",b),M.length>0&&le.set("/word/footnotes.xml",M),C.length>0&&le.set("/word/endnotes.xml",C);let Ee=[];for(let S of le.values())for(let L of S)L.targetMode==="External"&&Ee.push({ownerPart:L.ownerPart,id:L.id,type:L.type,rawTarget:L.rawTarget,sinkSafe:x(L.rawTarget).ok});let ne=new Map;ne.set("rels",Wr),ne.set("xml","application/xml");for(let[S,L]of pe)ne.set(S,L);let me={defaults:ne,overrides:new Map(ft)},he=new Map;for(let[S,L]of Ne)he.set(S.startsWith("/")?S:`/${S}`,L);return {ok:true,bytes:Ta(Ne),package:Object.freeze({parts:Ft,partBytes:he,relationships:le,externalTargets:Ee,contentTypes:me,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t.lastMarkCovered,blockCount:R.length,mediaBytes:D}}function xe(e){return e.kind!=="textValue"}function re(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===fa}function Fe(e,t){for(let n of e)t(n),n.kind!=="textValue"&&Fe(n.children,t);}function Ke(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===fa&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===ia&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(Ke).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function Qt(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(Ke).join("")}`}function Vn(e){let t=[],n=new Map,r=new Set,o=null;if(e&&xe(e.root))for(let i of e.root.children){if(!xe(i))continue;if(re(i,"docDefaults")){o=i;continue}if(!re(i,"style"))continue;t.push(i);let a=Ve(i,"styleId");a&&n.set(a,i);let s=i.children.find(d=>re(d,"name")),l=s?Ve(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function jn(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(a=>re(a,t));if(!o||!xe(o))return r;let i=o.children.find(a=>re(a,n));if(!i||!xe(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function no(e,t,n,r){let o=t;for(let i=0;i<16&&o;i+=1){let a=e.byId.get(o);if(!a)return false;let s=a.children.find(d=>re(d,n));if(s&&xe(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=a.children.find(d=>re(d,"basedOn"));o=l?Ve(l,"val"):void 0;}return false}function Jd(e,t){for(let n of e.styles){if(Ve(n,"type")!==t)continue;let r=Ve(n,"default");if(r==="1"||r==="true")return Ve(n,"styleId")}}function Hn(e,t){let n=e.children.find(r=>re(r,t));return n&&xe(n)?n:null}var qd=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])),Qd=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 ro(e,t,n){let r=jn(t.docDefaults,"rPrDefault","rPr"),o=jn(n.docDefaults,"rPrDefault","rPr"),i=jn(t.docDefaults,"pPrDefault","pPr"),a=jn(n.docDefaults,"pPrDefault","pPr"),s=(h,x,k)=>{let f=Jd(h,"paragraph"),v=f?h.byId.get(f):void 0;if(!v)return f;for(let[O,P]of [["rPr",x],["pPr",k]]){let y=Hn(v,O);if(y)for(let T of y.children)T.kind!=="textValue"&&P.set(T.localName,T);}return f};s(t,r,i),s(n,o,a);let l=new Map;for(let[h,x]of r){let k=o.get(h);(!k||Ke(k)!==Ke(x))&&l.set(h,x);}let d=new Map;for(let[h,x]of i){if(h==="sectPr")continue;let k=a.get(h);(!k||Ke(k)!==Ke(x))&&d.set(h,x);}if(l.size===0&&d.size===0)return e;let c=0,u=()=>`fragment#materialized-${c++}`,p=h=>{let x=k=>k.kind==="textValue"?{id:u(),kind:"textValue",value:k.value}:{...k,id:u(),children:k.children.map(x)};return x(h)},R=(h,x,k)=>{if(k.length===0)return h;let f=Hn(h,x);if(f){let O=x==="rPr"?Qd:qd,P=[...f.children];for(let T of k){let N=T.kind==="textValue"?Number.MAX_SAFE_INTEGER:O.get(T.localName)??Number.MAX_SAFE_INTEGER,j=P.length;for(let z=0;z<P.length;z+=1){let ee=P[z];if(ee.kind==="textValue")continue;let X=O.get(ee.localName);if(X!==void 0&&X>N){j=z;break}}P.splice(j,0,T);}let y={...f,children:P};return {...h,children:h.children.map(T=>T===f?y:T)}}let v={id:u(),kind:x==="rPr"?"runProperties":"paragraphProperties",namespaceUri:fa,localName:x,prefix:"w",namespaceBindings:[],attributes:[],children:k};return {...h,children:[v,...h.children]}},m=h=>{let x=Hn(h,"pPr"),k=x?.children.find(y=>re(y,"pStyle")),f=k?Ve(k,"val"):void 0,v=[];for(let[y,T]of d)x?.children.some(j=>j.kind!=="textValue"&&j.localName===y)||f&&no(t,f,"pPr",y)||v.push(p(T));let O=y=>{if(y.kind==="textValue")return y;if(y.kind==="run"){let N=Hn(y,"rPr"),j=N?.children.find(X=>re(X,"rStyle")),z=j?Ve(j,"val"):void 0,ee=[];for(let[X,_]of l)N?.children.some(ie=>ie.kind!=="textValue"&&ie.localName===X)||z&&no(t,z,"rPr",X)||f&&no(t,f,"rPr",X)||ee.push(p(_));return R(y,"rPr",ee)}if(y.kind==="paragraphProperties"||y.kind==="runProperties")return y;let T=y.children.map(O);return T.some((N,j)=>N!==y.children[j])?{...y,children:T}:y};return O(R(h,"pPr",v))},g=h=>{if(h.kind==="textValue")return h;if(h.kind==="paragraph")return m(h);let x=h.children.map(g);return x.some((k,f)=>k!==h.children[f])?{...h,children:x}:h};return e.map(g)}var ns="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function Re(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var Zd=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),oo=ng,Ge=new Map;function wt(e,t){let n=t.styleIds??Ge,r=t.numIds??Ge,o=t.relIds??Ge,i=t.footnoteIds??Ge,a=t.endnoteIds??Ge,s=t.bookmarkIds??Ge,l=t.sdtIds??Ge,d=t.revisionIds??Ge,c=t.docPrIds??Ge,u=(p,R)=>{if(p.kind==="textValue")return p;let m=p;if(p.namespaceUri===fa&&Zd.has(p.localName)){let k=Ve(p,"val"),f=k!==void 0?n.get(k):void 0;f!==void 0&&(m=Re(m,fa,"val",f));}if(re(p,"numId")){let k=Ve(p,"val"),f=k!==void 0?r.get(k):void 0;f!==void 0&&(m=Re(m,fa,"val",f));}if(p.kind==="noteReference"){let k=p.localName==="footnoteReference"?i:a,f=Ve(p,"id"),v=f!==void 0?k.get(Ce(f)):void 0;v!==void 0&&(m=Re(m,fa,"id",v));}if(p.kind==="bookmarkStart"||p.kind==="bookmarkEnd"){let k=Ve(p,"id"),f=k!==void 0?s.get(k):void 0;f!==void 0&&(m=Re(m,fa,"id",f));}if(re(p,"id")&&R==="sdtPr"){let k=Ve(p,"val"),f=k!==void 0?l.get(k):void 0;f!==void 0&&(m=Re(m,fa,"val",f));}if(oo(p)){let k=Ve(p,"id"),f=k!==void 0?d.get(k):void 0;f!==void 0&&(m=Re(m,fa,"id",f));}if(p.kind==="drawingDocPr"){let k=p.attributes.find(v=>v.localName==="id"&&v.namespaceUri==="")?.value,f=k!==void 0?c.get(k):void 0;f!==void 0&&(m=Re(m,"","id",f));}for(let k of m.attributes){if(k.namespaceUri!==ns)continue;let f=o.get(k.value);f!==void 0&&f!==k.value&&(m=Re(m,ns,k.localName,f));}let g=p.localName,h=m.children.map(k=>u(k,g));return m!==p||h.some((k,f)=>k!==m.children[f])?{...m,children:h}:p};return u(e,"")}function rs(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 os(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 ec=1e5;function as(e){let t=jb(),n=tc(e,t),r=nc(e,t),o=rc(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function ao(e,t,n,r){if(e)return lb(t,e,r);let o=n;return ()=>String(o++)}function is(e,t){if(e.add(t),!/^\d{1,10}$/.test(t))return;let n=Number(t);n<=hb&&e.add(String(n));}function ss(e,t){if(t===void 0)return e;let n=Number(t);return Number.isInteger(n)&&n>e?n:e}function tc(e,t){let n=new Map;if(e.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [e.ownerPart,...e.notesParts])Fe([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=Ve(s,"id");l!==void 0&&(is(o,l),s.kind==="bookmarkStart"&&(r=ss(r,l)));});let i=ao(t,o,r+1,hb);for(let a of e.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function nc(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;Fe([s.root],d=>{if(!ng(d))return;let c=Ve(d,"id");c!==void 0&&is(o,c),l&&(r=ss(r,c));});}let i=ao(t,o,r+1,hb),a=false;return Fe(e.travelling,s=>{if(a||!ng(s))return;let l=Ve(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function rc(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=xd$1(e.pkg),o=ec;if(!t){let s=yd$1(e.pkg);s.ok&&(o=s.id);}let i=ao(t,r,o,wd$1),a=false;return Fe(e.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}var Nt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",oc=`${Nt}/hyperlink`,ls=`${Nt}/image`,Wn=`${Nt}/numbering`,io=`${Nt}/styles`,ds="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",cs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Zt(e,t,n,r){for(let o of Pd$1(e,t)){if(o.type!==n||o.targetMode==="External")continue;let i=w(o.ownerPart,o.rawTarget);if(i.ok){let a=e.parts.get(i.partName);if(a)return a}}return e.parts.get(r)??null}function so(e,t){let n=0;return Fe([e],r=>{let o=t(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function zn(e,t,n,r){if(n.length===0)return e;let o=Ha(t,"paste"),i=n.map(d=>_e$1(d,o)),a=sj(t,i),s=r??a.root.children.length,l=Na(a,a.root.id,s,i,{deferValidation:true});return l.ok?Nd$1(e,l.part):null}function ms(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||re(o,"pict")||re(o,"object")){let a=false;return Fe([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===Nt&&t.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===Nt)?.value;if(a!==void 0&&t.has(a))return r(o.children)}let i=r(o.children);return i.length===o.children.length&&i.every((a,s)=>a===o.children[s])?o:{...o,children:i}};function r(o){let i=[];for(let a of o){let s=n(a);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(e)}var ac=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),us={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function ic(e,t){let n=md$1(e);return n==="unknown"||(Object.hasOwn(us,t)?us[t]:t)!==n||ac.has(n)&&!zd$1(e,n)?null:n}function lo(e,t,n){for(let b of t.parts.values())if(Xt([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||!xe(o))return {ok:false,reason:"no-fragment-document"};let i=tj(o.children.filter(b=>b.kind==="paragraph"||b.kind==="table"||b.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a$1=e,s=Zt(t,t.mainDocumentPart,Wn,"/word/numbering.xml"),l=new Map,d=[],c=[];if(s&&xe(s.root)){let b=new Map,M=[];for(let V of s.root.children)if(xe(V))if(re(V,"abstractNum")){let de=Ve(V,"abstractNumId");de&&b.set(de,V);}else re(V,"num")&&M.push(V);let C=Zt(a$1,a$1.mainDocumentPart,Wn,"/word/numbering.xml"),F=new Map,W=new Map;if(C&&xe(C.root)){for(let V of C.root.children)if(xe(V)&&re(V,"abstractNum")){let de=Ve(V,"abstractNumId");de&&W.set(de,V);}for(let V of C.root.children){if(!xe(V)||!re(V,"num"))continue;let de=Ve(V,"numId");if(!de)continue;let Se=V.children.find(ne=>re(ne,"abstractNumId")),le=Se?Ve(Se,"val"):void 0,Ee=le?W.get(le):void 0;F.set(`${Ee?Qt(Ee):"none"}::${V.children.filter(ne=>re(ne,"lvlOverride")).map(Ke).join("")}`,de);}}let J=(C?so(C.root,V=>V.kind!=="textValue"&&re(V,"abstractNum")?Ve(V,"abstractNumId"):void 0):0)+1,ce=(C?so(C.root,V=>V.kind!=="textValue"&&re(V,"num")?Ve(V,"numId"):void 0):0)+1,pe=new Map;for(let V of M){let de=Ve(V,"numId");if(!de)continue;let Se=V.children.find(H=>re(H,"abstractNumId")),le=Se?Ve(Se,"val"):void 0,Ee=le?b.get(le):void 0,ne=`${Ee?Qt(Ee):"none"}::${V.children.filter(H=>re(H,"lvlOverride")).map(Ke).join("")}`,me=F.get(ne);if(me!==void 0){l.set(de,me);continue}let he=le?pe.get(le):void 0;he===void 0&&Ee&&le&&(he=String(J++),pe.set(le,he),c.push(Re(Ee,fa,"abstractNumId",he)));let S=String(ce++);l.set(de,S);let L=Re(V,fa,"numId",S);if(he!==void 0){let H=L.children.map(Q=>re(Q,"abstractNumId")?Re(Q,fa,"val",he):Q);L={...L,children:H};}d.push(L),F.set(ne,S);}}let u=Vn(Zt(t,t.mainDocumentPart,io,"/word/styles.xml")),p=Zt(a$1,a$1.mainDocumentPart,io,"/word/styles.xml"),R=Vn(p),m=new Map,g=[],h=new Set(R.byId.keys()),x=new Set(R.names),k=new Map,f=new Map,v=new Map,O=(b,M)=>{let C=v.get(b);return C===void 0&&(C=Qt(M),v.set(b,C)),C},P=b=>({...b,attributes:b.attributes.filter(M=>!(M.localName==="default"&&M.namespaceUri===fa))});for(let b of u.styles){let M=Ve(b,"styleId");if(!M)continue;let C=R.byId.get(M),F=Qt(wt(b,{styleIds:m,numIds:l}));if(C&&O(M,C)===F){m.set(M,M);continue}if(!C){m.set(M,M),h.add(M),g.push(P(b));continue}let W=rs(`${M}Pasted`,h,k);h.add(W),m.set(M,W),g.push(P(Re(b,fa,"styleId",W)));}let y=g.map(b=>{let M=b.children.find(J=>re(J,"name")),C=M?Ve(M,"val"):void 0;if(!C||!x.has(C))return C&&x.add(C),b;let F=os(C,x,f);x.add(F);let W=b.children.map(J=>re(J,"name")?Re(J,fa,"val",F):J);return {...b,children:W}}),T=null,N=1,j=()=>{if(T)return T;let b=new Map;for(let[M,C]of a$1.partBytes){let F=M.startsWith("/")?M:`/${M}`;if(!F.startsWith("/word/media/"))continue;b.set(a(C),F);let W=/\/image(\d+)\./.exec(F);W&&(N=Math.max(N,Number(W[1])+1));}return T=b,b},z=new Map,ee=b=>{let M=z.get(b);if(!M){M=new Map;for(let C of Pd$1(a$1,b)){if(C.targetMode==="External"||C.type!==ls)continue;let F=w(C.ownerPart,C.rawTarget);F.ok&&M.set(F.partName,C.id);}z.set(b,M);}return M},X=(b,M)=>{let C=b.lastIndexOf("."),F=C===-1?"":b.slice(C+1);return /^[A-Za-z0-9]{1,8}$/.test(F)?F.toLowerCase():M==="image/jpeg"?"jpeg":M==="image/gif"?"gif":"png"},_=(b,M,C)=>{let F=new Map,W=new Set,J=ee(M),ce=[],pe=new Set,V=[],de=[],Se=new Map,le=[],Ee=t.relationships.get(b)??[];for(let ne of Ee){if(!C.has(ne.id))continue;if(ne.targetMode==="External"){if(ne.type===oc){let yt=Jf(a$1,ne.rawTarget,M);yt?(a$1=yt.pkg,F.set(ne.id,yt.relationshipId)):W.add(ne.id);}else W.add(ne.id);continue}let me=w(ne.ownerPart,ne.rawTarget);if(!me.ok){W.add(ne.id);continue}let he=t.partBytes.get(me.partName)??t.partBytes.get(me.partName.replace(/^\//,"")),S=(Qd$1(t,me.partName)??"").toLowerCase();if(!he||!S.startsWith("image/")){W.add(ne.id);continue}let L=ic(he,S);if(L===null){W.add(ne.id);continue}let H=L,Q=j(),ae=a(he),q=Q.get(ae);if(!q){let yt=X(me.partName,H),pd=cn=>a$1.partBytes.has(cn)||a$1.partBytes.has(cn.slice(1))||a$1.parts.has(cn)||pe.has(cn),or=`/word/media/image${N}.${yt}`;for(;pd(or);)N+=1,or=`/word/media/image${N}.${yt}`;N+=1,q=or,ce.push({partName:q,bytes:he,contentType:H}),pe.add(q),Q.set(ae,q);}let et=q.startsWith("/word/")?q.slice(6):q,ht=J.get(q);if(ht!==void 0){F.set(ne.id,ht);continue}let dn=Se.get(q);dn===void 0&&(dn=V.length,Se.set(q,dn),V.push(et),de.push(q)),le.push({recordId:ne.id,index:dn});}if(ce.length>0&&(a$1=Dd$1(a$1,ce)),V.length>0){let ne=Td$1(Ud$1(a$1,M),M,V.map(me=>[ls,me]));if(ne.ok){a$1=ne.pkg,ne.ids.forEach((me,he)=>{J.set(de[he],me);});for(let me of le)F.set(me.recordId,ne.ids[me.index]);}else for(let me of le)W.add(me.recordId);}return {relIdMap:F,dropRelIds:W}},B=_(t.mainDocumentPart,n,Yr(i));i=ms(i,B.dropRelIds);let ie=new Map,be=new Map,$=[],U=(b,M)=>xe(b)&&b.namespaceUri===fa&&b.localName===M,Y={},w$1=$n(i,(b,M)=>{let C=Y[b];if(C===void 0){C=new Map,Y[b]=C;let F=eg(t,b);if(F&&xe(F.root))for(let W of F.root.children){if(!U(W,b))continue;let J=Ve(W,"id");if(J===void 0)continue;let ce=Ce(J);C.has(ce)||C.set(ce,W);}}return C.get(M)??null});for(let b of ["footnote","endnote"]){let M=b==="footnote"?ie:be,C=w$1[b];if(C.size===0)continue;let F=eg(t,b);if(!F||!xe(F.root))continue;let W=Vg(a$1,b);if(!W.ok||!W.package)return {ok:false,reason:"merge-refused"};a$1=W.package;let J=eg(a$1,b);if(!J)return {ok:false,reason:"merge-refused"};let ce=so(J.root,V=>U(V,b)?Ve(V,"id"):void 0)+1,pe=[];for(let V of F.root.children){if(!U(V,b))continue;let de=Ve(V,"id"),Se=Ve(V,"type");if(Se==="separator"||Se==="continuationSeparator"||de===void 0||!C.has(Ce(de))||M.has(Ce(de)))continue;let le=String(ce++);M.set(Ce(de),le),pe.push(Re(V,fa,"id",le));}pe.length>0&&$.push({kind:b,fragmentPartName:F.name,bodies:tj(pe)});}let I=a$1.parts.get(n),D=[...i,...$.flatMap(b=>b.bodies)],K=[],te=new Set,se=false,G=false,Ue=new Map;Fe(D,b=>{if(b.kind!=="textValue"){if(b.kind==="bookmarkStart"||b.kind==="bookmarkEnd"){let M=Ve(b,"id");if(M!==void 0&&K.push(M),b.kind==="bookmarkStart"){let C=Ve(b,"name");C&&te.add(C);}return}if(oo(b)){se=true;return}if(b.kind==="drawingDocPr"){G=true;return}if(b.kind==="contentControlProperties")for(let M of b.children){if(!re(M,"id"))continue;let C=Ve(M,"val");if(C!==void 0&&!Ue.has(C)){let F=0,W=`${C}:${Ue.size}`;for(let J=0;J<W.length;J+=1)F=F*31+W.charCodeAt(J)>>>0;Ue.set(C,String(F%2147483647||1));}}}});let ge=as({pkg:a$1,ownerPart:I,notesParts:$.map(b=>eg(a$1,b.kind)).filter(b=>b!==null),travelling:D,fragmentBookmarkIds:K,hasRevision:se,hasDocPr:G});if(!ge)return {ok:false,reason:"merge-refused"};let ln=ge.bookmarkIds,Ne=ge.revisionIds,ft=ge.docPrIds;if(te.size>0){let b=new Set;if(Fe([I.root],M=>{if(M.kind!=="textValue"&&M.kind==="bookmarkStart"){let C=Ve(M,"name"),F=Ve(M,"id");C&&F!==void 0&&te.has(C)&&b.add(F);}}),b.size>0){let M=F=>{if(F.kind==="textValue")return F;let W=[],J=false;for(let ce of F.children){if((ce.kind==="bookmarkStart"||ce.kind==="bookmarkEnd")&&b.has(Ve(ce,"id")??"")){J=true;continue}let pe=M(ce);pe!==ce&&(J=true),W.push(pe);}return J?{...F,children:W}:F},C=M(I.root);C!==I.root&&(La(I.root,C),a$1=Nd$1(a$1,{...I,root:C}));}}let Ft=b=>Jr(b,ie,be);for(let b of $){b.bodies=b.bodies.map(Ft);let M=eg(a$1,b.kind);if(!M)return {ok:false,reason:"merge-refused"};let C=_(b.fragmentPartName,M.name,Yr(b.bodies)),F=ms(b.bodies,C.dropRelIds);F=[...ro(F,u,R)],F=F.map(J=>wt(J,{styleIds:m,numIds:l,relIds:C.relIdMap,footnoteIds:ie,endnoteIds:be,bookmarkIds:ln,sdtIds:Ue,revisionIds:Ne,docPrIds:ft}));let W=zn(a$1,a$1.parts.get(M.name),F);if(!W)return {ok:false,reason:"merge-refused"};a$1=W;}if(y.length>0){let b=y.map(C=>wt(C,{styleIds:m,numIds:l}));if(!p){let C=za(`<w:styles xmlns:w="${fa}"></w:styles>`,{name:"/word/styles.xml",contentType:cs});if(!C.ok)return {ok:false,reason:"merge-refused"};a$1=Wd$1(a$1,"/word/styles.xml",C.part.root,cs);let F=Vd$1(Ud$1(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,io,"styles.xml");if(!F.ok)return {ok:false,reason:"merge-refused"};a$1=F.pkg,p=a$1.parts.get("/word/styles.xml")??null;}if(!p)return {ok:false,reason:"merge-refused"};let M=zn(a$1,a$1.parts.get(p.name),b);if(!M)return {ok:false,reason:"merge-refused"};a$1=M,R=Vn(a$1.parts.get(p.name)??null);}if(c.length>0||d.length>0){let b=Zt(a$1,a$1.mainDocumentPart,Wn,"/word/numbering.xml");if(!b){let J=za(`<w:numbering xmlns:w="${fa}"></w:numbering>`,{name:"/word/numbering.xml",contentType:ds});if(!J.ok)return {ok:false,reason:"merge-refused"};a$1=Wd$1(a$1,"/word/numbering.xml",J.part.root,ds);let ce=Vd$1(Ud$1(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,Wn,"numbering.xml");if(!ce.ok)return {ok:false,reason:"merge-refused"};a$1=ce.pkg,b=a$1.parts.get("/word/numbering.xml")??null;}if(!b)return {ok:false,reason:"merge-refused"};let M=a$1.parts.get(b.name),C=M.root.children.findIndex(J=>re(J,"num")),F=c.map(J=>wt(J,{styleIds:m,numIds:l})),W=zn(a$1,M,F,C===-1?void 0:C);if(!W)return {ok:false,reason:"merge-refused"};if(a$1=W,W=zn(a$1,a$1.parts.get(b.name),d),!W)return {ok:false,reason:"merge-refused"};a$1=W;}let Lt=[...ro(i,u,R)].map(Ft).map(b=>wt(b,{styleIds:m,numIds:l,relIds:B.relIdMap,footnoteIds:ie,endnoteIds:be,bookmarkIds:ln,sdtIds:Ue,revisionIds:Ne,docPrIds:ft}));return {ok:true,pkg:a$1,blocks:Lt}}var ps=16*1024*1024;function sc(e){let t=e.parts.get(e.mainDocumentPart);if(!t||t.root.kind!=="document")return false;let n=t.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>oj)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>qj))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!o(l,a+1,s))return false;return true};for(let i of n.children)if(!o(i,1,pj))return false;for(let[i,a]of e.parts)if(i!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,pj*4))return false;return true}function co(e,t,n){if(n.fragmentBytes.byteLength>ps)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=Ld$1(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!sc(o))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:a,story:s}=i;if(a.compositionActive||e.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=e.currentPackage(),d=a.checkpoint(),c=0,u="";return Ea(e,()=>{let p=a.transact(m=>{for(let k of n.priorOps??[])if(!m.apply(k))return;let g=null,h=m.applyPackage(k=>(g=lo(k,o,s.partName),g.ok?g.pkg:k)),x=g;if(!x||!x.ok){u=`fragment-merge:${x?x.reason:"no-merge"}`,m.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}h&&(c=x.blocks.length,m.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:x.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return u.length>0?{ok:false,reason:"invalidArgs",detail:u}:p.ok?p.change?{ok:true,change:e.promoteStoryTransactionToPackageUnit(l,a,d),blockCount:c}:{ok:true,change:null,blockCount:c}:{ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}}},p=>Fa(p))}function fs(){let e=null;return (t,n,r)=>{let o=e;if(e=null,!Pi(n)||!("paragraphId"in r)||!Ri(t,r.paragraphId))return r;if(r.op==="insertText"&&!r.revision&&r.inside===void 0&&o&&o.partName===t.name&&o.paragraphId===r.paragraphId&&o.offset===r.offset)return {...r,inside:o.controlId};if(r.op!=="deleteText"||r.revision||r.start>=r.end)return r;let i=Ja(t,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=Wi$1(t,Vi$1(r));if(a.unprotected.length)return r;let s=ff(i);for(let l of a.touches){let d=s.spanOf(l.control);d&&d.start<=r.start&&d.end>=r.end&&(e={partName:t.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}var gs=new WeakSet;function lc(e){return gs.add(e),e}function hs(e){return gs.has(e)}function en(e){return {...e,applyPackage:t=>e.applyPackage(lc(t))}}var dc=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertDrawing","deleteText"]),ys=new Set(["insertDrawing"]);function cc(e){if(!(e===null||e.start!==e.end))return e}var Et={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function mc(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 dt=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(t,n,r={}){let o="root"in t,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?mc(t):t,this.storyPartName=i??(o?t.name:t.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart;}setStoryRef(t){this.storyRef=t;}get part(){let t=this.current.parts.get(this.storyPartName);if(!t)throw new Error(`story part missing: ${this.storyPartName}`);return t}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(t){this.current=t(this.current);}replacePart(t){let n=this.current.parts.get(t.name);t!==n&&(this.current=Nd$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 ib(n.actorId,()=>this.commitTransaction(t,n))}commitTransaction(t,n){let r=n.origin??b.mutationHuman,o=n.recordsHistory??(r!==b.projection&&r!==b.awareness),i=this.undoStack[this.undoStack.length-1];o&&!this.composition&&i?.group!==n.historyGroup&&this.closeHistoryGroup();let a=this.current,s=this.rev,l=this.current,d=null,c=0,u=new Set,p=new Set,R=new Set,m=new Set,g=new Set,h=[],x=n.minimumImpact??"text-local",k=null,f=false,v=null,O=null,P=new Map,y=new Map,T=$=>{let U=y.get($.name);U||(U={mint:null,written:new Set},y.set($.name,U));let Y=U;return {mint:()=>(Y.mint??=mg($))(),wrote:w=>{Y.written.add(w);},wroteUnder:w=>Y.written.has(w)}},N=()=>{for(let $ of y.values())$.mint=null;},j=($,U)=>{let Y=qi$1.get($.op);if(Y===void 0)return P.clear(),null;let w=`${U.name}\0${Y}`,I=P.get(w);I||(I={id:null},P.set(w,I));let D=I;return ()=>D.id??=T(U).mint()},z=($,U)=>{let Y=dc.has($.op);return !Y&&qi$1.get($.op)!==void 0?null:((!Y||ys.has($.op))&&N(),Y?T(U):null)},ee=fs(),X=null,_=($,U)=>{if(d)return false;let Y=l.parts.get($);if(!Y)return d={reason:"unknown-part",detail:$},false;U=ee(Y,this.settingsPartOverride?.()??Vf(l),U);let w=Oi(this.settingsPartOverride?.()??Vf(l),U)??Xi$1(Y,this.settingsPartOverride?.()??Vf(l),U,X?.partName===$&&"paragraphId"in U&&X.paragraphId===U.paragraphId?X.fieldNodeId:void 0);if(w)return d={reason:w},false;let I=j(U,Y),D=z(U,Y),K=this.settingsPartOverride?.()??Vf(l),te=Pi(K)&&"paragraphId"in U&&Ri(Y,U.paragraphId)?Wh(Y,U,X?.partName===$&&X.paragraphId===U.paragraphId?X.fieldNodeId:void 0):null;X=te&&"paragraphId"in U?{partName:$,paragraphId:U.paragraphId,fieldNodeId:te.fieldNodeId}:null;let se={deferValidation:true,...I?{revisionIds:I}:{},...D?{trackedRevisionIds:D}:{}},G=te?ai(Y,U,te,se):uj(Y,U,se);if(!G.ok)return d={reason:G.reason,...G.detail?{detail:G.detail}:{}},false;if(ys.has(U.op)&&N(),l=Nd$1(l,G.part),G.part===Y&&G.effect.dirty.length===0&&G.effect.created.length===0&&G.effect.deleted.length===0&&G.effect.split===void 0&&(G.effect.splits===void 0||G.effect.splits.length===0)&&G.effect.join===void 0&&G.effect.caret===void 0)return true;u.add($),c+=1;for(let ge of G.effect.dirty)p.add(ge);for(let ge of G.effect.created)R.add(ge);for(let ge of G.effect.deleted)m.add(ge);for(let ge of G.effect.dependencyKeys)g.add(ge);G.effect.split&&h.push({split:G.effect.split});for(let ge of G.effect.splits??[])h.push({split:ge});return G.effect.join&&h.push({join:G.effect.join}),Et[G.effect.impact]>Et[x]&&(x=G.effect.impact),G.effect.caret&&(O={paragraphId:G.effect.caret.paragraphId,start:0,end:0}),true};if(t({apply:$=>_(this.storyPartName,$),applyTo:($,U)=>_($,U),applyPackage:$=>{if(d)return false;let U=this.settingsPartOverride?.()??Vf(l),Y=hs($)?Ni$1(U,{op:"comment"}):Oi(U);if(Y)return d={reason:Y},false;P.clear(),N();let w=$(l);if(w===l)return true;for(let[I,D]of w.parts)l.parts.get(I)!==D&&u.add(I);return l=w,c+=1,Et["flow-structural"]>Et[x]&&(x="flow-structural"),true},selectionBefore:$=>{k=$;},selectionAfter:$=>{f=true,v=$;}}),d){let $=d;return {ok:false,reason:$.reason,...$.detail?{detail:$.detail}:{}}}if(c===0)return {ok:true,change:null};let B=f?v:O,ie=f?cc(v):O??void 0;for(let $ of u){let U=a.parts.get($),Y=l.parts.get($);if(Y===void 0)continue;let w=U?xa(U,Y):xa(Y,Y);if(!w.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(w.issues)}}let be=Xd$1(l);if(!be.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(be.issues)};if(o)if(this.composition)Ej(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:B}};else {let $=n.historyGroup,U=this.undoStack[this.undoStack.length-1];$!==void 0&&U!==void 0&&U.group===$?this.undoStack[this.undoStack.length-1]={...U,selectionAfter:B??U.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:k,selectionAfter:B,group:$}),Ej($,U?.group===$?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&Et[n.minimumImpact]>Et[x]&&(x=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:p,created:R,deleted:m,dependencyKeys:g,splitJoin:h,impact:x,caret:ie},n.story??this.storyRef??void 0,n.actorId,n.operationId)}}beginComposition(t=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:t,selectionAfter:null},committed:false});}endComposition(){let t=this.composition;this.composition=null,!(!t||!t.committed)&&(this.pushUndo(t.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}closeHistoryGroup(){let t=this.undoStack[this.undoStack.length-1];t===void 0||t.group===void 0||(this.undoStack[this.undoStack.length-1]={...t,group:void 0});}undo(){let t=this.undoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let t=this.redoStack.pop();if(!t)return null;this.closeHistoryGroup();let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(t){this.undoStack.push(t),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(t,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:t,...i?{actorId:i}:{},...a?{operationId:a}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:o?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...o?{story:o}:{}};for(let l of this.subscribers)l(s);return s}};function mo(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 xs(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 uo(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function ks(e,t){return uo(e,t).map(n=>n.name).sort().join(",")}function Rs(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 Gn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",uc="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Tt(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===Gn&&n.localName===t)return n;return null}function Kn(e,t){return e.attributes.find(n=>n.namespaceUri===Gn&&n.localName===t)?.value}function pc(e){let t=Kn(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function vs(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>vs(n,t))})}function fc(e){let t=za(`<w:styles xmlns:w="${Gn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:uc});if(!t.ok)return null;let n=Tt(t.part.root,"style"),r=n?Tt(n,"pPr"):null;return r?vs(r,Ha(e)):null}var Ps=["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 gc(e,t){let n=Ps.indexOf(t),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=Ps.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function Os(e,t){let n=Cc$1(e);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Gn&&d.localName==="style"&&Kn(d,"type")==="paragraph"&&Kn(d,"styleId")===t){r=d;break}if(!r)return null;let o=Tt(r,"name");if(o&&Kn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let i=fc(n);if(!i)return null;let a=Tt(i,"contextualSpacing");if(!a)return null;let s=Tt(r,"pPr"),l;if(s){let d=Tt(s,"contextualSpacing");if(d&&pc(d))return e;l=d?Oa(n,d.id,a):Na(n,s.id,gc(s.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=Na(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,l.part]])}):null}var ws="http://schemas.openxmlformats.org/package/2006/relationships",Ns="application/vnd.openxmlformats-package.relationships+xml",xc="http://schemas.openxmlformats.org/package/2006/content-types",Is="/[Content_Types].xml",ct="/word/numbering.xml",bs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",tn="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",kc=`<Override PartName="${ct}" ContentType="${tn}"/>`;function Xn(e){return `${e.ownerPart}\0${e.id}`}function Es(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===Qc$1).map(Xn)),o=n.externalTargets.filter(s=>s.type===Qc$1&&!r.has(Xn(s)));if(o.length===0)return e;let i=new Set(e.map(Xn)),a=o.filter(s=>!i.has(Xn(s)));return a.length===0?e:Object.freeze([...e,...a])}function Ts(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 Cs(e,t,n=[],r=false){if(e===t)return e;let o=Rc(e,t,r);return o=vc(o,t,n),o}function Ms(e,t){let n=new Set;for(let o of e.externalTargets)o.type===Qc$1&&o.ownerPart!==e.mainDocumentPart&&(e.parts.has(o.ownerPart)||t.has(o.ownerPart)||n.add(o.ownerPart));for(let o of e.parts.keys()){let i=Sc(o);!i||i===e.mainDocumentPart||e.parts.has(i)||t.has(i)||e.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return e;let r=e;for(let o of n)r=wc(r,o);return r}function Rc(e,t,n){let r=t.parts.get(ct);if(!r)return e;let o=e.parts.get(ct),i=n&&o?Pc(o,r):r,a=Nd$1(e,i),s=(t.relationships.get(t.mainDocumentPart)??[]).find(d=>d.type===bs),l=a.relationships.get(a.mainDocumentPart)??[];if(s&&!l.some(d=>d.type===bs)&&!l.some(d=>d.id===s.id)){let d=Ic(a,{...s,ownerPart:a.mainDocumentPart});d&&(a=d);}if(a.contentTypes.overrides.get(u(ct))!==tn){let d=Nc(a);d&&(a=d);}return a}function Pc(e,t){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let d=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!d)return null;let c=l.attributes.find(u=>u.namespaceUri===n&&u.localName===d)?.value;return c===void 0?null:`${l.localName}:${c}`},o=new Set(e.root.children.map(r).filter(Boolean)),i=Ha(e),a=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=e;for(let l of t.root.children){let d=r(l);if(!d||o.has(d)||l.kind==="textValue")continue;let c=a.indexOf(l.localName),u=s.root.children.findIndex(R=>R.kind!=="textValue"&&R.namespaceUri===n&&a.indexOf(R.localName)>c),p=Na(s,s.root.id,u<0?s.root.children.length:u,[po(l,i)]);p.ok&&(s=p.part,o.add(d));}return s}function vc(e,t,n){let r=n.filter(i=>i.type===Qc$1);if(r.length===0)return e;let o=e;for(let i of r){let a=Oc(e,t,i.ownerPart);if(!a||o.externalTargets.some(d=>d.ownerPart===a&&d.id===i.id)||new Set((o.relationships.get(a)??[]).map(d=>d.id)).has(i.id))continue;let l=bc(o,{ownerPart:a,id:i.id,type:Qc$1,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function Oc(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Ic(e,t){let n=e.mainDocumentPart,r=fo(n),o=e.parts.get(r),i=za(`<Relationships xmlns="${ws}"><Relationship Id="${P(t.id,"relationship id")}" Type="${P(t.type,"relationship type")}" Target="${P(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:Ns});if(!i.ok)return null;let a=e.relationships.get(n)??[];if(a.some(d=>d.id===t.id))return null;let s={...t,ownerPart:n,order:a.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...e.relationships,[n,[...a,s]]]);return o?Ds(e,o,i.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:l})}function bc(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=fo(r),i=e.parts.get(o),a=za(`<Relationships xmlns="${ws}"><Relationship Id="${P(t.id,"relationship id")}" Type="${Qc$1}" Target="${P(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:Ns});if(!a.ok)return null;let s=[...e.externalTargets,t];if(!i)return Object.freeze({...e,parts:new Map([...e.parts,[o,a.part]]),externalTargets:s});let l=Ds(e,i,a.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Ds(e,t,n,r){if(!n)return null;let o=Ha(t),i=Na(t,t.root.id,t.root.children.length,[po(n,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,i.part]]),relationships:r}):null}function po(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>po(n,t))}}function fo(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Sc(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 wc(e,t){let n=fo(t),r=new Map(e.parts);r.delete(n);let o=new Map(e.partBytes);o.delete(n);let i=new Map(e.relationships);i.delete(t);let a=Object.freeze(e.externalTargets.filter(s=>s.ownerPart!==t));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function Nc(e){let t=e.contentTypes.overrides.get(u(ct));if(t===tn)return e;if(t!==void 0)return null;let n=e.partBytes.get(Is);if(!n)return null;let r=strFromU8(n),o=Ss(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+kc+r.slice(i),s=Ss(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,As("Override",{PartName:ct,ContentType:tn})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[Is,strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[u(ct),tn]])})})}function Ss(e){let t=X(e);if(!t.ok)return null;let n=t.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),i=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==xc)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(As(s.name,s.attributes));return {rootName:r.name,children:a}}function As(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}var _s=4e3,Fs=64;function Ls(e){return eg(e,"footnote")!==null||eg(e,"endnote")!==null}function $s(e,t,n,r){if(!Ls(e))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=Ja(t,n.paragraphId);return !o||o.kind!=="paragraph"?true:df(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function Us(e,t,n,r){if(!Ls(e))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=Ja(t,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=_s||l>Fs)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return df(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(a(d,l+1))return true;return false};return a(o,0)}function Bs(e,t,n){if(n.count>=_s||t>Fs)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(Bs(r,t+1,n))return true;return false}function js(e,t,n,r){if(!fh(e))return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=Ja(t,o);return !i||i.kind==="textValue"?true:Bs(i,0,{count:0})}var go="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",ho="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function Hs(e,t){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===t);return r?r.type!==go&&r.type!==ho?{ok:false,reason:"wrong-relationship-type",detail:r.type}:Ec(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function Ec(e,t){let n=E(t);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:t.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=e.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}function mt(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Vs(e,t){let n=Ja(e,t);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function Ws(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Ja(r,n);return !o||o.kind!=="drawing"?null:ed$1(o,{ownerPartName:t,supportedMcRequires:Zc$1,limits:Yc$1,resolveRelationship:$c$1(e,t)})}function zs(e,t,n){let r=F(e.relationships.get(t)??[],t,n);return r.mode==="internal"?r.partName:null}function Ct(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=mt(e,o.store);if(i)return i;let{store:a,story:s}=o;return Ea(e,()=>Tc(e,a,s,n,r),l=>Fa(l))}function Tc(e,t,n,r,o){let i=n.partName,a=e.currentPackage(),s=t.checkpoint(),l=null,d=false,c=false,u=t.transact(m=>{if(o?.commitGuard?.()===false){c=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){d=true;return}let g=r(m,i);if(g===null){m.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=g;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(c)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(d)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!u.ok)return {ok:false,reason:u.reason,...u.detail?{detail:u.detail}:{}};if(!u.change)return {ok:true,change:null};let p=u.change.created.find(m=>{let g=t.part;return Ja(g,m)?.kind==="drawing"});return p&&(l=p),{ok:true,change:e.promoteStoryTransactionToPackageUnit(a,t,s),...l?{drawingNodeId:l}:{}}}function Ks(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=Vs(r,n);return o?kj(o):null}function yo(e,t,n,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(t);if(!a)return i;let s=Ja(a,n);if(!s||s.kind!=="drawing")return i;let l=Vs(a,n);if(!l)return i;let d=lj(l,r),c=Cc(s,d),u=Oa(a,s.id,c,{deferValidation:true});return u.ok?(o=true,Nd$1(i,u.part)):i}),o}function Cc(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function Gs(e,t,n){let r=Fd$1(n.widthPoints),o=Fd$1(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=mt(e,i.store);if(a)return a;let s=i.story.partName,l=await Ad$1(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=Cd$1(e.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,p=Ct(e,t,(R,m)=>{let g=e.currentPackage(),h=Cd$1(g,m,{bytes:d,mime:n.mime});if(!h.ok)return null;g=h.pkg,u=h.partName;let x;if(n.hyperlink){let f=Jf(g,n.hyperlink,m);if(!f)return null;g=f.pkg,x=f.relationshipId;}if(!R.applyPackage(()=>g))return null;let k=Gd$1({docPrId:h.docPrId,relationshipId:h.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...x?{hyperlinkRelationshipId:x}:{}});return R.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:k,...n.revision?{revision:n.revision}:{}})?k.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return p.ok?p.change?{...p,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:p}async function xo(e,t,n,r,o,i,a){let s=e.resolveStory(t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=mt(e,s.store);if(l)return l;let d=s.story.partName,c=await Ad$1(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,p=Cd$1(e.currentPackage(),d,{bytes:u,mime:o});return p.ok?Ct(e,t,(R,m)=>{let g=e.currentPackage(),h=Ws(g,d,n),x=h?.picture?.embeddedRelationshipId??null,k=h?.picture?.linkedRelationshipId??null,f=x??k;if(!f)return null;let v=x!==null?zs(g,d,x):null,O=g,P=Cd$1(O,m,{bytes:u,mime:o});return !P.ok||(O=P.pkg,!R.applyPackage(()=>O))||!R.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:P.relationshipId})?null:(R.applyPackage(y=>Id$1(y,m,v,f)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:p.reason==="invalid-image"?"invalid-image":p.reason}}function Xs(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 i=r.story.partName,a=e.currentPackage(),s=a.parts.get(i),l=Ws(a,i,n)??(s?bj(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let d=l.picture?.embeddedRelationshipId??null,c=l.picture?.linkedRelationshipId??null,u=d??c,p=d!==null?zs(a,i,d):null;return Ct(e,t,(R,m)=>R.apply({op:"deleteDrawing",drawingNodeId:n})?(R.applyPackage(g=>Id$1(g,m,p,u)),n):null)}function Mc(e,t){let n=null,r=i=>{let a=false,s=false,l=(d,c)=>{if(a||d.kind==="textValue")return;if(d.id===t){a=true,s=c;return}let u=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let p of d.children)l(p,u);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=ff(i).spanOf(t);if(a!==null&&a.end>a.start){let s=Ja(e,t);if(!s||s.kind!=="drawing"&&!ad$1(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(e.root),n}function Ys(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=mt(e,o.store);if(i)return i;let a=e.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=Mc(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:Ct(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 Js(e,t,n,r,o,i,a,s){let l=await Jd$1(o,r,i,void 0,a);return l.ok?xo(e,t,n,l.bytes,l.mime,a,{expectedPackageRevision:e.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function qs(e,t,n,r,o,i){let a=e.resolveStory(t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=mt(e,a.store);return s||Ct(e,t,(l,d)=>{let c=Ks(e.currentPackage(),d,n),u=null;if(i!==null){let R=Jf(e.currentPackage(),i,d);if(!R||!l.applyPackage(()=>R.pkg))return null;u=R.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!yo(l,d,n,u))return null}else if(i===null&&!yo(l,d,n,null))return null;let p=false;return l.applyPackage(R=>{let m=Lf(R,d,c);return m===null?(p=true,R):m}),p?null:n})}function Qs(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||Ct(e,t,(i,a)=>{let s=Ks(e.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=Jf(e.currentPackage(),n.hyperlink,a);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!yo(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let u=Lf(c,a,s);return u===null?(d=true,c):u}),d?null:n.drawingNodeId})}function Dc(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 Zs(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 Ac(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 _c(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!Ac(i,o[a])))return false}return true}function Fc(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 Lc(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||!Dc(r,o))return false}return true}function $c(e,t){return e.contentTypes===t.contentTypes||Zs(e.contentTypes.defaults,t.contentTypes.defaults)&&Zs(e.contentTypes.overrides,t.contentTypes.overrides)}var Yn=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),Jn=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function el(e){for(let[t,n]of e)if(!ua(t,n))return Jn;return Yn}function Uc(e,t){if(e===t)return Yn;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Lc(e.partBytes,t.partBytes)||!_c(e.relationships,t.relationships)||!Fc(e.externalTargets,t.externalTargets)||!$c(e,t))return Jn;let n=[];for(let[a,s]of e.parts){let l=t.parts.get(a);if(!l)return Jn;s!==l&&n.push([s,l]);}if(n.length===0)return Yn;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return el(n);let i=va(o.root,r.root);return i.undecided?el(n):i.equal?Yn:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?Jn:{equal:false,dirty:i.paragraphIds,dependencyKeys:[g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function ko(e){return {ok:false,reason:"package-invariant",detail:e}}function Bc(e,t){if(!e.parts.get(e.mainDocumentPart))return ko("no-main-document");for(let[r,o]of e.parts){let i=t?.parts.get(r);if(i===o)continue;let a=i?xa(i,o):wa(o);if(!a.ok)return ko(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=Xd$1(e);return n.ok?null:ko(n.issues[0]?.code??"package-invariant")}function tl(e,t,n){let r=e.currentPackage(),o=Uc(t,r);if(o.equal)return {ok:true,change:null};let i=Bc(t,r);if(i)return i;let a=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===a;return Ea(e,()=>{let l=e.packageRevision;return e.installAuthoritativePackageSnapshot(t),{ok:true,change:e.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?o.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?o.dependencyKeys:[],impact:s?o.impact:"global",story:{kind:"body",partName:a}})}},()=>false)}function ol(e,t,n,r){let o=[...t],i=new Set;for(let a of o)e.parts.has(a)&&i.add(a);for(let a of n)nl(a,o,i);for(let a of r)nl(a,o,i);return i}function al(e,t,n,r,o){let i=new Set(e);i.add(t),i.add(n);for(let a of r)rl(a,i);for(let a of o)rl(a,i);return i}function nl(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 rl(e,t){if(e.kind==="story"){t.add(e.partName);return}for(let n of e.before.parts.keys())t.add(n);for(let n of e.after.parts.keys())t.add(n);}var il=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),sl=new Set(["authorTable","deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),ll=64,nn=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(t,n,r={}){this.pkg=Nd$1(t,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??ll,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??Ug,this.body=new dt(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>Vf(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let t=this.currentPackageMemo;if(t&&t.pkg===this.pkg&&t.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(t.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===t.storyParts.length)return t.result}let n=Nd$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=Nd$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 Ea(this,()=>this.commitStoryTransaction(t,n,r),Fa,r.historyGroup)}commitStoryTransaction(t,n,r={}){let o=this.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,p=new Set,R=false,m=new Set,g=false,h,x=false,k;i.graftPackage(()=>this.currentPackage());let f=i.transact(P=>{k=xs(P),n({...P,applyTo:(y,T)=>{let N=P.applyTo(y,T);return N&&y!==a.partName&&(x=true),N},applyPackage:y=>P.applyPackage(T=>{let N=y(T);return N!==T&&!x&&(x=Rs(T,N,a.partName)),N}),apply:y=>(y.op==="setListNumbering"&&y.numId!==null&&(g=true),y.op==="setParagraphProperties"&&(h??=y.properties.find(T=>T.localName==="pStyle")?.attributes?.val),u||(y.op==="deleteText"&&$s(this.pkg,i.part,y,p)||y.op==="deleteBlock"&&Us(this.pkg,i.part,y,p)||il.has(y.op)||sl.has(y.op))&&(u=true),R||(y.op==="deleteText"||y.op==="deleteBlock"?R=js(this.pkg,i.part,y,m):(il.has(y.op)||sl.has(y.op))&&(R=true)),P.apply(y)),...k.context});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!f.ok)return {ok:false,reason:f.reason,...f.detail?{detail:f.detail}:{}};this.syncPackageFromStore(i);let v=false;if(f.change&&x&&(this.installPackageSnapshotInternal(i.package,false),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),v=true),g&&h){let P=Os(this.pkg,h);P&&this.replacePackageShell(P);}let O=false;if(f.change&&u){let P=this.currentPackage(),y=this.cascadeNoteReferences(s,P);if(y===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};y!==P&&(this.installPackageSnapshotInternal(y),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),O=true);}if(f.change&&R){let P=this.currentPackage(),y=jh(s,P,{storyPartName:a.partName});if(y===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};y!==P&&(this.installPackageSnapshotInternal(y),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),O=true);}if(f.change){this.packageRev+=1;let P=O||v;P&&Ej(r.historyGroup,"split","package-unit"),!d&&r.recordsHistory!==false&&(i.historyDepth>l||P)&&(P?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...k?.snapshot(f.change.caret)}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let y=P?this.publishSynthetic(f.change.origin,"global",a,f.change.created):f.change;return P||this.publish(y),{ok:true,change:y}}return {ok:true,change:f.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(t,n=null){let r=this.resolveStory(t);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(t),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.endComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),t.packageWideEffects){n.restoreHistoryStacks(t.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:t.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let o=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);o&&this.pushUndoPointer({kind:"story",partName:t.partName,story:o});}this.syncPackageFromStore(n);}cancelComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.cancelComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(t.packageWideEffects){n&&n.restoreCheckpoint(t.storyCheckpoint),this.installPackageSnapshotInternal(t.beforePackage),this.packageRev+=1;let r=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);this.publishSynthetic(b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(t){return Ea(this,()=>this.commitLifecycleOp(t),Fa)}commitLifecycleOp(t){let n=this.currentPackage(),r=Ni$1(Vf(n),t);if(r)return {ok:false,reason:r};if(Sg(t)){let s=Tg(n,t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};if(s.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(s.package),this.pushUndoPointer({kind:"package",before:n,after:s.package}),this.packageRev+=1;let l={kind:"body",partName:this.body.part.name},d=this.publishSynthetic(b.mutationHuman,s.impact,l,s.createdPartName?[s.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:d}}if(!Of(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let o=Pf(n,t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};this.installPackageSnapshotInternal(o.package),this.pushUndoPointer({kind:"package",before:n,after:o.package}),this.packageRev+=1;let i={kind:"body",partName:this.body.part.name},a=this.publishSynthetic(b.mutationHuman,o.impact,i,o.createdPartName?[o.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:a}}undo(){let t=this.undoOrder.pop();if(!t)return null;if(Cj(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.before,true,t.restoreNumbering),this.redoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let t=this.redoOrder.pop();if(!t)return null;if(Cj(this.body,this.stories,null),t.kind==="package"){this.installPackageSnapshotInternal(t.after,true,t.restoreNumbering),this.undoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){return mo(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return mo(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return uo(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return ks(this.stories,this.pkg)}insertImage(t,n){return Gs(this,t,n)}applyFragmentPaste(t,n){return co(this,t,n)}replaceImage(t,n,r,o,i,a){return xo(this,t,n,r,o,i,a)}deleteImage(t,n){return Xs(this,t,n)}deleteImageTracked(t,n,r){return Ys(this,t,n,r)}embedExternalImage(t,n,r,o,i,a,s){return Js(this,t,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(t,n,r,o,i){return qs(this,t,n,r,o,i)}applyImageProperties(t,n){return Qs(this,t,n)}promoteStoryTransactionToPackageUnit(t,n,r,o){this.installPackageSnapshotInternal(n.package),n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:t,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(t){return t?(this.packageRev+=1,this.publish(t),t):null}adoptPackageUnit(t){let n=this.currentPackage();t!==n&&this.pushUndoPointer({kind:"package",before:t,after:n});}installPackageSnapshot(t){this.installPackageSnapshotInternal(t);}installAuthoritativePackageSnapshot(t){this.installPackageSnapshotInternal(t,false);}publishRemotePackage(t,n){return tl(this,t,n)}replacePackageShell(t){this.shellHyperlinks=Es(this.shellHyperlinks,this.pkg,t);let n=t;n=Nd$1(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=Nd$1(n,r.part));this.pkg=n;}installPackageSnapshotInternal(t,n=true,r=false){let o=n?Cs(t,this.pkg,this.shellHyperlinks,r):t,i=o.parts.get(o.mainDocumentPart);if(!i)return;this.body.replacePart(i);for(let[s,l]of this.stories){let d=o.parts.get(s);d&&l.replacePart(d);}this.rIdToPartName.clear();let a=o.relationships.get(o.mainDocumentPart)??[];for(let s of a){if(s.type!==go&&s.type!==ho)continue;let l=E(s);l.mode!=="Internal"||!l.target.ok||this.stories.has(l.target.partName)&&o.parts.has(l.target.partName)&&this.rIdToPartName.set(s.id,l.target.partName);}this.pkg=o,this.pkg=Nd$1(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=Nd$1(this.pkg,s.part));}openNotesPartStore(t){let n=eg(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=gb(n),i=new dt(o,{historyLimit:this.historyLimit,settingsPart:()=>Vf(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:t};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=Nd$1(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(t){let n=this.rIdToPartName.get(t);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:t},store:l}}let r=Hs(this.currentPackage(),t);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(t,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:t},store:o};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let i=gb(r.part),a=new dt(i,{historyLimit:this.historyLimit,settingsPart:()=>Vf(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:t};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(t,i.name),i!==r.part&&(this.pkg=Nd$1(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(t){if(t===this.body.part.name)return {kind:"body",partName:t};for(let[r,o]of this.rIdToPartName)if(o===t)return {kind:"headerFooter",partName:t,rId:r};let n=this.currentPackage().parts.get(t);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:t,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:t,noteKind:"endnote"}:null}syncPackageFromStore(t){this.pkg=Nd$1(this.pkg,t.part);}pushUndoPointer(t){Cj(this.body,this.stories,t),t.kind==="package"&&t.before.parts.get("/word/numbering.xml")!==t.after.parts.get("/word/numbering.xml")&&(t={...t,restoreNumbering:true}),this.undoOrder.push(t),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let t=ol(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[o]of [...this.stories])if(!t.has(o)){this.stories.delete(o);for(let[i,a]of [...this.rIdToPartName])a===o&&this.rIdToPartName.delete(i);}let n=al(t,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=Ms(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=Ts(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(t){this.lastChange=t;for(let n of this.subscribers)n(t);}publishSynthetic(t,n,r,o){this.commitCounter+=1;let i=this.packageRev-1,a={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:t,dirty:[],created:[...o],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(a),a}};var jc=256,Hc=65535,dl=64;function qn(e,t){return e.length>t}function cl(e){return typeof e!="string"||e.trim().length===0?"invalid-author":qn(e,jc)?"resource-limit":O(e)?null:"invalid-author"}function ml(e){return typeof e!="string"||e.length===0?"invalid-text":qn(e,Hc)?"resource-limit":O(e)?null:"invalid-text"}function Ro(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(qn(t,dl))return {ok:false,rejection:"resource-limit"};if(!O(t))return {ok:false,rejection:"invalid-date"};let n=Ye(t);return n===null?{ok:false,rejection:"invalid-date"}:qn(n,dl)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function Jg(e){if(e===void 0)return null;let t=Ro(e);return t.ok?null:t.rejection}function Po(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 Vc(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function vo(e,t){if(!e){let a=jb(t);return a?kb(new Set,a,hb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Vc(a,fa,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=hb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(e.root);let i=jb(t);return i?kb(r,i,hb):String(n+1)}function ul(e,t){if(e.kind==="textValue")return e;let n=t.get(e.id);if(n!==void 0)return n;let r=false,o=[];for(let i of e.children){let a=ul(i,t);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function Kc(e,t,n){let r=ul(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:ia}]};return Oa(e,e.root.id,o,{deferValidation:true})}function pl(e,t,n){let r=new Map;for(let i of t){if(i.stampParagraph===null)continue;let a=r.get(i.commentsPartName);a||(a=new Map,r.set(i.commentsPartName,a)),a.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let o=e;for(let[i,a]of r){let s=o.parts.get(i);if(!s)return null;let l=eb(s.root),d=l??"w14",c=new Map;for(let p of a.values())c.set(p.paragraph.id,n(p.paragraph,p.paraId,d));let u=Kc(s,c,l===null?d:null);if(!u.ok)return null;o=Nd$1(o,u.part);}return o}function fl(e,t,n){let r=e.root.children.map(o=>o.kind==="textValue"?o:t.get(o.id)??o);return Ma(e,e.root.id,[...r,...n],{deferValidation:true})}var yl="/word/comments.xml",xl="/word/commentsExtended.xml",wo="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",No="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Gc=[No,"application/vnd.ms-word.commentsExtended+xml"],kl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Eo="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",Ze="http://schemas.microsoft.com/office/word/2012/wordml";function on(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Mt(e,t){return {kind:"genericExtension",namespaceUri:fa,localName:e,prefix:"w",value:t}}function Xe(e,t,n,r,o,i,a,s=[]){return {id:e,kind:t,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function Rl(e,t,n,r,o){let i=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let a of i)for(let s of Pd$1(e,a)){if(s.type!==n)continue;let l=w(a,s.rawTarget);if(!l.ok)continue;if(!e.parts.has(l.partName))return l.partName;let d=Qd$1(e,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return o}function Oo(e,t,n){let r=e.mainDocumentPart;for(let i of Pd$1(e,r)){if(i.type!==t)continue;let a=w(r,i.rawTarget);if(a.ok&&a.partName===n)return e}let o=Ud$1(e,r);return Vd$1(o,r,t,wh(r,n)).pkg}function To(e,t){return Rl(e,t,kl,wo,yl)}function Pl(e,t){let n=Xg(e,t),r=Yg(e,t,n).extended;return r!==null?r:Rl(e,t,Eo,Gc,xl)}function gl(e){let t=new Set;for(let n of e.parts.values())for(let r of db(n.root))t.add(r);return t}function Xc(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&on(o,fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=on(a,ia,"paraId");s!==void 0&&$a(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),n}function Yc(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&on(o,fa,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){n=a;return}}return}for(let i of o.children)r(i);}};return r(e.root),n}function vl(e){let t=eb(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:ia}]},r=Oa(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(La(e.root,n),{part:{...e,root:n},prefix:"w14"})}function Ol(e,t,n){return Xe(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===ia&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:ia,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function Jc(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let i=vl(o),a=Ja(i.part,n);if(!a||a.kind!=="paragraph")return Nd$1(e,i.part);let s=Oa(i.part,a.id,Ol(a,r,i.prefix),{deferValidation:true});return Nd$1(e,s.ok?s.part:i.part)}function qc(e,t,n,r){let o=`${yl}#comment-${e}`,i=n.text!==n.text.trim(),a=Xe(`${o}.t`,"text",fa,"w","t",i?[{kind:"xmlSpace",namespaceUri:ga,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=Xe(`${o}.rPr`,"runProperties",fa,"w","rPr",[],[Xe(`${o}.rStyle`,"generic",fa,"w","rStyle",[Mt("val","CommentReference")],[])]),l=Xe(`${o}.r`,"run",fa,"w","r",[],[s,a]),d=Xe(`${o}.pPr`,"paragraphProperties",fa,"w","pPr",[],[Xe(`${o}.pStyle`,"generic",fa,"w","pStyle",[Mt("val","CommentText")],[])]),c=Xe(`${o}.p`,"paragraph",fa,"w","p",[{kind:"genericExtension",namespaceUri:ia,localName:"paraId",prefix:r,value:t}],[d,l]);return Xe(o,"comment",fa,"w","comment",[Mt("id",e),Mt("author",n.author),...n.initials===void 0?[]:[Mt("initials",n.initials)],...n.date===void 0?[]:[Mt("date",n.date)]],[c])}function Io(e,t){let n=za(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function Co(e,t){for(let x of [cl(t.author),ml(t.text)])if(x)return {ok:false,reason:Po(x)};let n;if(t.date!==void 0){let x=Ro(t.date);if(!x.ok)return {ok:false,reason:Po(x.rejection)};n=x.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,i=e.part.name,a=To(o,i),s=Pl(o,i),l=o.parts.get(a),d=vo(l,r.actorId),c=cb(`${a}#${d}`,gl(o)),u=t.replyToCommentId===void 0?null:Xc(l,t.replyToCommentId),p=t.replyToCommentId!==void 0&&u===null?Yc(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&u===null&&!p)return {ok:false,reason:"unknown-revision"};let R=p?cb(`${a}#parent-${t.replyToCommentId}`,new Set([...gl(o),c])):null,m=u??R,g=t.anchor.endParagraphId??t.anchor.paragraphId,h=e.transact(x=>{let k=en(x);k.applyPackage(f=>{let v=f.parts.has(a)?f:(()=>{let O=Io(a,`<w:comments xmlns:w="${fa}"/>`);return O?Wd$1(f,a,O,wo):null})();return v===null?f:Oo(v,kl,a)}),p&&R&&k.applyPackage(f=>Jc(f,a,p.id,R)),k.applyPackage(f=>{let v=f.parts.get(a);if(!v)return f;let O=vl(v),P=Na(O.part,O.part.root.id,O.part.root.children.length,[qc(d,c,r,O.prefix)],{deferValidation:true});return P.ok?Nd$1(f,P.part):f}),m!==null&&(k.applyPackage(f=>{let v=f.parts.has(s)?f:(()=>{let O=Io(s,`<w15:commentsEx xmlns:w15="${Ze}"/>`);return O?Wd$1(f,s,O,No):null})();return v===null?f:Oo(v,Eo,s)}),k.applyPackage(f=>{let v=f.parts.get(s);if(!v)return f;let P=[...Qc(v).has(m.toUpperCase())?[]:[So(`${s}#ex-${m}`,m,void 0,false)],So(`${s}#ex-${c}`,c,m,false)],y=Na(v,v.root.id,v.root.children.length,P,{deferValidation:true});return y.ok?Nd$1(f,y.part):f})),k.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"reference"}),k.applyTo(i,{op:"insertCommentMarker",paragraphId:g,offset:t.anchor.end,commentId:d,marker:"end"}),k.applyTo(i,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return h.ok?{ok:true,commentId:d,change:h.change}:{ok:false,reason:h.reason}}function bo(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 hl(e){let t=bo(e);if(!t)return null;let n=on(t,ia,"paraId");return n!==void 0&&$a(n)?n.toUpperCase():null}function Qc(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===Ze&&r.localName==="commentEx"){let o=on(r,Ze,"paraId");o!==void 0&&$a(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function rn(e,t){return {kind:"genericExtension",namespaceUri:Ze,localName:e,prefix:"w15",value:t}}function Zc(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 em(e,t,n){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===Ze&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===Ze&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&t!==void 0&&r.push(rn("paraIdParent",t)),o||r.push(rn("done",n?"1":"0")),Zc(e,r)}function So(e,t,n,r){return {id:e,kind:"generic",namespaceUri:Ze,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[rn("paraId",t),...n===void 0?[]:[rn("paraIdParent",n)],rn("done",r?"1":"0")],children:[]}}function Mo(e,t,n){return tm(e,t,n,Wg())}function tm(e,t,n,r){let o=e.package,i=e.part.name;if(Xg(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=_g(o,t,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=Zg(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,u=[];for(let g of s.ids){let h=s.records.get(g);if(!h)return {ok:false,reason:"unknown-comment"};if(!bo(h.node))return {ok:false,reason:"unknown-comment"};let k=hl(h.node),f=k??cb(`${h.partName}#done-${g}`,d);k===null&&d.add(f),c.set(g,f);}for(let g of s.ids){let h=s.records.get(g),x=bo(h.node),k=c.get(g),f=hl(h.node),v=s.parentCommentIdByChildId.get(g),O=s.parentParaIdByCommentId.get(g)??(v===void 0?void 0:c.get(v)),P=s.commentExByParaId.get(k);u.push({paraId:k,stampParagraph:f===null?x:null,commentsPartName:h.partName,parentParaId:O,existing:P?.node,existingParentParaId:P?.parentParaId,existingDone:P?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(g=>g.existingDone===n))return {ok:true,changed:false,change:null};let p=s.extendedPartName??xl,R=s.extendedPartName===null,m=e.transact(g=>{en(g).applyPackage(x=>{let k=pl(x,u,Ol);if(k===null)return x;let f=k;if(!f.parts.has(p)){let T=Io(p,`<w15:commentsEx xmlns:w15="${Ze}"/>`);if(!T)return x;let N=Wd$1(f,p,T,No);f=R?Oo(N,Eo,p):N;}let v=f.parts.get(p);if(!v)return x;let O=new Map,P=[];for(let T of u){let N=T.existingParentParaId??T.parentParaId;T.existing?O.set(T.existing.id,em(T.existing,N,n)):P.push(So(`${p}#done-${T.paraId}`,T.paraId,N,n));}let y=fl(v,O,P);return y.ok?Nd$1(f,y.part):x});});return m.ok?{ok:true,changed:true,change:m.change}:{ok:false,reason:m.reason}}function nm(e,t){let n=To(e,t);return e.parts.has(n)&&Qd$1(e,n)===wo}function rm(e,t){return To(e,t)}function om(e,t){return Pl(e,t)}var Il={kind:"body"};function am(e,t,n=Il){let r=n.kind==="body"?null:e.resolveStory(n),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),Ea(e,()=>{let s=Co(o,t);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Fa(s))}function im(e,t,n){let r=e.bodyStore(),o=e.currentPackage(),i=Ni$1(Vf(o),{op:"setCommentResolved"});if(i)return {ok:false,reason:i};let a=r.checkpoint();return r.graftPackage(()=>e.currentPackage()),Ea(e,()=>{let s=Mo(r,t,n);return !s.ok||!s.changed||(r.restoreHistoryStacks(a),e.replacePackageShell(r.package),e.adoptPackageUnit(o),e.publishStoryWrite(s.change)),s},s=>s.ok&&s.changed)}function sm(e,t,n=Il,r){if(t.length===0||Ni$1(Vf(e.currentPackage()),{op:"deleteComments"}))return false;let o=n.kind==="body"?e.bodyStore().part:e.partFor(n);if(!o)return false;let i={storyPartName:o.name,...r===void 0?{}:{noteId:r}},a=e.bodyStore(),s=e.currentPackage(),l=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),Ea(e,()=>{let d=false,c=false,u=a.transact(p=>{en(p).applyPackage(m=>{let g=m;for(let h of t){let x=h.parentCommentId===void 0?hh(g,h.commentId,i):ih(g,h.commentId,h.parentCommentId,i);if(x===null)return d=true,m;c||=x!==g,g=x;}return g});});return d||!u.ok||!c?false:(a.restoreHistoryStacks(l),e.installPackageSnapshot(a.package),e.adoptPackageUnit(s),e.publishStoryWrite(u.change),true)},d=>d)}var Sl=256*1024,wl=4096;function Do(e,t,n){let r=t.payload,o=e.part.name,i=n??o;if(r){if(r.data.length>Sl)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>wl)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(Ab(e.part.root).map(p=>p.node.id)),s=t.replaceControlId===void 0?[]:Nl(e,o,t.replaceControlId),l=null,d,c=e.transact(p=>{if(t.replaceControlId!==void 0){p.apply({op:"removeContentControl",controlId:t.replaceControlId,keepContent:false});for(let g of s)p.applyPackage(h=>Eh(h,g.partName,g.nodeId));}let R=t.replaceUntil;if(R!==void 0&&R<=t.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(R!==void 0&&p.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:R}),!r){p.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock}});return}let m=null;p.applyPackage(g=>{let h=zh(g,i,r.namespaceUri,r.rootLocalName);if(!h.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,g;if(m=Jh(h.part,r.rootLocalName,r.nodeId),!m)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,g;let x=Dh(h.pkg,h.part.partName,{id:r.nodeId,label:r.label,data:r.data});return Ch(x,h.part.partName,r.nodeId)?x:(l="store-not-authored",d="the payload node could not be written into the store",g)}),!(l!==null||!m)&&p.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock},dataBinding:m});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=lm(e,a);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function lm(e,t){for(let n of Ab(e.part.root))if(!t.has(n.node.id))return n.node.id}function Nl(e,t,n){let r=Ab(e.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of xh(e.package,t)){let a=Mh(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Ao(e,t){let n=e.part.name,r=Nl(e,n,t),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let a of r)i.applyPackage(s=>Eh(s,a.partName,a.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function dm(e,t,n){if(!e.parts.has(t)||n.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let i of n){let a=yh(r,t,i);if(!a)continue;let s=Lh(r,a.itemId),l=Fh(r,a.partName,s);if(l.pkg===r&&Bh$1(r,a.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var bl=new WeakMap;function cm(e,t){let n=bl.get(e);n||(n=new Map,bl.set(e,n));let r=n.get(t);if(r)return r;let o=xh(e,t).map(i=>({itemId:i.itemId,nodes:new Map(Bh$1(e,i.partName).map(a=>[a.id,a]))}));return n.set(t,o),o}function mm(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let i=cm(e,n);if(i.length===0)return r;for(let a of Ab(o.root))for(let s of i){let l=Mh(a.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(a.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function um(e,t,n){let r=new Map,o=yh(e,t,n);if(!o)return r;for(let i of Bh$1(e,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var El={kind:"body"};function Tl(e,t,n){let r=t.kind==="body"?null:e.resolveStory(t),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),Ea(e,()=>{let s=n(o);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Fa(s))}function pm(e,t,n=El){return Tl(e,n,r=>Do(r,t,e.bodyStore().part.name))}function fm(e,t,n=El){return Tl(e,n,r=>Ao(r,t))}var Ml=new WeakMap;function Ie(e,t){return Ml.set(e,t),e}function Z(e){return Ml.get(e)??[]}function an(e){return `${e.kind}-${e.id}`}function _o(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function Dl(e){return _o(e)[0]??null}function Dt(e,t){let n=Dl(e);if(!n)return Number.MAX_SAFE_INTEGER;let r=t.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function gm(e,t){let n=t.get(e.start.paragraphId),r=t.get(e.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(e.end.offset-e.start.offset)}var hm=0,ym=1,xm=2;function km(e,t,n){let r=n.get(t.paragraphId),o=n.get(e.start.paragraphId),i=n.get(e.end.paragraphId);return r===void 0||o===void 0||i===void 0||r<o||r>i||r===o&&t.offset<e.start.offset||r===i&&t.offset>e.end.offset?null:o===i&&e.start.offset===e.end.offset?hm:r===i&&t.offset===e.end.offset?xm:ym}function Rm(e,t,n){let r=null;for(let o of _o(e)){let i=km(o,t,n);if(i===null)continue;let a=gm(o,n);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var Cl={comment:0,custom:1,revision:2};function Pm(e,t,n){let r=[];for(let o of e){let i=Rm(o,t,n);i!==null&&r.push({item:o,grip:i.grip,width:i.width});}return r.sort((o,i)=>o.grip!==i.grip?o.grip-i.grip:o.width!==i.width?o.width-i.width:o.item.kind!==i.item.kind?Cl[o.item.kind]-Cl[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function Uh(e,t,n){let o=Pm(e,t,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?Al(e,o):o:null}function Bh(e,t){return Al(e,t)}function Al(e,t){let n=new Map,r=new Map;for(let a of e)a.kind==="comment"?n.set(a.id,a):a.kind==="revision"&&r.set(a.id,a);let o=new Set([t.id]),i=t;for(;i.parentId!==void 0;){let a=n.get(i.parentId);if(!a||o.has(a.id))break;o.add(a.id),i=a;}if(i.parentRevisionId!==void 0){let a=r.get(i.parentRevisionId);if(a)return a}return i}function _l(e){let t=[],n=r=>{if(r.kind==="textValue"){t.push(r.value);return}for(let o of r.children)n(o);};for(let r of e.blocks)n(r);return t.join("")}function Fl(e){if(e.initials&&e.initials.trim().length>0)return e.initials.trim();let t=e.author.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function ut(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return Za(e);if(qe$1(e))return "";let t="";for(let n of e.children)t+=ut(n);return t}var At=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t;function Ll(e,t,n){let r=new Set(["tcPrChange","trPrChange","tblPrExChange","tblGridChange","tblPrChange"]),o=new Map(n.filter(g=>g.propertyChange&&r.has(g.node.localName)).map(g=>[g.node.id,g]));if(!o.size)return [...t];let i=li(e,n).tableHistories,a=[],s=new Map,l=g=>g.node.attributes.find(h=>h.namespaceUri===fa&&h.localName==="author")?.value??"",d=(g,h)=>{if(g.kind==="textValue"||At(g,"tbl"))return;let x=o.get(g.id);x&&h.push(x);for(let k of g.children)d(k,h);},c=g=>{if(g.kind!=="textValue"){if(At(g,"tbl")){let h,x=[],k=[],f=[],v=false;for(let P of g.children){if(At(P,"tblGrid")&&d(P,k),At(P,"tblPr")&&d(P,f),!At(P,"tr"))continue;let y=[];if(d(P,y),v||=y.some(N=>N.refused),!y.length||y.some(N=>N.refused)){h=void 0;continue}let T=l(y[y.length-1]);(!h||h.author!==T)&&(h={ids:new Set,author:T,tableId:g.id},a.push(h),x.push(h));for(let N of y)h.ids.add(N.node.id);}let O=x.at(-1);if(O&&!v&&k.every(P=>!P.refused)){for(let P of k)O.ids.add(P.node.id);if(x.length===1&&k.length>0)for(let P of f){let y=P.node.children.find(T=>At(T,"tblPr"));!P.refused&&P.parent?.kind==="tableProperties"&&y&&l(P)===O.author&&(i.has(P.node.id)||ua({...P.parent,children:P.parent.children.filter(T=>T.id!==P.node.id)},y))&&O.ids.add(P.node.id);}}}for(let h of g.children)c(h);}};c(e.root);for(let g of a)for(let h of g.ids)s.set(h,g);let u=new Set;for(let g of t){let x=Z(g).map(k=>s.get(k));if(x.some(k=>k!==x[0]))for(let k of x)k&&u.add(k.tableId);}for(let g of a)if(u.has(g.tableId))for(let h of g.ids)o.get(h)?.node.localName==="tblGridChange"&&(g.ids.delete(h),s.delete(h));let p=new Map;for(let g of t){let h=Z(g),x=h.length?s.get(h[0]):void 0;if(!x||g.readOnly||g.revisionKind!=="format"||!h.every(f=>s.get(f)===x))continue;let k=p.get(x)??[];k.push(g),p.set(x,k);}let R=new Map,m=new Set;for(let g of a){let h=p.get(g)??[],x=h.find(y=>!["tblGridChange","tblPrChange"].includes(y.formattingKind??""))??h[0],k=x?[x,...h.filter(y=>y!==x)]:[],f=k.flatMap(Z),v=new Set(f);if(!x||k.length<2||![...g.ids].every(y=>v.has(y)))continue;let O=[...new Map(k.flatMap(y=>y.addresses).map(y=>[JSON.stringify([y.id,y.author,y.date??null]),y])).values()],P=[...new Map(k.filter(y=>!["tblGridChange","tblPrChange"].includes(y.formattingKind??"")).flatMap(y=>y.ranges).map(y=>[JSON.stringify(y),y])).values()];R.set(x,Ie({...x,author:g.author,addresses:O,ranges:P,text:[...new Set(k.map(y=>y.text).filter(Boolean))].join(`
|
|
2
|
-
`)},f));for(let y of k.slice(1))m.add(y);}return t.filter(g=>!m.has(g)).map(g=>R.get(g)??g)}var Ul=e=>e.kind==="textValue"?e.value:[e.namespaceUri,e.localName,e.attributes.map(t=>[t.namespaceUri,t.localName,t.value]).sort((t,n)=>JSON.stringify(t).localeCompare(JSON.stringify(n))),e.children.map(Ul)],$l=e=>new Map(e.children.filter(t=>t.kind!=="textValue"&&!(t.namespaceUri===fa&&t.localName==="rPrChange")).map(t=>t.kind==="textValue"?["",""]:[JSON.stringify([t.namespaceUri,t.localName]),JSON.stringify(Ul(t))]));function vm(e){if(e.node.localName!=="rPrChange"||!e.parent||e.paragraphMark||e.refused)return;let t=e.node.children.find(i=>i.kind!=="textValue"&&i.namespaceUri===fa&&i.localName==="rPr");if(!t||t.kind==="textValue")return;let n=$l(t),r=$l(e.parent),o=[...new Set([...n.keys(),...r.keys()])].sort().filter(i=>n.get(i)!==r.get(i)).map(i=>[i,r.get(i)??null]);return o.length?JSON.stringify(o):void 0}function Bl(e,t){let n=new Map(t.map(s=>[s.node.id,vm(s)])),r=new Map;for(let s of e){if(s.revisionKind!=="format"||s.formattingKind!=="rPrChange"||s.readOnly||s.ranges.length!==1)continue;let l=s.ranges[0];if(l.start.paragraphId!==l.end.paragraphId||l.start.offset===l.end.offset)continue;let d=Z(s),c=d.length?n.get(d[0]):void 0;if(!c||!d.every(R=>n.get(R)===c))continue;let u=JSON.stringify([s.author,l.partName,l.start.paragraphId,c]),p=r.get(u)??[];p.push(s),r.set(u,p);}let o=new Set,i=new Map,a=s=>{if(s.length<2)return;let l=s[0],d=[...new Map(s.flatMap(c=>c.addresses).map(c=>[JSON.stringify([c.id,c.author,c.date??null]),c])).values()];i.set(l,Ie({...l,addresses:d,ranges:s.flatMap(c=>c.ranges),text:s.map(c=>c.text).join("")},s.flatMap(Z)));for(let c of s.slice(1))o.add(c);};for(let s of r.values()){s.sort((d,c)=>d.ranges[0].start.offset-c.ranges[0].start.offset);let l=[];for(let d of s)l.length&&l[l.length-1].ranges[0].end.offset!==d.ranges[0].start.offset&&(a(l),l=[]),l.push(d);a(l);}return e.filter(s=>!o.has(s)).map(s=>i.get(s)??s)}var ue=(e,t)=>e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t,sn=(e,t)=>e.attributes.find(n=>n.namespaceUri===fa&&n.localName===t)?.value;function Om(e,t,n){let r=e.children.filter(o=>ue(o,"tc"));return r.length>0&&r.every(o=>{if(o.kind==="textValue")return false;let i=o.children.filter(a=>a.kind==="paragraph");return i.length>0&&i.every(a=>{if(a.kind==="textValue")return false;let s=a.children.find(u=>ue(u,"pPr")),l=s?.kind!=="textValue"?s?.children.find(u=>ue(u,"rPr")):void 0,d=l?.kind!=="textValue"?l?.children.filter(u=>ue(u,"ins")||ue(u,"del")):void 0,c=d?.length===1?d[0]:void 0;return !!c&&c.kind!=="textValue"&&c.localName===t&&sn(c,"author")===n})})}function Im(e,t,n,r){let o=new Map(n.filter(f=>f.parent?.localName==="trPr"&&(f.node.localName==="ins"||f.node.localName==="del")).map(f=>[f.node.id,f]));if(o.size===0)return [...t];let i=new Map(n.map(f=>[f.node.id,f])),a=new Map;for(let f of r.values())a.set(f.paragraphId,Math.max(a.get(f.paragraphId)??0,f.end));let s=[],l=new Map,d=new Set,c=new Map,u=(f,v)=>{if(f.kind==="textValue"||ue(f,"tbl"))return;let O=i.get(f.id),P=o.has(f.id);O&&!O.propertyChange&&f.localName===v.direction&&!O.refused&&(P?sn(f,"author")===v.author:O.paragraphMark||f.kind==="revisionInsert"||f.kind==="revisionDelete")&&(c.set(f.id,v),P&&v.markerIds.add(f.id));for(let y of f.children)u(y,v);},p=(f,v=0)=>{if(f.kind!=="textValue"){if(ue(f,"tr")&&v>1){let O=f.children.find(P=>ue(P,"trPr"));if(O&&O.kind!=="textValue")for(let P of O.children)o.has(P.id)&&l.set(P.id,f);}if(ue(f,"tbl")){let O;for(let P of f.children){if(P.kind==="textValue"||!ue(P,"tr")){O=void 0;continue}let y=P.children.find(ee=>ue(ee,"trPr")),T=y?.kind!=="textValue"?y?.children.filter(ee=>o.has(ee.id))??[]:[],N=T.length===1?T[0]:void 0,j=N&&N.kind!=="textValue"?sn(N,"author"):void 0;if(!N||N.kind==="textValue"||j===void 0||o.get(N.id)?.refused){O=void 0;continue}let z=N.localName;if(v>0){if(!Om(P,z,j)){O=void 0;continue}d.add(P.id);}(!O||O.author!==j||O.direction!==z)&&(O={markerIds:new Set,rows:[],author:j,direction:z,followingText:[]},s.push(O)),O.rows.push(P),O.markerIds.add(N.id),u(P,O);}}for(let O of f.children)p(O,v+(ue(f,"tbl")?1:0));}};p(e.root);let R,m=new Set(s.flatMap(f=>f.rows.map(v=>v.id))),g=(f,v=0,O=false)=>{if(f.kind==="textValue")return;d.has(f.id)&&(R=void 0);let P=v+(ue(f,"tbl")?1:0),y=O||m.has(f.id);if(f.kind==="run"&&!y&&(R=void 0),R&&(f.kind==="revisionInsert"||f.kind==="revisionDelete")){let T=R;R=void 0;let N=i.get(f.id),j=sn(T.marker,"author");if(N&&!N.refused&&j!==void 0&&f.localName===T.marker.localName&&sn(f,"author")===j&&(c.get(f.id)?.author??j)===j){let z=c.get(f.id);z||(z={markerIds:new Set,rows:[T.row],author:j,direction:T.marker.localName,followingText:[ut(f)],rowEndOnly:true},s.push(z),c.set(f.id,z)),z.markerIds.add(T.marker.id),c.set(T.marker.id,z);}}for(let T of f.children)g(T,P,y);if((ue(f,"tc")||f.kind==="paragraph"&&!y)&&(R=void 0),ue(f,"tr")&&(R=void 0,P>1&&!d.has(f.id))){let T=f.children.find(z=>ue(z,"trPr")),N=T&&T.kind!=="textValue"?T.children.filter(z=>o.has(z.id)):[],j=N.length===1?N[0]:void 0;j&&j.kind!=="textValue"&&!o.get(j.id)?.refused&&(R={marker:j,row:f});}};g(e.root),t=t.map(f=>{let v=Z(f);if(f.revisionKind!=="structural"||!v.length||!v.every(P=>l.has(P)))return f;let O=[];for(let P of v){let y,T=N=>{if(!(N.kind==="textValue"||ue(N,"tbl")))if(N.kind==="paragraph")y=N;else for(let j of N.children)T(j);};if(T(l.get(P)),y){let N={paragraphId:y.id,offset:a.get(y.id)??0};O.push({partName:e.name,start:N,end:N});}}return O.length?Ie({...f,ranges:O},v):f});let h=new Map;for(let f of t){let v=Z(f),O=v.length?c.get(v[0]):void 0;if(!O||f.readOnly||!v.every(y=>c.get(y)===O))continue;let P=h.get(O)??[];P.push(f),h.set(O,P);}let x=new Set,k=new Map;for(let f of s){let v=h.get(f)??[],O=v.find(_=>Z(_).some(B=>f.markerIds.has(B))),P=new Set(v.flatMap(Z));if(!O||![...f.markerIds].every(_=>P.has(_)))continue;let y=[O,...v.filter(_=>_!==O)],T=y.flatMap(_=>_.addresses),N=[],j=[],z=_=>{if(!(_.kind==="textValue"||ue(_,"tbl"))){if(_.kind==="paragraph"){N.push({partName:e.name,start:{paragraphId:_.id,offset:0},end:{paragraphId:_.id,offset:a.get(_.id)??0}}),j.push(ut(_));return}for(let B of _.children)z(B);}};for(let _ of f.rows)z(_);if(f.rowEndOnly&&N.length){let _=N[N.length-1];N.splice(0,N.length,{..._,start:_.end});}let ee=new Set(N.map(_=>_.start.paragraphId));for(let _ of y)if(!(_.revisionKind==="structural"&&Z(_).some(B=>!l.has(B))))for(let B of _.ranges)ee.has(B.start.paragraphId)||N.push(B);j.push(...f.followingText);let X=Ie({...O,addresses:[...new Map(T.map(_=>[JSON.stringify([_.id,_.author,_.date??null]),_])).values()],ranges:N.length?N:y.flatMap(_=>_.ranges),text:j.join(`
|
|
3
|
-
`),nesting:y.reduce((_,B)=>Math.min(_,B.nesting),O.nesting)},y.flatMap(Z));k.set(O,X);for(let _ of v)_!==O&&x.add(_);}return t.filter(f=>!x.has(f)).map(f=>k.get(f)??f)}function jl(e,t,n,r,o){let i=Bl(Ll(e,Im(e,t,n,r),n),n),a=new Set(n.filter(s=>s.node.kind==="moveFromRangeStart"||s.node.kind==="moveToRangeStart").map(s=>s.node.id));return a.size>0||n.some(s=>s.parent?.localName==="trPr"&&["ins","del"].includes(s.node.localName))?i.sort((s,l)=>Dt(s,o)-Dt(l,o)||Number(Z(l).some(d=>a.has(d)))-Number(Z(s).some(d=>a.has(d)))):i}function Hl(e){if(e.parent?.localName==="trPr"){if(e.node.localName==="ins")return "rowInsert";if(e.node.localName==="del")return "rowDelete"}if(e.parent?.localName==="tcPr"){if(e.node.localName==="cellIns")return "cellInsert";if(e.node.localName==="cellDel")return "cellDelete";if(e.node.localName==="cellMerge")return "cellMerge"}if(e.parent?.localName==="numPr"&&e.node.localName==="ins")return "numberingInsert"}function Vl(e,t,n,r){if(!e.some(m=>m.revisionKind==="paragraphMark"))return e;let o=new Map,i=(m,g)=>{if(!(m.kind==="textValue"||g>64))for(let h=0;h<m.children.length;h+=1){let x=m.children[h],k=m.children[h+1];x.kind==="paragraph"&&k?.kind==="paragraph"&&o.set(x.id,k.id),i(x,g+1);}};i(t.root,0);let a=e.map((m,g)=>g),s=m=>{for(;a[m]!==m;)a[m]=a[a[m]],m=a[m];return m},l=new Map,d=new Map,c=(m,g,h)=>JSON.stringify([m.revisionKind==="paragraphMark"?m.markDirection:m.revisionKind,m.author,m.nesting,g,h]),u=(m,g,h)=>{let x=m.get(g);x?x.push(h):m.set(g,[h]);};e.forEach((m,g)=>{if(!(m.readOnly||!["insert","delete","paragraphMark"].includes(m.revisionKind)))for(let h of m.ranges)u(l,c(m,h.start.paragraphId,h.start.offset),g),u(d,c(m,h.end.paragraphId,h.end.offset),g);});let p=(m,g)=>{for(let h of g){let x=e[m].date,k=e[h].date;x!==void 0&&k!==void 0&&!qg(x,k)||(a[s(h)]=s(m));}};e.forEach((m,g)=>{if(!(m.readOnly||m.revisionKind!=="paragraphMark"||!["insert","delete"].includes(m.markDirection??"")))for(let h of m.ranges){p(g,d.get(c(m,h.start.paragraphId,h.start.offset))??[]);let x=o.get(h.end.paragraphId);x&&p(g,l.get(c(m,x,0))??[]);}});let R=new Map;return e.forEach((m,g)=>{let h=s(g),x=R.get(h);x?x.push(m):R.set(h,[m]);}),[...R.values()].map(m=>{if(m.length===1)return m[0];let g=m.flatMap(v=>v.ranges).sort((v,O)=>n.get(v.start.paragraphId)-n.get(O.start.paragraphId)||v.start.offset-O.start.offset),h=m.flatMap(v=>Z(v)).flatMap(v=>{let O=r.get(v);return O?[O]:[]}).sort((v,O)=>n.get(v.range.start.paragraphId)-n.get(O.range.start.paragraphId)||v.range.start.offset-O.range.start.offset),x=m[0],k=m.find(v=>v.revisionKind!=="paragraphMark"),f=[...new Map(m.flatMap(v=>v.addresses).map(v=>[JSON.stringify(v),v])).values()];return Ie({...x,id:m.map(v=>v.id).join("+"),revisionKind:k?.revisionKind??"paragraphMark",...k?{markDirection:void 0}:{},addresses:f,ranges:g,text:k?h.map(v=>v.text).join(""):""},m.flatMap(v=>Z(v)))})}function Fo(e){if(!e.propertyChange||!e.parent)return [];let t=(o,i)=>{let a=o?.children.find(s=>s.kind!=="textValue"&&s.namespaceUri===fa&&s.localName==="lang");return a&&a.kind!=="textValue"?a.attributes.find(s=>s.namespaceUri===fa&&s.localName===i)?.value:void 0},n=e.node.children.find(o=>o.kind!=="textValue"&&o.localName===e.parent.localName),r=[];for(let o of ["val","eastAsia","bidi"]){let i=t(e.parent,o),a=t(n?.kind!=="textValue"?n:void 0,o);i&&i!==a&&!r.includes(i)&&r.push(i);}return r}var bm=[{property:"bold",element:"b",attribute:"val",kind:"toggle"},{property:"italic",element:"i",attribute:"val",kind:"toggle"},{property:"underline",element:"u",attribute:"val"},{property:"strike",element:"strike",attribute:"val",kind:"toggle"},{property:"fontFamily",element:"rFonts",attribute:"ascii"},{property:"fontSize",element:"sz",attribute:"val",kind:"halfPoints"},{property:"color",element:"color",attribute:"val"},{property:"alignment",element:"jc",attribute:"val"},{property:"leftIndent",element:"ind",attribute:"left",kind:"twips"},{property:"rightIndent",element:"ind",attribute:"right",kind:"twips"},{property:"firstLineIndent",element:"ind",attribute:"firstLine",kind:"twips"},{property:"hangingIndent",element:"ind",attribute:"hanging",kind:"twips"},{property:"spaceBefore",element:"spacing",attribute:"before",kind:"twips"},{property:"spaceAfter",element:"spacing",attribute:"after",kind:"twips"}];function Lo(e){if(!e.propertyChange||!e.parent)return [];let t=e.node.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===fa&&r.localName===e.parent.localName),n=[];for(let r of bm){let o=a=>{let s=a?.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===fa&&d.localName===r.element);if(!s||s.kind==="textValue")return null;let l=s.attributes.find(d=>d.namespaceUri===fa&&d.localName===r.attribute)?.value;if(r.kind==="toggle")return l==="0"||l==="false"||l==="off"?"false":"true";if(l===void 0)return null;if(r.kind==="halfPoints"||r.kind==="twips"){let d=Number(l);return Number.isFinite(d)?String(d/(r.kind==="halfPoints"?2:20)):l}return l},i=o(e.parent);i!==o(t?.kind!=="textValue"?t:void 0)&&n.push({property:r.property,value:i});}return n}function Zn(e){return Gl(e,true)}function py(e){return Gl(e,false)}function Gl(e,t){let n=t?zl.get(e.root):void 0;if(n)return n;let r=new Map,o=s=>{let l=t?Wl.get(s):void 0;if(l){for(let[c,u]of l)r.set(c,u);return}let d=new Map;wm(s,d,t),t&&Wl.set(s,d);for(let[c,u]of d)r.set(c,u);},i=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){o(s);return}for(let d of s.children)i(d,l+1);}};i(e.root,0);let a=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){let d=t?Kl.get(s):void 0;if(!d){let c=[];Xl(s,0,c,t),d=c,t&&Kl.set(s,d);}for(let[c,u]of d)r.set(c,u);return}if(s.kind==="table"||s.kind==="tableRow"||s.kind==="tableCell"){let d=t?Qn.get(s):void 0;d||(d=Yl(s),t&&Qn.set(s,d));for(let[c,u]of d)r.set(c,u);}for(let d of s.children)a(d,l+1);}};return a(e.root,0),t&&zl.set(e.root,r),r}function Xl(e,t,n,r){if(!(e.kind==="textValue"||t>64)){if(e.kind==="table"||e.kind==="tableRow"||e.kind==="tableCell"){let o=r?Qn.get(e):void 0;o||(o=Yl(e),r&&Qn.set(e,o));for(let i of o)n.push(i);}for(let o of e.children)Xl(o,t+1,n,r);}}function Yl(e){let t=null,n=(i,a)=>{if(!(t||i.kind==="textValue"||a>64)){if(i.kind==="paragraph"){t=i;return}for(let s of i.children)n(s,a+1);}};if(n(e,0),!t)return Sm;let r={paragraphId:t.id,start:0,end:0},o=[];if(e.kind==="textValue")return o;for(let i of e.children)if(!(i.kind==="textValue"||!["tblPr","tblGrid","tblPrEx","trPr","tcPr"].includes(i.localName)))for(let a of i.children){if(a.kind==="textValue")continue;(a.localName===`${i.localName}Change`||i.localName==="trPr"&&["ins","del"].includes(a.localName)||i.localName==="tcPr"&&["cellIns","cellDel","cellMerge"].includes(a.localName))&&o.push([a.id,r]);}return o}var Sm=[],Wl=new WeakMap,zl=$g(8),Qn=new WeakMap,Kl=new WeakMap;function wm(e,t,n){let r=n?ff(e):hf(e),o=(s,l,d,c)=>{if(!(s.kind==="textValue"||c>64)){t.set(s.id,{paragraphId:e.id,start:l,end:d});for(let u of s.children)o(u,l,d,c+1);}},i=(s,l)=>{if(s.kind==="textValue"||l>64)return;let d=r.spanOf(s);if(s.kind==="fldSimple"&&d){o(s,d.start,d.end,l);return}if(s.kind==="run"){if(!d)return;t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)c.kind==="runProperties"&&o(c,d.start,d.end,l+1);return}d&&t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)i(c,l+1);};for(let s of e.children)s.kind!=="paragraphProperties"&&i(s,0);let a=e.children.find(s=>s.kind==="paragraphProperties");a&&o(a,r.length,r.length,0);}var Em={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function er(e,t){for(let n of e.attributes)if(n.localName===t&&n.namespaceUri===fa)return n.value}function $o(e){return `${e.id}\0${e.author}\0${e.date??""}`}var Tm={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo",moveFromRangeStart:"moveFrom",moveToRangeStart:"moveTo"},Ql={retainRevisionItems:true,revisionSites:yi,locations:Zn,commentAnchors:bh,deepOrder:Mi$1};function tr(e){return Zl(e,Ql)}function Zl(e,t){let n=e.root.kind!=="paragraph";if(n&&t.retainRevisionItems){let o=Jl.get(e.root);if(o&&o.name===e.name)return o.items}let r=Cm(e,t);return n&&t.retainRevisionItems&&Jl.set(e.root,{name:e.name,items:r}),r}var Jl=$g(8);function Cm(e,t){let n=t.revisionSites(e);if(n.length===0)return [];let r=t.locations(e),o=new Map(mi(e.root).map(m=>[m.start.id,m])),i=oi(e.root),a=n.some(m=>m.paragraphMark),s=new Map,l=new Map,d=ki(e,n);for(let m of n){if(d.has(m.node.id))continue;let g=o.get(m.node.id),h=g?g.content.map(ut).join(""):ut(m.node),x=er(m.node,"id"),k=x??`missing-${m.node.id}`,f=er(m.node,"author")??"",v=er(m.node,"author")===void 0&&m.node.localName!=="tblGridChange",O=er(m.node,"date"),P=O===void 0?{id:k,author:f}:{id:k,author:f,date:O},y=i.has(m.node.id)?"insert":m.propertyChange?"format":m.paragraphMark?"paragraphMark":Tm[m.node.kind]??"structural",T=m.paragraphMark?Em[m.node.localName]:void 0,N=y==="structural"?Hl(m):void 0,j=r.get(m.node.id),z=g?.end&&r.get(g.end.id),ee=j&&z&&j.paragraphId===z.paragraphId?{...j,end:z.end}:j,X=ee?{partName:e.name,start:{paragraphId:ee.paragraphId,offset:ee.start},end:{paragraphId:ee.paragraphId,offset:ee.end}}:null;a&&X&&(y==="paragraphMark"||y==="insert"||y==="delete")&&s.set(m.node.id,{range:X,text:y==="paragraphMark"?`
|
|
4
|
-
`:h});let _=y==="structural"?`structural\0${$o(P)}`:`${y}\0${m.node.localName}\0${$o(P)}`,B=l.get(_);if(B){B.siteNodeIds.push(m.node.id),N&&!B.structuralChanges?.includes(N)&&(B.structuralChanges??=[]).push(N),m.propertyChange&&(B.formattingLanguages=[...new Set([...B.formattingLanguages??[],...Fo(m)])],B.formattingChanges=[...new Map([...B.formattingChanges??[],...Lo(m)].map(ie=>[JSON.stringify(ie),ie])).values()]),X&&!B.ranges.some(ie=>ie.partName===X.partName&&ie.start.paragraphId===X.start.paragraphId&&ie.start.offset===X.start.offset&&ie.end.paragraphId===X.end.paragraphId&&ie.end.offset===X.end.offset)&&B.ranges.push(X),y!=="structural"&&B.revisionKind==="structural"&&(B.revisionKind=y),(y==="insert"&&B.revisionKind==="delete"||y==="delete"&&B.revisionKind==="insert"||B.revisionKind==="replace")&&(B.revisionKind="replace"),B.readOnly||=m.refused||v,m.nesting>B.nesting&&(B.nesting=m.nesting),y==="delete"||y==="moveFrom"?B.deletedText+=h:y!=="format"&&y!=="paragraphMark"&&(B.text+=h);continue}l.set(_,{address:P,localName:m.node.localName,...N?{structuralChanges:[N]}:{},...m.propertyChange?{formattingLanguages:Fo(m),formattingChanges:Lo(m)}:{},revisionKind:y,...T?{markDirection:T}:{},author:f,...O===void 0?{}:{date:O},text:y==="format"||y==="paragraphMark"||y==="delete"||y==="moveFrom"?"":h,deletedText:y==="delete"||y==="moveFrom"?h:"",ranges:X?[X]:[],siteNodeIds:[m.node.id],nesting:m.nesting,readOnly:m.refused||v||x===void 0});}let c=[...l.values()].map(m=>Ie({kind:"revision",id:`${m.revisionKind}${m.revisionKind==="format"||m.revisionKind==="paragraphMark"?`-${m.localName}`:""}-${e.name}\0${$o(m.address)}`,address:m.address,addresses:[m.address],revisionKind:m.revisionKind,...m.revisionKind==="format"?{formattingKind:m.localName}:{},...m.structuralChanges?.length?{structuralChanges:m.structuralChanges}:{},...m.formattingChanges?.length?{formattingChanges:m.formattingChanges}:{},...m.formattingLanguages?.length?{formattingLanguages:m.formattingLanguages}:{},...m.markDirection?{markDirection:m.markDirection}:{},author:m.author,...m.date===void 0?{}:{date:m.date},text:m.revisionKind==="replace"?m.text:m.text||m.deletedText,replacedText:m.revisionKind==="replace"?m.deletedText:"",ranges:m.ranges,nesting:m.nesting,readOnly:m.readOnly,replyIds:[]},m.siteNodeIds)),u=t.deepOrder(e),p=jl(e,c,n,r,u),R=ed(p,u);return Mm(Vl(R,e,u,s),u)}function Mm(e,t){let n=ed(e,t),r=n.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0),o=new Set,i=new Map,a=new Map;for(let l of r){if(l.revisionKind!=="insert")continue;let d=l.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,u=a.get(c);u?u.push(l):a.set(c,[l]);}for(let l of r){if(l.revisionKind!=="delete"||o.has(l.id))continue;let d=l.ranges[l.ranges.length-1].end,c=a.get(`${d.paragraphId}\0${d.offset}`)??[],u=c.length>1?[...c].sort((p,R)=>(p.text.length>0?0:1)-(R.text.length>0?0:1)):c;for(let p of u){if(o.has(p.id)||p.author!==l.author)continue;o.add(l.id),o.add(p.id);let R=$m(l.ranges[0],p.ranges[0],t)?l:p,m=Lm(l.date,p.date);i.set(l.id,Ie({...R,id:`replace-${l.id}-${p.id}`,revisionKind:"replace",...m===void 0?{}:{date:m},addresses:Fm([...l.addresses,...p.addresses]),text:p.text,replacedText:l.text,ranges:[...l.ranges,...p.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||p.readOnly},[...Z(l),...Z(p)]));break}}let s=[];for(let l of n){let d=i.get(l.id);if(d){s.push(d);continue}o.has(l.id)||s.push(l);}return s}function ed(e,t){let n=e.filter(d=>(d.revisionKind==="insert"||d.revisionKind==="delete")&&!d.readOnly&&d.ranges.length>0);if(n.length<2)return e;let r=d=>`${d.paragraphId}\0${d.offset}`,o=new Map;for(let d of n){let c=`${d.revisionKind}\0${d.author}`,u=o.get(c);u?u.push(d):o.set(c,[d]);}let i=(d,c)=>{let u=d.ranges[0].start,p=c.ranges[0].start,R=(t.get(u.paragraphId)??0)-(t.get(p.paragraphId)??0);return R!==0?R:u.offset-p.offset};for(let d of o.values()){let c=true;for(let u=1;u<d.length&&c;u+=1)c=i(d[u-1],d[u])<=0;c||d.sort(i);}let a=new Set,s=new Map;for(let d of o.values()){let c=[],u="",p=()=>{if(c.length>1){s.set(c[0].id,Am(c));for(let R=1;R<c.length;R+=1)a.add(c[R].id);}c=[];};for(let R of d){let m=r(R.ranges[0].start);c.length>0&&m!==u&&p();let g=c.length===0;c.push(R),(g||Dm(R))&&(u=r(R.ranges[R.ranges.length-1].end));}p();}if(s.size===0)return e;let l=[];for(let d of e)a.has(d.id)||l.push(s.get(d.id)??d);return l}function Dm(e){return e.ranges.some(t=>t.start.paragraphId!==t.end.paragraphId||t.start.offset!==t.end.offset)}function Am(e){let t=e[0],n=[...t.addresses],r=[...t.ranges],o=[...Z(t)],i=t.text,a=t.date;for(let s of e.slice(1)){for(let l of s.addresses)n.some(d=>td(d,l))||n.push(l);for(let l of s.ranges)r.push(l);for(let l of Z(s))o.push(l);i+=s.text,a=_m(a,s.date);}return Ie({...t,id:e.map(s=>s.id).join("+"),addresses:n,ranges:r,text:i,...a===void 0?{}:{date:a}},o)}function _m(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?e:r>n?t:e}function Fm(e){let t=[];for(let n of e)t.some(r=>td(r,n))||t.push(n);return t}function td(e,t){return e.id===t.id&&e.author===t.author&&(e.date??"")===(t.date??"")}function Lm(e,t){if(t===void 0)return e;if(e===void 0)return t;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?t:n>r?e:t}function $m(e,t,n){let r=n.get(e.start.paragraphId)??0,o=n.get(t.start.paragraphId)??0;return r!==o?r<o:e.start.offset<=t.start.offset}function nd(e,t,n){let r=new Map(t.map(c=>[c.commentId,c])),o=new Map,i=new Map;for(let c of e)c.paraId&&o.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let a=new Map,s=new Map;for(let c of e){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let p=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;a.has(p)?s.set(c.id,a.get(p)):a.set(p,c.id);}let l=new Map;for(let c of e){let u=c.paraId?n.get(c.paraId.toUpperCase()):void 0,p=u?.parentParaId?o.get(u.parentParaId):void 0,R=c.parentCommentId?i.get(c.parentCommentId):void 0,m=u===void 0?s.get(c.id):void 0,g=m?i.get(m):void 0,h=p??R??g;h&&h.id!==c.id&&l.set(c.id,h.id);}for(let c of [...l.keys()]){let u=new Set([c]),p=l.get(c);for(;p!==void 0;){if(u.has(p)){l.delete(c);break}u.add(p),p=l.get(p);}}let d=new Map;for(let[c,u]of l){let p=d.get(u);p?p.push(c):d.set(u,[c]);}return e.map(c=>{let u=r.get(c.id),p=c.paraId?n.get(c.paraId.toUpperCase()):void 0,R=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:p?.done??false,...R===void 0?{}:{parentId:R},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function Um(e){return Bm(e,Ql)}function Bm(e,t){let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let c of [...e.furnitureParts??[],...e.stylesPart?[e.stylesPart]:[]])r.has(c.name)||(r.add(c.name),n.push(c));let o=e.commentsPart?dh(e.commentsPart):[],i=e.commentsExtendedPart?eh(e.commentsExtendedPart):new Map,a=[],s=[],l=n.length===1?t.deepOrder(n[0]):new Map;for(let c of n){for(let R of Zl(c,t))a.push(R);for(let R of t.commentAnchors(c))s.push(R);if(n.length===1)continue;let u=l,p=u.size;for(let[R,m]of t.deepOrder(c))u.has(R)||u.set(R,p+m);}return rd([...a,...nd(o,s,i)]).sort((c,u)=>Dt(c,l)-Dt(u,l))}function jm(e,t){if(e.kind!=="comment")return e;let n=e.replyIds??[],r=n.filter(i=>t.has(i)),o=e.parentId!==void 0&&!t.has(e.parentId);if(!o&&r.length===n.length)return e;if(o){let{parentId:i,parentRevisionId:a,...s}=e;return r.length===n.length?s:{...s,replyIds:r}}return {...e,replyIds:r}}function ql(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function rd(e){let t=new Set;for(let l of e)l.kind==="comment"&&t.add(l.id);let n=e.map(l=>jm(l,t)),r=new Map;for(let l of n)if(l.kind==="revision")for(let d of l.ranges??[]){if(d.start.paragraphId===d.end.paragraphId&&d.start.offset===d.end.offset)continue;let c=ql(d),u=l.nesting??0,p=r.get(c);(p===void 0||u>p.nesting)&&r.set(c,{id:l.id,nesting:u});}let o=new Map;for(let l of n)l.kind==="comment"&&l.replyIds&&l.replyIds.length>0&&o.set(l.id,l.replyIds);let i=l=>{let d=[],c=new Set([l]),u=[...o.get(l)??[]];for(;u.length>0;){let p=u.shift();c.has(p)||(c.add(p),d.push(p),u.push(...o.get(p)??[]));}return d},a=new Map,s=new Map;for(let l of n){if(l.kind!=="comment"||l.parentId!==void 0||l.orphaned||!l.range)continue;let d=r.get(ql(l.range))?.id;if(d===void 0)continue;let c=[l.id,...i(l.id)];for(let p of c)s.set(p,d);let u=a.get(d);u?u.push(...c):a.set(d,c);}return n.map(l=>{if(l.kind==="revision"){let d=a.get(l.id)??[];return d.length===0&&(l.replyIds??[]).length===0?l:Ie({...l,replyIds:d},Z(l))}if(l.kind==="comment"){let d=s.get(l.id);if(d===void 0){if(l.parentRevisionId===void 0)return l;let{parentRevisionId:c,...u}=l;return u}return l.parentRevisionId===d?l:{...l,parentRevisionId:d}}return l})}var Hm=256,Vm=2e3,od=/[\p{L}\p{N}_]/u;function Uo(e){let t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(let r=0;r<e.length;r+=1){let o=e[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function ad(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&od.test(r)||o!==void 0&&od.test(o))}function id(e){return typeof e=="string"&&e.length>0&&e.length<=256}function Wm(e,t,n,r={}){let o={matches:[],truncated:false};if(!id(t)||e.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?t:Uo(t),l=i?e:Uo(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),u=[],p=l.indexOf(s,d);for(;p>=0;){let R=p+s.length;if(R>c)return {matches:u,truncated:false};if(!a||ad(e,p,R)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:p,length:s.length});}p=l.indexOf(s,R);}return {matches:u,truncated:false}}var zm=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),Km=96;function Bo(e,t){return e.kind!=="textValue"&&e.namespaceUri===fa&&e.localName===t}function Gm(e){return e.kind==="textValue"&&e.value.trim()===""}function Xm(e){let t=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>Km)return;if(Se(r)){let s=Ue(r),l=yb(r);if(s&&l&&s.children.every(Gm)&&zm.has(l.type)){t.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||Bo(r,"p");for(let s of r.children)n(s,a,i+1);};return n(e,false,0),t}function Ym(e){return Yi$1(e,"rPr",{kind:"runProperties",children:[Yi$1(e,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function Jm(e){let t=e.find(r=>r.kind==="paragraph"||Bo(r,"p"));if(!t||t.kind==="textValue")return null;let n=t.children.filter(r=>r.kind!=="paragraphProperties"&&!Bo(r,"pPr"));return n.length>0?n:null}function jo(e,t){let n=Xm(t.root);if(n.length===0)return t;let r=null,o=d=>{if(d!==void 0)return r??=Ff(e),r.find(c=>c.name===d)},i=Ha(t,"paste"),a=new Set(db(t.root)),s={value:0},l=t;for(let[d,c]of n.entries()){let u=o(c.docPart),p=null;if(u){let x=u.blocks.map((k,f)=>rj(_e$1(k,i),a,`${c.control.id}:placeholder:${d}:${f}`,s));p=c.inline?Jm(x):x;}if(!p){let x=Zi$1(i,Ti$1(c.kind),Ym(i));p=c.inline?[x]:[Yi$1(i,"p",{kind:"paragraph",children:[x]})];}let R=_i$1(Te(c.control),{showingPlaceholder:true},i),m={...c.content,children:p},g=c.control.children.map(x=>x.id===c.content.id?m:x.kind!=="textValue"&&x.localName==="sdtPr"?R:x),h=Ma(l,c.control.id,g);h.ok&&(l=h.part);}return l}function sd(e,t,n){let r=t.filter(a=>a.node.localName==="tblGridChange"&&n.has(a.node.id));if(!r.length)return new Set;let o=new Map;for(let a of t){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(a.node.localName))continue;let s=a.parent;for(;s&&s.kind!=="table";)s=Ka(e,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(a.node.id),o.set(s.id,l);}let i=new Set;for(let a of r){let s=a.parent&&Ka(e,a.parent.id),l=s&&o.get(s.id);l?.some(d=>n.has(d))&&l.some(d=>!n.has(d))&&i.add(a.node.id);}return i}function qm(e,t,n,r){let o=r??e.root,i=o.kind==="textValue"?e:{...e,root:o},a=tr(i),s=n===void 0?[...ki(i,yi(i))]:[],l=s.length?[{op:"acceptAllRevisions",siteNodeIds:s,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||a.length===0)return {ops:l,result:{resolved:[],skipped:[...new Set(n??[])].map(w=>({key:w,reason:"unknown-revision"})),remaining:a.length}};let d=new Set(n??a.map(an)),c=new Map(a.map(w=>[an(w),w])),u=new Set;for(let w of d){let I=c.get(w);if(I)for(let D of Z(I))u.add(D);}let p=yi(i),R=ni(o,p,u,t);for(let w of R.selected)u.add(w);for(let w of a){let I=Z(w);I.length&&I.every(D=>u.has(D))&&d.add(an(w));}let m=Bi$1(o,p),g=new Map(p.map((w,I)=>[w.node.id,I])),h=p.map((w,I)=>I),x=w=>{for(;h[w]!==w;)h[w]=h[h[w]],w=h[w];return w},k=(w,I)=>{h[x(I)]=x(w);};for(let w of R.dependencies){let I=w.flatMap(D=>g.has(D)?[g.get(D)]:[]);for(let D of I)k(I[0],D);}let f=new Map;for(let w of a){let I=Z(w).flatMap(D=>{let K=g.get(D);return K===void 0?[]:[K]});for(let D of I)k(I[0],D);}let v=p.filter(w=>u.has(w.node.id)),O=new Set(si(e,v,t).keys()),P=new Map;for(let[w,I]of p.entries()){if(t==="reject"&&I.propertyChange&&I.parent&&u.has(I.node.id))for(let K of I.parent.children)pi(I.node.localName,K)||f.set(K.id,w);let D=t==="accept"?I.node.localName==="del"||I.node.localName==="moveFrom":I.node.localName==="ins"||I.node.localName==="moveTo";if(I.paragraphMark&&I.parent&&D&&!m.has(I.node.id)&&u.has(I.node.id)){let K=Ka(e,I.parent.id),te=K&&Ka(e,K.id),se=te&&Ka(e,te.id);if(K&&te&&se){let G=P.get(se.id);G||(G=wi$1(se.children,O),P.set(se.id,G)),G.has(te.id)&&f.set(K.id,w);}}if(u.has(I.node.id)&&ti(e,I,t)){let K=ti(e,I,t);K&&!I.refused&&f.set(K.id,w);}}for(let[w,I]of ui(e,v,t)){let D=Ja(e,w),K=g.get(I[0]);if(!(D?.kind!=="tableCell"||K===void 0))for(let te of D.children)te.localName==="tcPr"&&f.set(te.id,K);}let y=(w,I)=>{let D=g.get(w.id),K=f.get(w.id);D!==void 0&&K!==void 0&&k(K,D);let te=D??K;te!==void 0&&I!==void 0&&k(I,te);let se=te??I;if(w.kind!=="textValue")for(let G of w.children)y(G,se);};y(o);for(let w of Ai$1(o).values()){let I=w.wrappers.flatMap(D=>{let K=g.get(D.id);return K===void 0?[]:[K]});for(let D of I)k(I[0],D);}for(let w of p.some(I=>I.node.localName==="cellMerge")?vi(i):[]){let I=w.flatMap(D=>{let K=g.get(D);return K===void 0?[]:[K]});for(let D of I)k(I[0],D);}let T=new Map;for(let[w,I]of p.entries()){let D=x(w),K=T.get(D)??[];K.push(I),T.set(D,K);}let N=new Map;for(let[w,I]of T)I.some(D=>D.refused||t==="reject"&&D.propertyChange&&ri(D.node)===null)?N.set(w,"unsupported-revision"):I.some(D=>!u.has(D.node.id))&&N.set(w,"incomplete-group");for(let w of a)if(w.readOnly)for(let I of Z(w)){let D=g.get(I);D!==void 0&&N.set(x(D),"unsupported-revision");}let j=p.filter((w,I)=>u.has(w.node.id)&&!N.has(x(I))),z=false,ee=si(e,j,t);for(let[w,I]of ee){if(f.has(w))continue;let D=g.get(I[0]);D!==void 0&&(f.set(w,D),z=true);}if(z){y(o);for(let[w,I]of [...N]){let D=x(w);N.get(D)!=="unsupported-revision"&&N.set(D,I);}}let X=[],_=[],B=new Set,ie=new Set(ji$1(e,p,t));for(let w of ie){let I=Ka(e,w);for(;I;){if(ee.has(I.id)){ie.delete(w);break}I=Ka(e,I.id);}}for(let w of d){let I=c.get(w);if(!I){_.push({key:w,reason:"unknown-revision"});continue}let D={key:w,author:I.author,partName:e.name,revisionKind:I.revisionKind},K=Z(I),te;for(let se of K){let G=g.get(se);if(te=G===void 0?"incomplete-group":N.get(x(G)),te)break}if(K.length||(te="unsupported-revision"),te)_.push({key:w,reason:te,revision:D});else {K.some(se=>ie.has(se))?_.push({key:w,reason:"retained-structure",revision:D}):X.push(D);for(let se of K)ie.has(se)||B.add(se);}}let be=sd(e,p,B),$=new Set;for(let w of a){let I=Z(w);if(w.formattingKind!=="tblGridChange"&&I.length>1)for(let D of I)be.has(D)&&$.add(D);}let U=[...B].filter(w=>!R.implicit.has(w)&&!$.has(w)),Y=a.length-X.length;if(Y>0&&U.length){let w={...e,root:{...e.root}},I=Ci$1(w,t,void 0,{siteNodeIds:U,...r?{scopeRootId:r.id}:{}});if(I.ok&&I.part){let D=r?Ja(I.part,r.id):I.part.root;Y=D&&D.kind!=="textValue"?tr({...I.part,root:D}).length:0;}}return {ops:B.size?[...l,{op:t==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:U,...r?{scopeRootId:r.id}:{}}]:l,result:{resolved:X,skipped:_,remaining:Y}}}function Ho(e){return e.kind!=="textValue"}function nr(e,t){for(let n of e.children)if(Ho(n)&&n.localName===t)return n;return null}function Qm(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(Ho(r)){if(r.localName===t)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var md=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function _t(e,t,n){let r=nr(e,t),i=(r?nr(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&md.test(i)?i:null}var ld=new WeakMap;function Zm(e){let t=e?ld.get(e):void 0;if(t)return t;let n=e?Qm(e,"fontScheme"):null;if(!n)return ud;let r=Object.freeze({major:_t(n,"majorFont","latin"),minor:_t(n,"minorFont","latin"),majorEastAsia:_t(n,"majorFont","ea"),minorEastAsia:_t(n,"minorFont","ea"),majorBidi:_t(n,"majorFont","cs"),minorBidi:_t(n,"minorFont","cs"),...ru(n)});return e&&ld.set(e,r),r}var dd=new WeakMap,ud=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null});function Vo(e,t=null){let n=e?Zm(e):ud,r=t?nr(t,"themeFontLang"):null;if(!r||!t)return n;let o=dd.get(t);o||dd.set(t,o=new WeakMap);let i=o.get(n);if(i)return i;let a=R=>r.attributes.find(m=>m.localName===R)?.value,s=cd(a("val")),l=cd(a("bidi")),d=a("eastAsia"),c=rr(d),u=(R,m,g)=>m&&(R?n.majorSupplemental:n.minorSupplemental)?.[m]||g||null,p=Object.freeze({major:u(true,s,n.major),minor:u(false,s,n.minor),majorEastAsia:u(true,c,n.majorEastAsia),minorEastAsia:u(false,c,n.minorEastAsia),majorBidi:u(true,l,n.majorBidi),minorBidi:u(false,l,n.minorBidi),...d===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,p),p}var eu=new Map([["minorAscii",e=>e.minor],["minorHAnsi",e=>e.minor],["majorAscii",e=>e.major],["majorHAnsi",e=>e.major],["minorEastAsia",e=>e.minorEastAsia??null],["majorEastAsia",e=>e.majorEastAsia??null],["minorBidi",e=>e.minorBidi??null],["majorBidi",e=>e.majorBidi??null]]);function fk(e,t,n){if(e===void 0)return null;let r=eu.get(e)?.(t)??null;if(r!==null)return r;let o=rr(n);return o?(e==="majorEastAsia"?t.majorSupplemental:e==="minorEastAsia"?t.minorSupplemental:void 0)?.[o]??null:null}function rr(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[0]==="ja"?"Jpan":t[0]==="ko"?"Hang":t[0]!=="zh"?null:t.includes("hant")?"Hant":t.includes("hans")?"Hans":t.some(n=>["tw","hk","mo"].includes(n))?"Hant":"Hans"}var tu=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function cd(e){if(!e||e.length>85)return null;let t=e.toLowerCase().split("-");return t[1]&&/^[a-z]{4}$/.test(t[1])?t[1][0].toUpperCase()+t[1].slice(1):rr(e)??tu.get(t[0])??null}var nu=new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]);function gk(e){return nu.get(rr(e)??"")??null}function ru(e){let t={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of nr(e,n)?.children??[]){if(!Ho(i)||i.localName!=="font")continue;let a=i.attributes.find(l=>l.localName==="script")?.value,s=i.attributes.find(l=>l.localName==="typeface")?.value;a&&/^[A-Z][a-z]{3}$/.test(a)&&s&&md.test(s)&&(o[a]=s);}Object.keys(o).length&&(t[r]=Object.freeze(o));}return t}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",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Wo(e,t,n,r){let o=(e.relationships.get(t)??[]).find(i=>i.type===n);if(o){let i=E(o);if(i.mode==="Internal"&&i.target.ok){let a=e.parts.get(i.target.partName);if(a)return a}}return e.parts.get(r)}function Sk(e){let t=Ld$1(e);if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let n=t.package.parts.get(t.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:t.package.mainDocumentPart};let r=new nn(t.package,jo(t.package,gb(n)));return {ok:true,view:ou(r)}}function ou(e){let t=()=>e.currentPackage(),n=()=>e.bodyStore().part,r=(d,c)=>Wo(t(),t().mainDocumentPart,d,c)?.root??null,o=Object.freeze(Vo(null)),i=null,a=oh,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 d=t();return i!==d&&(o=Object.freeze(Vo(r(pt.theme,"/word/theme/theme1.xml"),r(pt.settings,"/word/settings.xml"))),i=d),o},documentProperties(){let d=t();if(s!==d){let c=Wo(d,"/",pt.coreProperties,"/docProps/core.xml"),u=Wo(d,"/",pt.extendedProperties,"/docProps/app.xml");a=ph(c?.root??null,u?.root??null),s=d;}return a},headerFooterPartsBySection:()=>ge(t()),headerFooterResolutionBySection:()=>fe(t()),relationshipTarget:d=>Kf(t(),n().name,d)})}
|
|
5
|
-
export{am as $,Gt as A,Bm as Aa,Ur as B,rd as Ba,Sd as C,Hm as Ca,Br as D,Vm as Da,jr as E,Uo as Ea,Hr as F,ad as Fa,Vr as G,id as Ga,Ed as H,Wm as Ha,Mi as I,jo as Ia,Xt as J,qm as Ja,Yd as K,Sk as Ka,lo as L,ou as La,ps as M,co as N,dt as O,ll as P,nn as Q,cl as R,ml as S,Ro as T,Jg as U,vo as V,Co as W,Mo as X,nm as Y,rm as Z,om as _,Vo as a,im as aa,fk as b,sm as ba,gk as c,Sl as ca,fd as d,wl as da,Si as e,Do as ea,Mn as f,Ao as fa,it as g,dm as ga,Dn as h,mm as ha,An as i,um as ia,ye as j,pm as ja,xd as k,fm as ka,st as l,Z as la,zt as m,an as ma,_n as n,_o as na,Kt as o,Dl as oa,Fn as p,Dt as pa,Ar as q,Pm as qa,_r as r,Uh as ra,Fr as s,Bh as sa,vd as t,_l as ta,Od as u,Fl as ua,$r as v,Zn as va,Ni as w,py as wa,Id as x,tr as xa,Lr as y,nd as ya,bd as z,Um as za};
|
package/dist/chunk-XWXJB4J7.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {Be,pe,ke,Ce,qe,se,Ae,De}from'./chunk-JXL25DRU.js';function V(e){return e.kind!=="textValue"}function O(e,t){for(let r of e.children)if(V(r)&&r.localName===t)return r}function A(e,t){return e.attributes.find(r=>r.localName===t)?.value}function z(e){let t=O(e,"pPr"),r=t?O(t,"outlineLvl"):void 0;if(r){let o=A(r,"val");return o!==void 0&&/^[0-8]$/.test(o)?Number(o):null}let n=O(e,"name"),l=n?/^heading\s+([1-9])$/i.exec(A(n,"val")?.trim()??""):null;return l?Number(l[1])-1:null}function M(e,t=0,r=e.length,n){let l=new Set,o=new Map,s=new Map,a=n?[n]:[];n&&l.add(n);for(let d=t;d<r;d+=1){let i=e[d].node;if(pe(i,"begin")){a.push(i.id);continue}if(pe(i,"separate")){let u=a[a.length-1];u&&(l.add(u),o.set(i.id,u));continue}if(pe(i,"end")){let u=a.pop();u&&(l.add(u),s.set(i.id,u));}}return {activeBegins:l,separateBegin:o,endBegin:s}}function b(e,t,r){if(pe(r,"begin"))return t.activeBegins.has(r.id)&&e.push({beginId:r.id,separated:false}),true;if(pe(r,"separate")){let n=t.separateBegin.get(r.id),l=e[e.length-1];return n&&l?.beginId===n&&(l.separated=true),true}if(pe(r,"end")){let n=t.endBegin.get(r.id),l=e[e.length-1];return n&&l?.beginId===n&&e.pop(),true}return false}function F(e){for(let t of e)if(!t.separated)return false;return true}function q(e,t){let r=[];Be(e,r,t);let n=M(r),l=[];return {consume:o=>b(l,n,o),visible:()=>F(l)}}var _=4096,j=Ce*16;function C(){return {out:[],runs:[],length:0}}function L(e,t,r,n){if(t.length===0||r===n)return;let l=e.runs[e.runs.length-1];if(l?.runId===t&&l.end===r){e.runs[e.runs.length-1]={runId:t,start:l.start,end:n};return}e.runs.push({runId:t,start:r,end:n});}function N(e,t,r,n){if(t.length>n.left)return false;if(n.left-=t.length,t.length>0){let l=e.length;e.out.push(t),e.length+=t.length,L(e,r,l,e.length);}return true}function D(e,t){let r=e.length;t.text.length>0&&e.out.push(t.text),e.length+=t.text.length;for(let n of t.runs)L(e,n.runId,r+n.start,r+n.end);}function w(e){return {text:e.out.join(""),runs:e.runs}}var U=Object.freeze({text:"",runs:[]});function I(){return {text:ke,runs:[]}}function X(e,t,r,n){let l=[];if(!Be(e,l,r))return null;let o=l.reverse(),s=C();for(;o.length>0;){let a=o.pop();if(t==="original"&&a.hiddenInOriginal)continue;if(se(a.node)){let i=[];if(!Be(a.node,i,r))return null;for(let u=i.length-1;u>=0;u-=1)o.push(i[u]);continue}if(qe(a.node))continue;let d=Ae(a.node);if(!N(s,d,a.runId,n))return null}return w(s)}function H(e,t,r,n,l){let o=C(),s=[],a=M(e);for(let d of e){let i=d.node;if(b(s,a,i)||qe(i)||!F(s)||t==="original"&&d.hiddenInOriginal)continue;if(se(i)){let p=l>=De?X(i,t,r,n):v(i,t,r,n,l+1);if(p===null)return null;D(o,p);continue}let u=Ae(i);if(!N(o,u,d.runId,n))return null}return w(o)}function v(e,t,r,n,l){let o=[];return Be(e,o,r)?H(o,t,r,n,l):null}function $(e,t,r){let n=t.node;if(e.owned.has(n.id)&&(e.nodesLeft-=1,e.nodesLeft<0&&(e.overflow=true)),n.id===e.endId)return true;if(n.id===e.span.node.id||b(e.states,e.markers,n)||e.overflow||qe(n)||se(n)||!e.owned.has(n.id)||!F(e.states)||r==="original"&&t.hiddenInOriginal)return false;let l=Ae(n);return N(e.result,l,t.runId,e.chars)||(e.overflow=true),false}function W(e,t,r="allMarkup"){let n=new Map,l=new Map,o=new Map;for(let i of t)i.kind==="complex"?l.set(i.node.id,i):o.set(i.node.id,i);let s=[];Be(e,s);let a=new Map;for(let i=0;i<s.length;i+=1)a.set(s[i].node.id,i);let d=null;for(let i=0;i<s.length;i+=1){let u=s[i],p=o.get(u.node.id);if(p)if(d!==null&&!F(d.states))n.set(p.node.id,U);else {let f={left:_},S={left:j},g=v(p.node,r,f,S,0);n.set(p.node.id,g??I());}if(d===null){let f=l.get(u.node.id);if(!f)continue;let S=new Set(f.removeNodeIds),g=-1;for(let k=f.removeNodeIds.length-1;k>=0;k-=1){let R=a.get(f.removeNodeIds[k]);if(!(R===void 0||R<=i)&&pe(s[R].node,"end")){g=R;break}}let P=s[g];if(!P){n.set(f.node.id,I());continue}d={span:f,owned:S,states:[{beginId:f.node.id,separated:false}],markers:M(s,i+1,g,f.node.id),endId:P.node.id,result:C(),chars:{left:j},nodesLeft:_,overflow:false};}$(d,u,r)&&(n.set(d.span.node.id,d.overflow?I():w(d.result)),d=null);}return d!==null&&n.set(d.span.node.id,I()),n}export{q as a,_ as b,W as c,z as d};
|