@docx-editor.dev/core 2.21.0 → 2.21.1
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 +31 -31
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +10 -10
- 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-25OQBAKA.js +2 -0
- package/dist/chunk-3B3DQMSL.js +11 -0
- package/dist/chunk-3P3DNJYM.js +5 -0
- package/dist/chunk-3PA64KPK.js +5 -0
- package/dist/{chunk-4EHMMSFR.cjs → chunk-4TYA4RLP.cjs} +1 -1
- package/dist/chunk-7N77EN2Z.cjs +2 -0
- package/dist/{chunk-TE43S3LX.cjs → chunk-AGWWNVIJ.cjs} +1 -1
- package/dist/{chunk-Q2B6HX3R.js → chunk-BF2TOG2V.js} +1 -1
- package/dist/chunk-DFTVN25X.cjs +5 -0
- package/dist/{chunk-BQXF2PFF.js → chunk-DGONGMAV.js} +1 -1
- package/dist/{chunk-BDAY2ETZ.js → chunk-DZYKU2HG.js} +1 -1
- package/dist/chunk-E5OUYRNM.cjs +5 -0
- package/dist/{chunk-S35UK656.cjs → chunk-F4H3LC6M.cjs} +1 -1
- package/dist/{chunk-X5QNSISI.js → chunk-FPDIJ4RF.js} +1 -1
- package/dist/chunk-IUTTOBQW.cjs +20 -0
- package/dist/{chunk-WQFNWLNY.cjs → chunk-IYCXQAFT.cjs} +2 -2
- package/dist/chunk-JL3SI5SZ.js +18 -0
- package/dist/chunk-OFWUHH52.js +20 -0
- package/dist/chunk-OKY6JRJL.js +4 -0
- package/dist/{chunk-XZY4Q6PJ.cjs → chunk-P24FHMQW.cjs} +1 -1
- package/dist/chunk-QBKAOSVF.cjs +18 -0
- package/dist/{chunk-PYXMAUNR.cjs → chunk-RA2TDTEQ.cjs} +1 -1
- package/dist/{chunk-Z2ETEZRU.cjs → chunk-T5B4NMKF.cjs} +1 -1
- package/dist/{chunk-VUNFWXHF.js → chunk-U5GUJKTS.js} +1 -1
- package/dist/chunk-XRYSPKKC.js +1 -0
- package/dist/chunk-ZZRCVDQU.cjs +11 -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-05qS32px.d.ts → custom-node-writes-CncR6KfC.d.ts} +2 -2
- package/dist/{document-protection-Cr59VKLO.d.ts → document-protection-DM6mA8Rf.d.ts} +1 -1
- package/dist/{editor-BsLSz_7y.d.ts → editor-BRh7GuZF.d.ts} +10 -6
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.ts +25 -25
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +12 -12
- package/dist/export.js +1 -1
- package/dist/{font-resolver-CzwdBJDE.d.ts → font-resolver-DwuQYj3P.d.ts} +1 -1
- package/dist/{headless-document-view-B7nAiR7P.d.ts → headless-document-view-C3fc_jV0.d.ts} +2 -2
- package/dist/{image-resources-C4ilLzog.d.ts → image-resources-DxF-SN_8.d.ts} +1 -1
- package/dist/{index-zkvqBQ9o.d.ts → index-3pNnG4z4.d.ts} +19 -18
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-BJKVTI6i.d.ts → layout-shaping-_GGjhhVc.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +19 -17
- package/dist/layout.js +1 -1
- package/dist/{note-properties-MNztEj5s.d.ts → note-properties-CjT31AuP.d.ts} +1 -1
- package/dist/{omml-equation-CbnW9yXd.d.ts → omml-equation-Bk3OP1fv.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-Co_r0SZQ.d.ts → protocol-CrbTIW2Z.d.ts} +2 -2
- package/dist/{review-paragraph-order-EFaU7TqH.d.ts → review-paragraph-order-D3KZohIL.d.ts} +1 -1
- package/dist/{revision-projection-DEIvpxiq.d.ts → revision-projection-kVd7p6Wd.d.ts} +1 -1
- package/dist/{semantic-cell-selection-DXmfnDCw.d.ts → semantic-cell-selection-CkSsZHDL.d.ts} +6 -4
- package/dist/{semantic-interaction-BLu3M6Nn.d.ts → semantic-interaction-Z2Xa68U5.d.ts} +1 -1
- package/dist/{semantic-paint-CPsihA6k.d.ts → semantic-paint-BHKprI9P.d.ts} +2 -2
- package/dist/{semantic-records-CqD0b5Ex.d.ts → semantic-records-StH-AnHK.d.ts} +11 -8
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +19 -25
- package/dist/store.js +1 -1
- package/dist/{tree-package-fragment-CwJDixNs.d.ts → tree-package-fragment-CpEV1gl3.d.ts} +2 -2
- package/dist/{tree-session-contract-D9RRWE0C.d.ts → tree-session-contract-CTT9nM7Z.d.ts} +10 -5
- package/dist/{types-barrel-DLB11iSY.d.ts → types-barrel-PwcfEkaX.d.ts} +8 -4
- package/package.json +2 -2
- package/dist/chunk-44LQJIKH.cjs +0 -20
- package/dist/chunk-AFG7Q622.cjs +0 -2
- package/dist/chunk-AYMSP25Q.js +0 -4
- package/dist/chunk-B4KZSKF7.cjs +0 -5
- package/dist/chunk-BNZF6DYC.cjs +0 -18
- package/dist/chunk-GIHKVXEO.js +0 -2
- package/dist/chunk-ITNK6C5M.cjs +0 -3
- package/dist/chunk-MP3K4LC5.js +0 -1
- package/dist/chunk-MXOO7KRI.cjs +0 -11
- package/dist/chunk-NG6IQ4SI.js +0 -11
- package/dist/chunk-Q5JPPUNR.js +0 -5
- package/dist/chunk-VH2DLEZK.js +0 -20
- package/dist/chunk-WZX4UGRQ.js +0 -3
- package/dist/chunk-XS4FOHH6.js +0 -18
package/dist/chunk-WZX4UGRQ.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {c,d,lg,kg,vg,p,f,k,j,i,Xe as Xe$1,Ci as Ci$1,Wf,ic as ic$1,Sa,jc,N,x,Ra,Bi as Bi$1,Ie,pg,Ja,gc as gc$1,xa,da,pc,oc as oc$1,nc as nc$1,ec as ec$1,Ca,Da,Nb,b,Lf,Wh,Xh as Xh$1,va,qc as qc$1,Mi as Mi$1,og,Fg,mg,ng,Ef,Ff,Ki as Ki$1,E,Lb,O,Le,Ob,Pb,Mb,Hb,La,qg,rg,ug,tg,Dg,Eg,Lc as Lc$1,_g,Vg,dh,Zg,Yg,Tg,gh,Ug,fh,$g,Xg,la,na,ka,fe,Fe,He as He$1,J as J$1,Ha,Se,zg as zg$1,Ag,Fa,Ib,zi as zi$1,Ne as Ne$1,gi,ai,fi,hi,Ge as Ge$1,Ka,Ih,ig,Ee,Ia,Eh,Lh,Kh,Gh,Af,Pd as Pd$1,Qd as Qd$1,Lg,Kg,w,qa,zf,a,Yb,mc as mc$1,ei,Yh as Yh$1,_h,qh,wh,Vh,xg,vf,ga,Ai as Ai$1,wi as wi$1,Bg,nf,Ma,_b,Vb,Xb,$b,bc as bc$1,cc as cc$1,Ya,sg,Sg,Jb,Eb,Xd as Xd$1,de,ub,Ub,Fh,yi,mb,eb,fb,hb,F,ta,g,ua,u,gg,Jc as Jc$1,di,ci,Ue,cg,dg,Qb,ib,sa,P,We as We$1,X,xi,Bf,si,ti,ea,Sb,Tb,Rb}from'./chunk-NG6IQ4SI.js';import {strFromU8,strToU8}from'fflate';var md=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],pd=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,ud=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Si(e){return pd.test(e)||ud.test(e)}function wn(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 fd=/^(\d+)\.(\d+)\.(\d+)$/;function ot(e){let t=fd.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 En(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 Tn(e,t){let n=ot(e),r=t.trim();if(r==="*")return true;if(r.startsWith("^")){let o=ot(r.slice(1));return En(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=ot(a.slice(s.length)),d=En(n,l);s===">="?i=i&&d>=0:i=i&&d<0;}return i}return En(n,ot(r))===0}var pe=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Lr=(e,t)=>`${e}:${t}`;function gd(e,t={}){let n=new Map;for(let d of e){if(wn(d.id,"extension"),Ni(d.version,d.id),n.has(d.id))throw new pe("duplicate-extension",`duplicate extension id ${d.id}`,[d.id]);n.set(d.id,d);for(let c of d.contributions)wn(c.id,c.kind),Ni(c.version,`${d.id} \u2192 ${c.id}`),c.replaces&&xd(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 pe("missing-dependency",`${d.id} requires missing extension ${c}`,[d.id,c]);for(let c of d.conflicts??[])if(n.has(c)){let m=[d.id,c].sort();throw new pe("conflict",`extensions ${m[0]} and ${m[1]} conflict`,m)}}yd(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 pe("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 m=Lr(c.kind,c.id);if(c.replaces){let p=Lr(c.kind,c.replaces.targetId),g=a.get(p)??[];g.push({ext:d.id,c}),a.set(p,g);continue}if(i.has(m)){let p=[o.get(m),d.id].sort();throw new pe("id-collision",`${c.kind} id ${c.id} registered by both ${p[0]} and ${p[1]}`,p)}i.set(m,c),o.set(m,d.id);}let s=new Map(i);for(let[d,c]of a){let m=i.get(d);if(!m){let u=c[0];throw new pe("replacement-target-missing",`${u.ext} replaces missing target ${u.c.replaces.targetId}`,[u.ext,u.c.replaces.targetId])}let p=m.replaceable??{kind:"none"};for(let{ext:u,c:h}of c){if(!Tn(m.version,h.replaces.targetRange))throw new pe("replacement-version-mismatch",`${u} replaces ${h.replaces.targetId}@${m.version} outside range ${h.replaces.targetRange}`,[u,h.replaces.targetId]);if(p.kind==="none")throw new pe("unauthorized-replacement",`${h.replaces.targetId} does not authorize replacement (attempted by ${u})`,[u,h.replaces.targetId])}let g=hd(m,c);s.set(d,g);}return {extensions:n,contributions:s,get:(d,c)=>s.get(Lr(d,c))}}function hd(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 pe("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 pe("ambiguous-replacement",`multiple replacers of ${e.id}: ${r.join(", ")}`,r)}function yd(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 m=i.indexOf(d),p=[...i.slice(m),d];throw new pe("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 Ni(e,t){try{ot(e);}catch{throw new pe("invalid-version",`invalid version ${JSON.stringify(e)} in ${t}`,[t])}}function xd(e,t){try{Tn("0.0.0",e);}catch{throw new pe("invalid-version",`invalid version range ${JSON.stringify(e)} in ${t}`,[t])}}var at=class extends Error{constructor(t){super(t),this.name="BudgetError";}},Wt=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 at(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new at(`${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 at(`${this.label}: ${t.length} cleanup error(s); first: ${String(t[0])}`)}assertLive(){if(this.disposed)throw new at(`${this.label}: budget already released`)}};var Cn=class extends Error{constructor(n,r){super(r?`cancelled: ${r}`:"cancelled");this.derivedOnly=n;this.name="CancellationError";}derivedOnly},zt=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 Cn(t.derivedOnly,t._reason)}}}};var Mn=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},$r=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 Mn(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)}},Ur=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}},Br=class{constructor(t="id"){this.prefix=t;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function kd(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 Wt(`op:${o}`,r),cancellation:new zt};return Object.freeze(i)}function Pd(e){e.budget.dispose();}var Hr=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"}}),wi=Object.keys(Hr);function Rd(e,t){return new p(`${Hr[t].phase}:${t}`,e[t])}var jr=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 Od(){for(let e of wi){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 Kt(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(m=>!t.has(m)).sort().map(m=>{r.push(m);try{return `${JSON.stringify(m)}:${o(l[m])}`}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 Vr(e,t){let n=Kt(e,t),r=0xcbf29ce484222325n,o=0x100000001b3n,i=0xffffffffffffffffn;for(let a=0;a<n.length;a++)r^=BigInt(n.charCodeAt(a)),r=r*o&i;return r.toString(16).padStart(16,"0")}var De="dev.docx-editor.core.comparator",Wr={authoredState:{id:`${De}.authored-state`,mode:"canonical-exact",ephemera:["revision","provenance","producedAt","commitId"],note:"canonical normalized authored records; ephemera excluded"},anchor:{id:`${De}.anchor`,mode:"exact",ephemera:[],note:"internal anchor identity/affinity compares exactly"},yjsStateVector:{id:`${De}.yjs-state-vector`,mode:"sync-optimization-only",ephemera:[],note:"exchange optimization only; never proves update or delete-set coverage"},shapedRun:{id:`${De}.shaped-run`,mode:"exact",ephemera:[],note:"glyph ids, clusters, and fixed-point advances compare exactly"},paginationFingerprint:{id:`${De}.pagination-fingerprint`,mode:"exact",ephemera:[],note:"page/column boundaries, break causes, fixed-point geometry compare exactly"},semanticTree:{id:`${De}.semantic-tree`,mode:"exact",ephemera:[],note:"reading order, roles, headings, alt text compare exactly"},hitTest:{id:`${De}.hit-test`,mode:"exact",ephemera:[],note:"resolved hit target and cluster affinity compare exactly"},pdfSemantics:{id:`${De}.pdf-semantics`,mode:"canonical-exact",ephemera:["objectNumber","producer","creationDate","modDate","subsetTag"],note:"canonical semantic PDF objects; container ephemera excluded"},rasterCheckpoint:{id:`${De}.raster-checkpoint`,mode:"tolerance",ephemera:[],note:"documented unavoidable raster comparison; explicit tolerance only"},benchmarkEvidence:{id:`${De}.benchmark-evidence`,mode:"sync-optimization-only",ephemera:[],note:"diagnostic evidence, not an equivalence basis"}};function zr(e,t,n,r={}){let o=Wr[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=Kt(t,i),s=Kt(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function Kr(e,t){let n=Wr[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 Vr(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}$/,vd=/^[0-9a-f]*$/;function Gr(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&&Id(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}`),vd.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 Id(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 bd(e,t){let n=Gr(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 {zr("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 Kr("authoredState",e)}var it="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Sd="http://schemas.openxmlformats.org/package/2006/relationships",Nd="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",Xr="application/vnd.openxmlformats-package.relationships+xml",Yr=`${it}/styles`,qr=`${it}/numbering`,Bi=`${it}/footnotes`,ji=`${it}/endnotes`,Hi=`${it}/officeDocument`,wd=`${it}/theme`;function Me(e){return e.kind!=="textValue"}function Ai(e,t){return {...e,children:t}}function Ge(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)Ge(n,t);}var Ed=new Set(["pStyle","rStyle","tblStyle"]);function Jr(e,t){for(let n of e)Ge(n,r=>{if(r.kind!=="textValue"&&Ed.has(r.localName)&&r.namespaceUri===da){let o=Ie(r,"val");o&&t.add(o);}});}function Qr(e,t){for(let n of e)Ge(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===da){let o=Ie(r,"val");o&&t.add(o);}});}function Dn(e,t){for(let n of e)Ge(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===it&&o.value.length>0&&t.add(o.value);});}function Ne(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)Ge(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",d=Ie(s,"id");if(d===void 0)return;let c=Ne(d);n[l].has(c)||(n[l].add(c),r.push({kind:l,id:c}));});};for(o(e);r.length>0;){let i=r.pop(),a=t(i.kind,i.id);a!==null&&o([a]);}return n}function Zr(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===da&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?t:n,d=Ie(i,"id");if(i.kind!=="noteReference"||d===void 0||!l.has(Ne(d))){o=true;continue}}let s=Zr(i,t,n);s!==i&&(o=true),r.push(s);}return o?{...e,children:r}:e}function Td(e,t){for(let n of ic$1(e,t)){if(n.type!==Yr||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 ic$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=Td(e,t),r=new Map,o=[],i=null;if(n&&Me(n.root))for(let a of n.root.children){if(!Me(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===da){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==da)continue;let s=Ie(a,"styleId");s&&r.set(s,a),(Ie(a,"default")==="1"||Ie(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var Cd=new Set(["basedOn","link","next"]);function zi(e,t){let n=new Set,r=[...t];for(let a of e.defaults){let s=Ie(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=e.byId.get(a);if(s){o.push(s);for(let l of s.children)if(Me(l)&&Cd.has(l.localName)&&l.namespaceUri===da){let d=Ie(l,"val");d&&r.push(d);}}}if(!e.part||!Me(e.part.root))return o;let i=new Map;return e.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function eo(e,t,n){let r=Vi(e,t,qr)??e.parts.get("/word/numbering.xml")??null;if(!r||!Me(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!Me(s)||s.localName!=="num"||s.namespaceUri!==da)continue;let l=Ie(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let d of s.children)if(Me(d)&&d.localName==="abstractNumId"){let c=Ie(d,"val");c&&i.add(c);}}}let a=[];for(let s of r.root.children){if(!Me(s)||s.localName!=="abstractNum"||s.namespaceUri!==da)continue;let l=Ie(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var An={latin:null,eastAsia:null,cs:null};function Ki(e,t){let n=Vi(e,t,wd);if(!n)return {major:An,minor:An};let r={major:{...An},minor:{...An}};return Ge(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==Nd||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!Me(a))continue;let s=Ie(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 Md(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 Ad=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],Di=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Xe(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===da){let i=[],a=new Map;for(let s of e.attributes){let l=Ad.find(([d])=>d===s.localName);if(l&&s.namespaceUri===da){let d=Md(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:da,localName:s,prefix:"w",value:l});n=i;}else e.attributes.some(i=>Di.has(i.localName)&&i.namespaceUri===da&&e.attributes.some(a=>a.localName==="val"))&&(n=e.attributes.filter(i=>!(Di.has(i.localName)&&i.namespaceUri===da)));let r=e.children.map(i=>Xe(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&&Me(r)?Ai(r,t):{id:"fragment#body",kind:"body",namespaceUri:da,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return Ai(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:da,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:da,localName:"document",prefix:"w",namespaceBindings:Me(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function Gt(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="${Sd}">${t}</Relationships>`}function Yi(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function qi(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Fn(e,t){return {...e,children:t}}function Ln(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===da}function Xt(e,t=[]){if(e.kind==="textValue")return t;e.kind==="paragraph"&&t.push(e.id);for(let n of e.children)Xt(n,t);return t}function Ji(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=Ji(n,t);if(r)return r}return null}function Dd(e){let t=(n,r)=>{if(n.kind==="textValue")return n;if(r&&Ln(n,"vMerge")){if(Ie(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===da)),{kind:"wmlVal",namespaceUri:da,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||Ln(n,"tc");return Fn(n,n.children.map(i=>t(i,o)))};return Fn(e,e.children.map(n=>t(n,false)))}function Qi(e,t){if(!(e.kind==="textValue"||e.kind==="table")){if(Ln(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(Ln(e,"tr")){if(!t.has(e))return {node:null,hadRows:true,keptRows:false};let a=n.value?Dd(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?Fn(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(Xt(e).filter(l=>t.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let d=Xt(l);return d.length>0&&d.every(c=>t.covered.has(c))}),a=new Set(i.flatMap(l=>Xt(l)));if(i.length>0&&o.size===a.size&&[...o].every(l=>a.has(l))){let l={value:true},d=new Set(i),c=[];for(let m of e.children){let p=Zi(m,d,l);p.node!==null&&c.push(p.node);}n.push(Fn(e,c));return}for(let l of Xt(e)){if(!t.inRange.has(l))continue;let d=Ji(e,l);d&&n.push(d);}}var _d="http://schemas.openxmlformats.org/package/2006/content-types",Fd=5e4;function je(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 to(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=to(n,t);if(r)return r}return null}function Be(e,t){return {...e,children:t}}function Ld(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===da}function $d(e){if(e.root.kind==="document"){let t=e.root.children.find(n=>n.kind==="body");return t&&je(t)?t:null}return je(e.root)?e.root:null}function Ud(e,t){return ts(e).some(n=>t.has(n))}function no(e,t,n){for(let r of e)if(je(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&&je(o)&&no(o.children,t,n);continue}Ud(r,t.inRange)&&no(r.children,t,n);}}var Bd=new Set(["commentRangeStart","commentRangeEnd"]);function jd(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}function ro(e){if(e.kind==="textValue")return e;if(Bd.has(e.localName)&&e.namespaceUri===da||jd(e)||Ld(e,"sectPr"))return null;let t=false,n=[];for(let r of e.children){let o=ro(r);if(o===null){t=true;continue}o!==r&&(t=true),n.push(o);}return t?Be(e,n):e}function Hd(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=Ie(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 m of l.children){let p=s(m);if(p===null){c=true;continue}p!==m&&(c=true),d.push(p);}return c?Be(l,d):l};return e.map(l=>s(l)).filter(l=>l!==null)}function oo(e){if(e.kind==="textValue")return e.value.length;let t=0;for(let n of e.children)t+=oo(n);return t}function Vd(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=oo(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&&je(a)?n.push(...a.children):n.push(r);}return Be(e,n)}function Wd(e){let t=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=Ie(a,"id");s!==void 0&&t.add(s);}if(a.kind==="bookmarkEnd"){let s=Ie(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=Ie(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?Be(a,s):a};return e.map(a=>i(a)??a)}function zd(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 R of [o,i]){let M=to(r.root,R);if(!M)return {ok:false,reason:"empty-range"};for(let L of M.children)L.kind==="contentControl"&&a.set(L.id,oo(L));}let s=r,l=to(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let d=Xe$1(l);if(t.endOffset<d){let R=Ci$1(s,{op:"deleteText",paragraphId:i,start:t.endOffset,end:d},{deferValidation:true});if(!R.ok)return {ok:false,reason:"trim-refused"};s=R.part;}if(t.startOffset>0){let R=Ci$1(s,{op:"deleteText",paragraphId:o,start:0,end:t.startOffset},{deferValidation:true});if(!R.ok)return {ok:false,reason:"trim-refused"};s=R.part;}let c=$d(s);if(!c)return {ok:false,reason:"unknown-part"};let m={inRange:new Set(t.paragraphIds),covered:new Set(t.coveredParagraphIds),fullBlocks:new Set(t.fullyCoveredBlockIds)},p=[];if(no(c.children,m,p),p.length===0)return {ok:false,reason:"empty-range"};if(p.length>Fd)return {ok:false,reason:"resource-limit"};let g=p.map(R=>ro(R)).filter(R=>R!==null).map(R=>R.kind!=="paragraph"||R.id!==o&&R.id!==i?R:Vd(R,a));g=[...Hd(g)],g=[...Wd(g)];let u=Wf(e,"footnote"),h=Wf(e,"endnote"),f=(R,M)=>je(R)&&R.namespaceUri===da&&R.localName===M,y=_n(g,(R,M)=>{let L=R==="footnote"?u:h;if(!L||!je(L.root))return null;for(let K of L.root.children){if(!f(K,R))continue;let Z=Ie(K,"id");if(Z!==void 0&&Ne(Z)===M)return K}return null}),k=y.footnote,I=y.endnote;k.size===0&&(u=null),I.size===0&&(h=null);let O=(R,M,L)=>{if(!R||!je(R.root))return [];let K=[];for(let Z of R.root.children){if(!f(Z,M))continue;let W=Ie(Z,"id"),Je=Ie(Z,"type");if(Je==="separator"||Je==="continuationSeparator"){K.push(Z);continue}if(W!==void 0&&L.has(Ne(W))){let yt=ro(Z);yt&&je(yt)&&K.push(yt);}}return K},v=O(u,"footnote",k),D=O(h,"endnote",I),U=[...v,...D],Y=[...g,...U],S=new Set;Jr(Y,S);let b=Wi(e,e.mainDocumentPart),A=new Set;Qr(Y,A);let _=[],H=eo(e,e.mainDocumentPart,A);for(;;){let R=S.size,M=A.size;_=zi(b,S),Qr(_,A),H=eo(e,e.mainDocumentPart,A);let L=[...H.nums,...H.abstracts];Jr(L,S);for(let K of L)Ge(K,Z=>{if(Z.kind!=="textValue"&&(Z.localName==="styleLink"||Z.localName==="numStyleLink")&&Z.namespaceUri===da){let W=Ie(Z,"val");W&&S.add(W);}});if(S.size===R&&A.size===M)break}let G=Ki(e,e.mainDocumentPart),te=_.map(R=>Xe(R,G)),de=b.docDefaults?Xe(b.docDefaults,G):null;g=g.map(R=>Xe(R,G));let F=v.map(R=>Xe(R,G)),$=D.map(R=>Xe(R,G)),z=new Set;Dn(g,z);let re=ic$1(e,r.name).filter(R=>z.has(R.id)),ae=new Map,Oe=0,qe=R=>{let M=new Set;for(let L of R){if(L.targetMode==="External")continue;let K=w(L.ownerPart,L.rawTarget);if(!K.ok){M.add(L.id);continue}if((jc(e,K.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let W=e.partBytes.get(K.partName)??e.partBytes.get(K.partName.replace(/^\//,""));W?(ae.set(K.partName,W),Oe+=W.byteLength):M.add(L.id);continue}M.add(L.id);}return M},ve=qe(re),_e=(R,M)=>{if(R.kind==="textValue")return R;if(R.kind==="drawing"||R.namespaceUri===da&&R.localName==="pict"){let Z=new Set;Dn([R],Z);for(let W of Z)if(M.has(W))return null;return R}let L=[],K=false;for(let Z of R.children){let W=_e(Z,M);if(W===null){K=true;continue}W!==Z&&(K=true),L.push(W);}return K?Be(R,L):R};ve.size>0&&(g=g.map(R=>_e(R,ve)).filter(R=>R!==null));let X=re.filter(R=>!ve.has(R.id)),Fe=(R,M)=>{if(!R)return [];let L=new Set;Dn(M,L);let K=ic$1(e,R.name).filter(W=>L.has(W.id)),Z=qe(K);if(Z.size>0)for(let W=0;W<M.length;W+=1){let Je=_e(M[W],Z);Je!==null&&(M[W]=Je);}return K.filter(W=>!Z.has(W.id))},ce=Fe(u,F),on=Fe(h,$),Ie$1=new Map,gt=[],Dt=new Map,ht=(R,M,L)=>{let K=Gi(R,M,L);Ie$1.set(R.slice(1),Sa(qa(K))),gt.push([R,M]),Dt.set(R,K);},_t=(R,M)=>R.map(L=>{if(L.targetMode==="External")return {...L,ownerPart:M};let K=w(L.ownerPart,L.rawTarget);return {...L,ownerPart:M,rawTarget:K.ok?K.partName:L.rawTarget}}),P=_t(X,"/word/document.xml"),E=_t(ce,"/word/footnotes.xml"),N$1=_t(on,"/word/endnotes.xml"),C=new Set(P.map(R=>R.id)),j=9001,V=(R,M)=>{let L=Yi(C,j);j+=1,C.add(L),P.push({ownerPart:"/word/document.xml",id:L,type:R,rawTarget:M,targetMode:"Internal",order:P.length});},oe=Xi(s,g);if(ht("/word/document.xml",_i,oe),b.part&&(te.length>0||de)){let R=Be(b.part.root,[...de?[de]:[],...te]);ht("/word/styles.xml",Fi,R),V(Yr,"styles.xml");}if(H.part&&(H.nums.length>0||H.abstracts.length>0)){let R=Be(H.part.root,[...H.abstracts.map(M=>Xe(M,G)),...H.nums]);ht("/word/numbering.xml",Li,R),V(qr,"numbering.xml");}u&&F.length>0&&(ht("/word/footnotes.xml",$i,Be(u.root,F)),V(Bi,"footnotes.xml"),E.length>0&&Ie$1.set("word/_rels/footnotes.xml.rels",Sa(Gt(E)))),h&&$.length>0&&(ht("/word/endnotes.xml",Ui,Be(h.root,$)),V(ji,"endnotes.xml"),N$1.length>0&&Ie$1.set("word/_rels/endnotes.xml.rels",Sa(Gt(N$1))));let le=new Map;for(let[R,M]of ae){Ie$1.set(R.slice(1),M);let L=qi(R);L&&!le.has(L)&&le.set(L,jc(e,R)??"application/octet-stream");}let B={ownerPart:"/",id:"rId1",type:Hi,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Ie$1.set("word/_rels/document.xml.rels",Sa(Gt(P))),Ie$1.set("_rels/.rels",Sa(Gt([B])));let ne=[`<Default Extension="rels" ContentType="${Xr}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...le].map(([R,M])=>`<Default Extension="${N(R)}" ContentType="${N(M)}"/>`)].join(""),Pe=gt.map(([R,M])=>`<Override PartName="${N(R)}" ContentType="${N(M)}"/>`).join("");Ie$1.set("[Content_Types].xml",Sa(`<Types xmlns="${_d}">${ne}${Pe}</Types>`));let ee=new Map;ee.set("/",[B]),ee.set("/word/document.xml",P),E.length>0&&ee.set("/word/footnotes.xml",E),N$1.length>0&&ee.set("/word/endnotes.xml",N$1);let be=[];for(let R of ee.values())for(let M of R)M.targetMode==="External"&&be.push({ownerPart:M.ownerPart,id:M.id,type:M.type,rawTarget:M.rawTarget,sinkSafe:x(M.rawTarget).ok});let q=new Map;q.set("rels",Xr),q.set("xml","application/xml");for(let[R,M]of le)q.set(R,M);let se={defaults:q,overrides:new Map(gt)},me=new Map;for(let[R,M]of Ie$1)me.set(R.startsWith("/")?R:`/${R}`,M);return {ok:true,bytes:Ra(Ie$1),package:Object.freeze({parts:Dt,partBytes:me,relationships:ee,externalTargets:be,contentTypes:se,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:t.lastMarkCovered,blockCount:g.length,mediaBytes:Oe}}function ue(e){return e.kind!=="textValue"}function J(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===da}function we(e,t){for(let n of e)t(n),n.kind!=="textValue"&&we(n.children,t);}function He(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===da&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===ga&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(He).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function Yt(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(He).join("")}`}function Bn(e){let t=[],n=new Map,r=new Set,o=null;if(e&&ue(e.root))for(let i of e.root.children){if(!ue(i))continue;if(J(i,"docDefaults")){o=i;continue}if(!J(i,"style"))continue;t.push(i);let a=Ie(i,"styleId");a&&n.set(a,i);let s=i.children.find(d=>J(d,"name")),l=s?Ie(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function $n(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(a=>J(a,t));if(!o||!ue(o))return r;let i=o.children.find(a=>J(a,n));if(!i||!ue(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function ao(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=>J(d,n));if(s&&ue(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=a.children.find(d=>J(d,"basedOn"));o=l?Ie(l,"val"):void 0;}return false}function Kd(e,t){for(let n of e.styles){if(Ie(n,"type")!==t)continue;let r=Ie(n,"default");if(r==="1"||r==="true")return Ie(n,"styleId")}}function Un(e,t){let n=e.children.find(r=>J(r,t));return n&&ue(n)?n:null}var Gd=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])),Xd=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 io(e,t,n){let r=$n(t.docDefaults,"rPrDefault","rPr"),o=$n(n.docDefaults,"rPrDefault","rPr"),i=$n(t.docDefaults,"pPrDefault","pPr"),a=$n(n.docDefaults,"pPrDefault","pPr"),s=(f,x,y)=>{let k=Kd(f,"paragraph"),I=k?f.byId.get(k):void 0;if(!I)return k;for(let[O,v]of [["rPr",x],["pPr",y]]){let D=Un(I,O);if(D)for(let U of D.children)U.kind!=="textValue"&&v.set(U.localName,U);}return k};s(t,r,i),s(n,o,a);let l=new Map;for(let[f,x]of r){let y=o.get(f);(!y||He(y)!==He(x))&&l.set(f,x);}let d=new Map;for(let[f,x]of i){if(f==="sectPr")continue;let y=a.get(f);(!y||He(y)!==He(x))&&d.set(f,x);}if(l.size===0&&d.size===0)return e;let c=0,m=()=>`fragment#materialized-${c++}`,p=f=>{let x=y=>y.kind==="textValue"?{id:m(),kind:"textValue",value:y.value}:{...y,id:m(),children:y.children.map(x)};return x(f)},g=(f,x,y)=>{if(y.length===0)return f;let k=Un(f,x);if(k){let O=x==="rPr"?Xd:Gd,v=[...k.children];for(let U of y){let Y=U.kind==="textValue"?Number.MAX_SAFE_INTEGER:O.get(U.localName)??Number.MAX_SAFE_INTEGER,S=v.length;for(let b=0;b<v.length;b+=1){let A=v[b];if(A.kind==="textValue")continue;let _=O.get(A.localName);if(_!==void 0&&_>Y){S=b;break}}v.splice(S,0,U);}let D={...k,children:v};return {...f,children:f.children.map(U=>U===k?D:U)}}let I={id:m(),kind:x==="rPr"?"runProperties":"paragraphProperties",namespaceUri:da,localName:x,prefix:"w",namespaceBindings:[],attributes:[],children:y};return {...f,children:[I,...f.children]}},u=f=>{let x=Un(f,"pPr"),y=x?.children.find(D=>J(D,"pStyle")),k=y?Ie(y,"val"):void 0,I=[];for(let[D,U]of d)x?.children.some(S=>S.kind!=="textValue"&&S.localName===D)||k&&ao(t,k,"pPr",D)||I.push(p(U));let O=D=>{if(D.kind==="textValue")return D;if(D.kind==="run"){let Y=Un(D,"rPr"),S=Y?.children.find(_=>J(_,"rStyle")),b=S?Ie(S,"val"):void 0,A=[];for(let[_,H]of l)Y?.children.some(te=>te.kind!=="textValue"&&te.localName===_)||b&&ao(t,b,"rPr",_)||k&&ao(t,k,"rPr",_)||A.push(p(H));return g(D,"rPr",A)}if(D.kind==="paragraphProperties"||D.kind==="runProperties")return D;let U=D.children.map(O);return U.some((Y,S)=>Y!==D.children[S])?{...D,children:U}:D};return O(g(f,"pPr",I))},h=f=>{if(f.kind==="textValue")return f;if(f.kind==="paragraph")return u(f);let x=f.children.map(h);return x.some((y,k)=>y!==f.children[k])?{...f,children:x}:f};return e.map(h)}var ns="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function ge(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var Yd=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),so=dg,Ve=new Map;function wt(e,t){let n=t.styleIds??Ve,r=t.numIds??Ve,o=t.relIds??Ve,i=t.footnoteIds??Ve,a=t.endnoteIds??Ve,s=t.bookmarkIds??Ve,l=t.sdtIds??Ve,d=t.revisionIds??Ve,c=t.docPrIds??Ve,m=(p,g)=>{if(p.kind==="textValue")return p;let u=p;if(p.namespaceUri===da&&Yd.has(p.localName)){let y=Ie(p,"val"),k=y!==void 0?n.get(y):void 0;k!==void 0&&(u=ge(u,da,"val",k));}if(J(p,"numId")){let y=Ie(p,"val"),k=y!==void 0?r.get(y):void 0;k!==void 0&&(u=ge(u,da,"val",k));}if(p.kind==="noteReference"){let y=p.localName==="footnoteReference"?i:a,k=Ie(p,"id"),I=k!==void 0?y.get(Ne(k)):void 0;I!==void 0&&(u=ge(u,da,"id",I));}if(p.kind==="bookmarkStart"||p.kind==="bookmarkEnd"){let y=Ie(p,"id"),k=y!==void 0?s.get(y):void 0;k!==void 0&&(u=ge(u,da,"id",k));}if(J(p,"id")&&g==="sdtPr"){let y=Ie(p,"val"),k=y!==void 0?l.get(y):void 0;k!==void 0&&(u=ge(u,da,"val",k));}if(so(p)){let y=Ie(p,"id"),k=y!==void 0?d.get(y):void 0;k!==void 0&&(u=ge(u,da,"id",k));}if(p.kind==="drawingDocPr"){let y=p.attributes.find(I=>I.localName==="id"&&I.namespaceUri==="")?.value,k=y!==void 0?c.get(y):void 0;k!==void 0&&(u=ge(u,"","id",k));}for(let y of u.attributes){if(y.namespaceUri!==ns)continue;let k=o.get(y.value);k!==void 0&&k!==y.value&&(u=ge(u,ns,y.localName,k));}let h=p.localName,f=u.children.map(y=>m(y,h));return u!==p||f.some((y,k)=>y!==u.children[k])?{...u,children:f}:p};return m(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 qd=1e5;function as(e){let t=Ob(),n=Jd(e,t),r=Qd(e,t),o=Zd(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function lo(e,t,n,r){if(e)return Qb(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<=Mb&&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 Jd(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])we([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=Ie(s,"id");l!==void 0&&(is(o,l),s.kind==="bookmarkStart"&&(r=ss(r,l)));});let i=lo(t,o,r+1,Mb);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 Qd(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;we([s.root],d=>{if(!dg(d))return;let c=Ie(d,"id");c!==void 0&&is(o,c),l&&(r=ss(r,c));});}let i=lo(t,o,r+1,Mb),a=false;return we(e.travelling,s=>{if(a||!dg(s))return;let l=Ie(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 Zd(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=Sb(e.pkg),o=qd;if(!t){let s=Tb(e.pkg);s.ok&&(o=s.id);}let i=lo(t,r,o,Rb),a=false;return we(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 st="http://schemas.openxmlformats.org/officeDocument/2006/relationships",ec=`${st}/hyperlink`,ls=`${st}/image`,jn=`${st}/numbering`,co=`${st}/styles`,ds="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",cs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function qt(e,t,n,r){for(let o of ic$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 mo(e,t){let n=0;return we([e],r=>{let o=t(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Hn(e,t,n,r){if(n.length===0)return e;let o=Fa(t,"paste"),i=n.map(d=>Ne$1(d,o)),a=Ai$1(t,i),s=r??a.root.children.length,l=La(a,a.root.id,s,i,{deferValidation:true});return l.ok?gc$1(e,l.part):null}function ms(e){let t=new Set;return we(e,n=>{if(n.kind!=="textValue")for(let r of n.attributes)r.namespaceUri===st&&r.value.length>0&&t.add(r.value);}),t}function ps(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||J(o,"pict")){let a=false;return we([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===st&&t.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===st)?.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 tc=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 nc(e,t){let n=ub(e);return n==="unknown"||(Object.hasOwn(us,t)?us[t]:t)!==n||tc.has(n)&&!Ub(e,n)?null:n}function po(e,t,n){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(P=>P.kind==="body"):null;if(!o||!ue(o))return {ok:false,reason:"no-fragment-document"};let i=Bi$1(o.children.filter(P=>P.kind==="paragraph"||P.kind==="table"||P.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a$1=e,s=qt(t,t.mainDocumentPart,jn,"/word/numbering.xml"),l=new Map,d=[],c=[];if(s&&ue(s.root)){let P=new Map,E=[];for(let B of s.root.children)if(ue(B))if(J(B,"abstractNum")){let ne=Ie(B,"abstractNumId");ne&&P.set(ne,B);}else J(B,"num")&&E.push(B);let N=qt(a$1,a$1.mainDocumentPart,jn,"/word/numbering.xml"),C=new Map,j=new Map;if(N&&ue(N.root)){for(let B of N.root.children)if(ue(B)&&J(B,"abstractNum")){let ne=Ie(B,"abstractNumId");ne&&j.set(ne,B);}for(let B of N.root.children){if(!ue(B)||!J(B,"num"))continue;let ne=Ie(B,"numId");if(!ne)continue;let Pe=B.children.find(q=>J(q,"abstractNumId")),ee=Pe?Ie(Pe,"val"):void 0,be=ee?j.get(ee):void 0;C.set(`${be?Yt(be):"none"}::${B.children.filter(q=>J(q,"lvlOverride")).map(He).join("")}`,ne);}}let V=(N?mo(N.root,B=>B.kind!=="textValue"&&J(B,"abstractNum")?Ie(B,"abstractNumId"):void 0):0)+1,oe=(N?mo(N.root,B=>B.kind!=="textValue"&&J(B,"num")?Ie(B,"numId"):void 0):0)+1,le=new Map;for(let B of E){let ne=Ie(B,"numId");if(!ne)continue;let Pe=B.children.find(L=>J(L,"abstractNumId")),ee=Pe?Ie(Pe,"val"):void 0,be=ee?P.get(ee):void 0,q=`${be?Yt(be):"none"}::${B.children.filter(L=>J(L,"lvlOverride")).map(He).join("")}`,se=C.get(q);if(se!==void 0){l.set(ne,se);continue}let me=ee?le.get(ee):void 0;me===void 0&&be&&ee&&(me=String(V++),le.set(ee,me),c.push(ge(be,da,"abstractNumId",me)));let R=String(oe++);l.set(ne,R);let M=ge(B,da,"numId",R);if(me!==void 0){let L=M.children.map(K=>J(K,"abstractNumId")?ge(K,da,"val",me):K);M={...M,children:L};}d.push(M),C.set(q,R);}}let m=Bn(qt(t,t.mainDocumentPart,co,"/word/styles.xml")),p=qt(a$1,a$1.mainDocumentPart,co,"/word/styles.xml"),g=Bn(p),u=new Map,h=[],f=new Set(g.byId.keys()),x=new Set(g.names),y=new Map,k=new Map,I=new Map,O=(P,E)=>{let N=I.get(P);return N===void 0&&(N=Yt(E),I.set(P,N)),N},v=P=>({...P,attributes:P.attributes.filter(E=>!(E.localName==="default"&&E.namespaceUri===da))});for(let P of m.styles){let E=Ie(P,"styleId");if(!E)continue;let N=g.byId.get(E),C=Yt(wt(P,{styleIds:u,numIds:l}));if(N&&O(E,N)===C){u.set(E,E);continue}if(!N){u.set(E,E),f.add(E),h.push(v(P));continue}let j=rs(`${E}Pasted`,f,y);f.add(j),u.set(E,j),h.push(v(ge(P,da,"styleId",j)));}let D=h.map(P=>{let E=P.children.find(V=>J(V,"name")),N=E?Ie(E,"val"):void 0;if(!N||!x.has(N))return N&&x.add(N),P;let C=os(N,x,k);x.add(C);let j=P.children.map(V=>J(V,"name")?ge(V,da,"val",C):V);return {...P,children:j}}),U=null,Y=1,S=()=>{if(U)return U;let P=new Map;for(let[E,N]of a$1.partBytes){let C=E.startsWith("/")?E:`/${E}`;if(!C.startsWith("/word/media/"))continue;P.set(a(N),C);let j=/\/image(\d+)\./.exec(C);j&&(Y=Math.max(Y,Number(j[1])+1));}return U=P,P},b=new Map,A=P=>{let E=b.get(P);if(!E){E=new Map;for(let N of ic$1(a$1,P)){if(N.targetMode==="External"||N.type!==ls)continue;let C=w(N.ownerPart,N.rawTarget);C.ok&&E.set(C.partName,N.id);}b.set(P,E);}return E},_=(P,E)=>{let N=P.lastIndexOf("."),C=N===-1?"":P.slice(N+1);return /^[A-Za-z0-9]{1,8}$/.test(C)?C.toLowerCase():E==="image/jpeg"?"jpeg":E==="image/gif"?"gif":"png"},H=(P,E,N)=>{let C=new Map,j=new Set,V=A(E),oe=[],le=new Set,B=[],ne=[],Pe=new Map,ee=[],be=t.relationships.get(P)??[];for(let q of be){if(!N.has(q.id))continue;if(q.targetMode==="External"){if(q.type===ec){let xt=zf(a$1,q.rawTarget,E);xt?(a$1=xt.pkg,C.set(q.id,xt.relationshipId)):j.add(q.id);}else j.add(q.id);continue}let se=w(q.ownerPart,q.rawTarget);if(!se.ok){j.add(q.id);continue}let me=t.partBytes.get(se.partName)??t.partBytes.get(se.partName.replace(/^\//,"")),R=(jc(t,se.partName)??"").toLowerCase();if(!me||!R.startsWith("image/")){j.add(q.id);continue}let M=nc(me,R);if(M===null){j.add(q.id);continue}let L=M,K=S(),Z=a(me),W=K.get(Z);if(!W){let xt=_(se.partName,L),cd=sn=>a$1.partBytes.has(sn)||a$1.partBytes.has(sn.slice(1))||a$1.parts.has(sn)||le.has(sn),ar=`/word/media/image${Y}.${xt}`;for(;cd(ar);)Y+=1,ar=`/word/media/image${Y}.${xt}`;Y+=1,W=ar,oe.push({partName:W,bytes:me,contentType:L}),le.add(W),K.set(Z,W);}let Je=W.startsWith("/word/")?W.slice(6):W,yt=V.get(W);if(yt!==void 0){C.set(q.id,yt);continue}let an=Pe.get(W);an===void 0&&(an=B.length,Pe.set(W,an),B.push(Je),ne.push(W)),ee.push({recordId:q.id,index:an});}if(oe.length>0&&(a$1=Yb(a$1,oe)),B.length>0){let q=mc$1(nc$1(a$1,E),E,B.map(se=>[ls,se]));if(q.ok){a$1=q.pkg,q.ids.forEach((se,me)=>{V.set(ne[me],se);});for(let se of ee)C.set(se.recordId,q.ids[se.index]);}else for(let se of ee)j.add(se.recordId);}return {relIdMap:C,dropRelIds:j}},G=H(t.mainDocumentPart,n,ms(i));i=ps(i,G.dropRelIds);let te=new Map,de=new Map,F=[],$=(P,E)=>ue(P)&&P.namespaceUri===da&&P.localName===E,z={},re=_n(i,(P,E)=>{let N=z[P];if(N===void 0){N=new Map,z[P]=N;let C=Wf(t,P);if(C&&ue(C.root))for(let j of C.root.children){if(!$(j,P))continue;let V=Ie(j,"id");if(V===void 0)continue;let oe=Ne(V);N.has(oe)||N.set(oe,j);}}return N.get(E)??null});for(let P of ["footnote","endnote"]){let E=P==="footnote"?te:de,N=re[P];if(N.size===0)continue;let C=Wf(t,P);if(!C||!ue(C.root))continue;let j=pg(a$1,P);if(!j.ok||!j.package)return {ok:false,reason:"merge-refused"};a$1=j.package;let V=Wf(a$1,P);if(!V)return {ok:false,reason:"merge-refused"};let oe=mo(V.root,B=>$(B,P)?Ie(B,"id"):void 0)+1,le=[];for(let B of C.root.children){if(!$(B,P))continue;let ne=Ie(B,"id"),Pe=Ie(B,"type");if(Pe==="separator"||Pe==="continuationSeparator"||ne===void 0||!N.has(Ne(ne))||E.has(Ne(ne)))continue;let ee=String(oe++);E.set(Ne(ne),ee),le.push(ge(B,da,"id",ee));}le.length>0&&F.push({kind:P,fragmentPartName:C.name,bodies:Bi$1(le)});}let ae=a$1.parts.get(n),Oe=[...i,...F.flatMap(P=>P.bodies)],qe=[],ve=new Set,_e=false,X=false,Fe=new Map;we(Oe,P=>{if(P.kind!=="textValue"){if(P.kind==="bookmarkStart"||P.kind==="bookmarkEnd"){let E=Ie(P,"id");if(E!==void 0&&qe.push(E),P.kind==="bookmarkStart"){let N=Ie(P,"name");N&&ve.add(N);}return}if(so(P)){_e=true;return}if(P.kind==="drawingDocPr"){X=true;return}if(P.kind==="contentControlProperties")for(let E of P.children){if(!J(E,"id"))continue;let N=Ie(E,"val");if(N!==void 0&&!Fe.has(N)){let C=0,j=`${N}:${Fe.size}`;for(let V=0;V<j.length;V+=1)C=C*31+j.charCodeAt(V)>>>0;Fe.set(N,String(C%2147483647||1));}}}});let ce=as({pkg:a$1,ownerPart:ae,notesParts:F.map(P=>Wf(a$1,P.kind)).filter(P=>P!==null),travelling:Oe,fragmentBookmarkIds:qe,hasRevision:_e,hasDocPr:X});if(!ce)return {ok:false,reason:"merge-refused"};let on=ce.bookmarkIds,Ie$1=ce.revisionIds,gt=ce.docPrIds;if(ve.size>0){let P=new Set;if(we([ae.root],E=>{if(E.kind!=="textValue"&&E.kind==="bookmarkStart"){let N=Ie(E,"name"),C=Ie(E,"id");N&&C!==void 0&&ve.has(N)&&P.add(C);}}),P.size>0){let E=C=>{if(C.kind==="textValue")return C;let j=[],V=false;for(let oe of C.children){if((oe.kind==="bookmarkStart"||oe.kind==="bookmarkEnd")&&P.has(Ie(oe,"id")??"")){V=true;continue}let le=E(oe);le!==oe&&(V=true),j.push(le);}return V?{...C,children:j}:C},N=E(ae.root);N!==ae.root&&(Ja(ae.root,N),a$1=gc$1(a$1,{...ae,root:N}));}}let Dt=P=>Zr(P,te,de);for(let P of F){P.bodies=P.bodies.map(Dt);let E=Wf(a$1,P.kind);if(!E)return {ok:false,reason:"merge-refused"};let N=H(P.fragmentPartName,E.name,ms(P.bodies)),C=ps(P.bodies,N.dropRelIds);C=[...io(C,m,g)],C=C.map(V=>wt(V,{styleIds:u,numIds:l,relIds:N.relIdMap,footnoteIds:te,endnoteIds:de,bookmarkIds:on,sdtIds:Fe,revisionIds:Ie$1,docPrIds:gt}));let j=Hn(a$1,a$1.parts.get(E.name),C);if(!j)return {ok:false,reason:"merge-refused"};a$1=j;}if(D.length>0){let P=D.map(N=>wt(N,{styleIds:u,numIds:l}));if(!p){let N=xa(`<w:styles xmlns:w="${da}"></w:styles>`,{name:"/word/styles.xml",contentType:cs});if(!N.ok)return {ok:false,reason:"merge-refused"};a$1=pc(a$1,"/word/styles.xml",N.part.root,cs);let C=oc$1(nc$1(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,co,"styles.xml");if(!C.ok)return {ok:false,reason:"merge-refused"};a$1=C.pkg,p=a$1.parts.get("/word/styles.xml")??null;}if(!p)return {ok:false,reason:"merge-refused"};let E=Hn(a$1,a$1.parts.get(p.name),P);if(!E)return {ok:false,reason:"merge-refused"};a$1=E,g=Bn(a$1.parts.get(p.name)??null);}if(c.length>0||d.length>0){let P=qt(a$1,a$1.mainDocumentPart,jn,"/word/numbering.xml");if(!P){let V=xa(`<w:numbering xmlns:w="${da}"></w:numbering>`,{name:"/word/numbering.xml",contentType:ds});if(!V.ok)return {ok:false,reason:"merge-refused"};a$1=pc(a$1,"/word/numbering.xml",V.part.root,ds);let oe=oc$1(nc$1(a$1,a$1.mainDocumentPart),a$1.mainDocumentPart,jn,"numbering.xml");if(!oe.ok)return {ok:false,reason:"merge-refused"};a$1=oe.pkg,P=a$1.parts.get("/word/numbering.xml")??null;}if(!P)return {ok:false,reason:"merge-refused"};let E=a$1.parts.get(P.name),N=E.root.children.findIndex(V=>J(V,"num")),C=c.map(V=>wt(V,{styleIds:u,numIds:l})),j=Hn(a$1,E,C,N===-1?void 0:N);if(!j)return {ok:false,reason:"merge-refused"};if(a$1=j,j=Hn(a$1,a$1.parts.get(P.name),d),!j)return {ok:false,reason:"merge-refused"};a$1=j;}let _t=[...io(i,m,g)].map(Dt).map(P=>wt(P,{styleIds:u,numIds:l,relIds:G.relIdMap,footnoteIds:te,endnoteIds:de,bookmarkIds:on,sdtIds:Fe,revisionIds:Ie$1,docPrIds:gt}));return {ok:true,pkg:a$1,blocks:_t}}var fs=16*1024*1024;function rc(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>wi$1)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>yi))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,xi))return false;for(let[i,a]of e.parts)if(i!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,xi*4))return false;return true}function uo(e,t,n){if(n.fragmentBytes.byteLength>fs)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=ec$1(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!rc(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,m="";return Ca(e,()=>{let p=a.transact(u=>{for(let y of n.priorOps??[])if(!u.apply(y))return;let h=null,f=u.applyPackage(y=>(h=po(y,o,s.partName),h.ok?h.pkg:y)),x=h;if(!x||!x.ok){m=`fragment-merge:${x?x.reason:"no-merge"}`,u.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}f&&(c=x.blocks.length,u.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:x.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return m.length>0?{ok:false,reason:"invalidArgs",detail:m}: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=>Da(p))}function gs(){let e=null;return (t,n,r)=>{let o=e;if(e=null,!Yh$1(n)||!("paragraphId"in r)||!_h(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=Ha(t,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=di(t,ci(r));if(a.unprotected.length)return r;let s=Ue(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 hs=new WeakSet;function oc(e){return hs.add(e),e}function ys(e){return hs.has(e)}function Jt(e){return {...e,applyPackage:t=>e.applyPackage(oc(t))}}var ac=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertDrawing","deleteText"]),xs=new Set(["insertDrawing"]);function ic(e){if(!(e===null||e.start!==e.end))return e}var Et={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function sc(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 lt=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?sc(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=gc$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 Nb(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,m=new Set,p=new Set,g=new Set,u=new Set,h=new Set,f=[],x=n.minimumImpact??"text-local",y=null,k=false,I=null,O=null,v=new Map,D=new Map,U=F=>{let $=D.get(F.name);$||($={mint:null,written:new Set},D.set(F.name,$));let z=$;return {mint:()=>(z.mint??=cg(F))(),wrote:re=>{z.written.add(re);},wroteUnder:re=>z.written.has(re)}},Y=()=>{for(let F of D.values())F.mint=null;},S=(F,$)=>{let z=Fh.get(F.op);if(z===void 0)return v.clear(),null;let re=`${$.name}\0${z}`,ae=v.get(re);ae||(ae={id:null},v.set(re,ae));let Oe=ae;return ()=>Oe.id??=U($).mint()},b$1=(F,$)=>{let z=ac.has(F.op);return !z&&Fh.get(F.op)!==void 0?null:((!z||xs.has(F.op))&&Y(),z?U($):null)},A=gs(),_=null,H=(F,$)=>{if(d)return false;let z=l.parts.get(F);if(!z)return d={reason:"unknown-part",detail:F},false;$=A(z,this.settingsPartOverride?.()??Lf(l),$);let re=Xh$1(this.settingsPartOverride?.()??Lf(l),$)??ei(z,this.settingsPartOverride?.()??Lf(l),$,_?.partName===F&&"paragraphId"in $&&_.paragraphId===$.paragraphId?_.fieldNodeId:void 0);if(re)return d={reason:re},false;let ae=S($,z),Oe=b$1($,z),qe=this.settingsPartOverride?.()??Lf(l),ve=Yh$1(qe)&&"paragraphId"in $&&_h(z,$.paragraphId)?qh(z,$,_?.partName===F&&_.paragraphId===$.paragraphId?_.fieldNodeId:void 0):null;_=ve&&"paragraphId"in $?{partName:F,paragraphId:$.paragraphId,fieldNodeId:ve.fieldNodeId}:null;let _e={deferValidation:true,...ae?{revisionIds:ae}:{},...Oe?{trackedRevisionIds:Oe}:{}},X=ve?wh(z,$,ve,_e):Ci$1(z,$,_e);if(!X.ok)return d={reason:X.reason,...X.detail?{detail:X.detail}:{}},false;if(xs.has($.op)&&Y(),l=gc$1(l,X.part),X.part===z&&X.effect.dirty.length===0&&X.effect.created.length===0&&X.effect.deleted.length===0&&X.effect.split===void 0&&(X.effect.splits===void 0||X.effect.splits.length===0)&&X.effect.join===void 0&&X.effect.caret===void 0)return true;m.add(F),c+=1;for(let ce of X.effect.dirty)p.add(ce);for(let ce of X.effect.created)g.add(ce);for(let ce of X.effect.deleted)u.add(ce);for(let ce of X.effect.dependencyKeys)h.add(ce);X.effect.split&&f.push({split:X.effect.split});for(let ce of X.effect.splits??[])f.push({split:ce});return X.effect.join&&f.push({join:X.effect.join}),Et[X.effect.impact]>Et[x]&&(x=X.effect.impact),X.effect.caret&&(O={paragraphId:X.effect.caret.paragraphId,start:0,end:0}),true};if(t({apply:F=>H(this.storyPartName,F),applyTo:(F,$)=>H(F,$),applyPackage:F=>{if(d)return false;let $=this.settingsPartOverride?.()??Lf(l),z=ys(F)?Wh($,{op:"comment"}):Xh$1($);if(z)return d={reason:z},false;v.clear(),Y();let re=F(l);if(re===l)return true;for(let[ae,Oe]of re.parts)l.parts.get(ae)!==Oe&&m.add(ae);return l=re,c+=1,Et["flow-structural"]>Et[x]&&(x="flow-structural"),true},selectionBefore:F=>{y=F;},selectionAfter:F=>{k=true,I=F;}}),d){let F=d;return {ok:false,reason:F.reason,...F.detail?{detail:F.detail}:{}}}if(c===0)return {ok:true,change:null};let G=k?I:O,te=k?ic(I):O??void 0;for(let F of m){let $=a.parts.get(F),z=l.parts.get(F);if(z===void 0)continue;let re=$?va($,z):va(z,z);if(!re.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(re.issues)}}let de=qc$1(l);if(!de.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(de.issues)};if(o)if(this.composition)Mi$1(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:G}};else {let F=n.historyGroup,$=this.undoStack[this.undoStack.length-1];F!==void 0&&$!==void 0&&$.group===F?this.undoStack[this.undoStack.length-1]={...$,selectionAfter:G??$.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:y,selectionAfter:G,group:F}),Mi$1(F,$?.group===F?"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:g,deleted:u,dependencyKeys:h,splitJoin:f,impact:x,caret:te},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 fo(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function ks(e,t){return fo(e,t).map(n=>n.name).sort().join(",")}function Ps(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 Wn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",lc="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Tt(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===Wn&&n.localName===t)return n;return null}function Vn(e,t){return e.attributes.find(n=>n.namespaceUri===Wn&&n.localName===t)?.value}function dc(e){let t=Vn(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function Os(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>Os(n,t))})}function cc(e){let t=xa(`<w:styles xmlns:w="${Wn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:lc});if(!t.ok)return null;let n=Tt(t.part.root,"style"),r=n?Tt(n,"pPr"):null;return r?Os(r,Fa(e)):null}var Rs=["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 mc(e,t){let n=Rs.indexOf(t),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=Rs.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function vs(e,t){let n=nf(e);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===Wn&&d.localName==="style"&&Vn(d,"type")==="paragraph"&&Vn(d,"styleId")===t){r=d;break}if(!r)return null;let o=Tt(r,"name");if(o&&Vn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let i=cc(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&&dc(d))return e;l=d?Ma(n,d.id,a):La(n,s.id,mc(s.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=La(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 Ns="http://schemas.openxmlformats.org/package/2006/relationships",ws="application/vnd.openxmlformats-package.relationships+xml",fc="http://schemas.openxmlformats.org/package/2006/content-types",Is="/[Content_Types].xml",dt="/word/numbering.xml",bs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",Qt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",gc=`<Override PartName="${dt}" ContentType="${Qt}"/>`;function zn(e){return `${e.ownerPart}\0${e.id}`}function Es(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===Ya).map(zn)),o=n.externalTargets.filter(s=>s.type===Ya&&!r.has(zn(s)));if(o.length===0)return e;let i=new Set(e.map(zn)),a=o.filter(s=>!i.has(zn(s)));return a.length===0?e:Object.freeze([...e,...a])}function 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=hc(e,t,r);return o=xc(o,t,n),o}function Ms(e,t){let n=new Set;for(let o of e.externalTargets)o.type===Ya&&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=Oc(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=vc(r,o);return r}function hc(e,t,n){let r=t.parts.get(dt);if(!r)return e;let o=e.parts.get(dt),i=n&&o?yc(o,r):r,a=gc$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=Pc(a,{...s,ownerPart:a.mainDocumentPart});d&&(a=d);}if(a.contentTypes.overrides.get(u(dt))!==Qt){let d=Ic(a);d&&(a=d);}return a}function yc(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(m=>m.namespaceUri===n&&m.localName===d)?.value;return c===void 0?null:`${l.localName}:${c}`},o=new Set(e.root.children.map(r).filter(Boolean)),i=Fa(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),m=s.root.children.findIndex(g=>g.kind!=="textValue"&&g.namespaceUri===n&&a.indexOf(g.localName)>c),p=La(s,s.root.id,m<0?s.root.children.length:m,[go(l,i)]);p.ok&&(s=p.part,o.add(d));}return s}function xc(e,t,n){let r=n.filter(i=>i.type===Ya);if(r.length===0)return e;let o=e;for(let i of r){let a=kc(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=Rc(o,{ownerPart:a,id:i.id,type:Ya,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function kc(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Pc(e,t){let n=e.mainDocumentPart,r=ho(n),o=e.parts.get(r),i=xa(`<Relationships xmlns="${Ns}"><Relationship Id="${P(t.id,"relationship id")}" Type="${P(t.type,"relationship type")}" Target="${P(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:ws});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?As(e,o,i.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:l})}function Rc(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=ho(r),i=e.parts.get(o),a=xa(`<Relationships xmlns="${Ns}"><Relationship Id="${P(t.id,"relationship id")}" Type="${Ya}" Target="${P(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:ws});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=As(e,i,a.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function As(e,t,n,r){if(!n)return null;let o=Fa(t),i=La(t,t.root.id,t.root.children.length,[go(n,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,i.part]]),relationships:r}):null}function go(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>go(n,t))}}function ho(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Oc(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 vc(e,t){let n=ho(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 Ic(e){let t=e.contentTypes.overrides.get(u(dt));if(t===Qt)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)+gc+r.slice(i),s=Ss(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Ds("Override",{PartName:dt,ContentType:Qt})];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(dt),Qt]])})})}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"]!==fc)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(Ds(s.name,s.attributes));return {rootName:r.name,children:a}}function Ds(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 Wf(e,"footnote")!==null||Wf(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=Ha(t,n.paragraphId);return !o||o.kind!=="paragraph"?true:Se(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=Ha(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 Se(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(!Bg(e))return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=Ha(t,o);return !i||i.kind==="textValue"?true:Bs(i,0,{count:0})}var yo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",xo="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!==yo&&r.type!==xo?{ok:false,reason:"wrong-relationship-type",detail:r.type}:bc(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function bc(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 ct(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function Vs(e,t){let n=Ha(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=Ha(r,n);return !o||o.kind!=="drawing"?null:mb(o,{ownerPartName:t,supportedMcRequires:fb,limits:eb,resolveRelationship:hb(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=ct(e,o.store);if(i)return i;let{store:a,story:s}=o;return Ca(e,()=>Sc(e,a,s,n,r),l=>Da(l))}function Sc(e,t,n,r,o){let i=n.partName,a=e.currentPackage(),s=t.checkpoint(),l=null,d=false,c=false,m=t.transact(u=>{if(o?.commitGuard?.()===false){c=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){d=true;return}let h=r(u,i);if(h===null){u.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=h;},{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(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let p=m.change.created.find(u=>{let h=t.part;return Ha(h,u)?.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?si(o):null}function ko(e,t,n,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(t);if(!a)return i;let s=Ha(a,n);if(!s||s.kind!=="drawing")return i;let l=Vs(a,n);if(!l)return i;let d=ti(l,r),c=Nc(s,d),m=Ma(a,s.id,c,{deferValidation:true});return m.ok?(o=true,gc$1(i,m.part)):i}),o}function Nc(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function Gs(e,t,n){let r=_b(n.widthPoints),o=_b(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=ct(e,i.store);if(a)return a;let s=i.story.partName,l=await Vb(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=Xb(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 m=c.partName,p=Ct(e,t,(g,u)=>{let h=e.currentPackage(),f=Xb(h,u,{bytes:d,mime:n.mime});if(!f.ok)return null;h=f.pkg,m=f.partName;let x;if(n.hyperlink){let k=zf(h,n.hyperlink,u);if(!k)return null;h=k.pkg,x=k.relationshipId;}if(!g.applyPackage(()=>h))return null;let y=$b({docPrId:f.docPrId,relationshipId:f.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...x?{hyperlinkRelationshipId:x}:{}});return g.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:y,...n.revision?{revision:n.revision}:{}})?y.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return p.ok?p.change?{...p,mediaPartName:m}:{ok:true,change:null,mediaPartName:m}:p}async function Po(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=ct(e,s.store);if(l)return l;let d=s.story.partName,c=await Vb(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let m=c.bytes,p=Xb(e.currentPackage(),d,{bytes:m,mime:o});return p.ok?Ct(e,t,(g,u)=>{let h=e.currentPackage(),f=Ws(h,d,n),x=f?.picture?.embeddedRelationshipId??null,y=f?.picture?.linkedRelationshipId??null,k=x??y;if(!k)return null;let I=x!==null?zs(h,d,x):null,O=h,v=Xb(O,u,{bytes:m,mime:o});return !v.ok||(O=v.pkg,!g.applyPackage(()=>O))||!g.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:v.relationshipId})?null:(g.applyPackage(D=>bc$1(D,u,I,k)),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=ct(e,r.store);if(o)return o;let i=r.story.partName,a=e.currentPackage(),s=Ws(a,i,n);if(!s)return {ok:false,reason:"unknown-drawing"};let l=s.picture?.embeddedRelationshipId??null,d=s.picture?.linkedRelationshipId??null,c=l??d,m=l!==null?zs(a,i,l):null;return Ct(e,t,(p,g)=>p.apply({op:"deleteDrawing",drawingNodeId:n})?(p.applyPackage(u=>bc$1(u,g,m,c)),n):null)}function wc(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 m=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let p of d.children)l(p,m);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=Ue(i).spanOf(t);if(a!==null&&a.end>a.start){let s=Ha(e,t);if(!s||s.kind!=="drawing"&&!ib(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=ct(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=wc(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 qs(e,t,n,r,o,i,a,s){let l=await cc$1(o,r,i,void 0,a);return l.ok?Po(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 Js(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=ct(e,a.store);return s||Ct(e,t,(l,d)=>{let c=Ks(e.currentPackage(),d,n),m=null;if(i!==null){let g=zf(e.currentPackage(),i,d);if(!g||!l.applyPackage(()=>g.pkg))return null;m=g.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&m!==null){if(!ko(l,d,n,m))return null}else if(i===null&&!ko(l,d,n,null))return null;let p=false;return l.applyPackage(g=>{let u=Bf(g,d,c);return u===null?(p=true,g):u}),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=ct(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=zf(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(!ko(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let m=Bf(c,a,s);return m===null?(d=true,c):m}),d?null:n.drawingNodeId})}function Ec(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 Tc(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 Cc(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)=>!Tc(i,o[a])))return false}return true}function Mc(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 Ac(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||!Ec(r,o))return false}return true}function Dc(e,t){return e.contentTypes===t.contentTypes||Zs(e.contentTypes.defaults,t.contentTypes.defaults)&&Zs(e.contentTypes.overrides,t.contentTypes.overrides)}var Kn=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),Gn=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function el(e){for(let[t,n]of e)if(!sa(t,n))return Gn;return Kn}function _c(e,t){if(e===t)return Kn;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Ac(e.partBytes,t.partBytes)||!Cc(e.relationships,t.relationships)||!Mc(e.externalTargets,t.externalTargets)||!Dc(e,t))return Gn;let n=[];for(let[a,s]of e.parts){let l=t.parts.get(a);if(!l)return Gn;s!==l&&n.push([s,l]);}if(n.length===0)return Kn;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return el(n);let i=ta(o.root,r.root);return i.undecided?el(n):i.equal?Kn:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?Gn:{equal:false,dirty:i.paragraphIds,dependencyKeys:[g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function Ro(e){return {ok:false,reason:"package-invariant",detail:e}}function Fc(e,t){if(!e.parts.get(e.mainDocumentPart))return Ro("no-main-document");for(let[r,o]of e.parts){let i=t?.parts.get(r);if(i===o)continue;let a=i?va(i,o):ua(o);if(!a.ok)return Ro(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=qc$1(e);return n.ok?null:Ro(n.issues[0]?.code??"package-invariant")}function tl(e,t,n){let r=e.currentPackage(),o=_c(t,r);if(o.equal)return {ok:true,change:null};let i=Fc(t,r);if(i)return i;let a=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===a;return Ca(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,Zt=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=gc$1(t,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??ll,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??og,this.body=new lt(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>Lf(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=gc$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=gc$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 Ca(this,()=>this.commitStoryTransaction(t,n,r),Da,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(),m=false,p=new Set,g=false,u=new Set,h=false,f,x=false;i.graftPackage(()=>this.currentPackage());let y=i.transact(O=>{n({...O,applyTo:(v,D)=>{let U=O.applyTo(v,D);return U&&v!==a.partName&&(x=true),U},applyPackage:v=>O.applyPackage(D=>{let U=v(D);return U!==D&&!x&&(x=Ps(D,U,a.partName)),U}),apply:v=>(v.op==="setListNumbering"&&v.numId!==null&&(h=true),v.op==="setParagraphProperties"&&(f??=v.properties.find(D=>D.localName==="pStyle")?.attributes?.val),m||(v.op==="deleteText"&&$s(this.pkg,i.part,v,p)||v.op==="deleteBlock"&&Us(this.pkg,i.part,v,p)||il.has(v.op)||sl.has(v.op))&&(m=true),g||(v.op==="deleteText"||v.op==="deleteBlock"?g=js(this.pkg,i.part,v,u):(il.has(v.op)||sl.has(v.op))&&(g=true)),O.apply(v)),selectionBefore:v=>O.selectionBefore(v),selectionAfter:v=>O.selectionAfter(v)});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!y.ok)return {ok:false,reason:y.reason,...y.detail?{detail:y.detail}:{}};this.syncPackageFromStore(i);let k=false;if(y.change&&x&&(this.installPackageSnapshotInternal(i.package,false),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),k=true),h&&f){let O=vs(this.pkg,f);O&&this.replacePackageShell(O);}let I=false;if(y.change&&m){let O=this.currentPackage(),v=this.cascadeNoteReferences(s,O);if(v===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};v!==O&&(this.installPackageSnapshotInternal(v),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),I=true);}if(y.change&&g){let O=this.currentPackage(),v=Fg(s,O,{storyPartName:a.partName});if(v===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};v!==O&&(this.installPackageSnapshotInternal(v),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),I=true);}if(y.change){this.packageRev+=1;let O=I||k;O&&Mi$1(r.historyGroup,"split","package-unit"),!d&&r.recordsHistory!==false&&(i.historyDepth>l||O)&&(O?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage()}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let v=O?this.publishSynthetic(y.change.origin,"global",a,y.change.created):y.change;return O||this.publish(v),{ok:true,change:v}}return {ok:true,change:y.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 Ca(this,()=>this.commitLifecycleOp(t),Da)}commitLifecycleOp(t){let n=this.currentPackage(),r=Wh(Lf(n),t);if(r)return {ok:false,reason:r};if(mg(t)){let s=ng(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(!Ef(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let o=Ff(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(Ki$1(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(Ki$1(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(){let t=this.undoOrder[this.undoOrder.length-1];return !t||t.kind==="package"?null:(t.partName===this.body.part.name?this.body:this.stories.get(t.partName))?.selectionForUndo()??null}selectionForRedo(){let t=this.redoOrder[this.redoOrder.length-1];return !t||t.kind==="package"?null:(t.partName===this.body.part.name?this.body:this.stories.get(t.partName))?.selectionForRedo()??null}openStoryParts(){return fo(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 uo(this,t,n)}replaceImage(t,n,r,o,i,a){return Po(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 qs(this,t,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(t,n,r,o,i){return Js(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=gc$1(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=gc$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!==yo&&s.type!==xo)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=gc$1(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=gc$1(this.pkg,s.part));}openNotesPartStore(t){let n=Wf(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=Lb(n),i=new lt(o,{historyLimit:this.historyLimit,settingsPart:()=>Lf(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:t};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=gc$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=Lb(r.part),a=new lt(i,{historyLimit:this.historyLimit,settingsPart:()=>Lf(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=gc$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=gc$1(this.pkg,t.part);}pushUndoPointer(t){Ki$1(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 Lc=256,$c=65535,dl=64;function Xn(e,t){return e.length>t}function cl(e){return typeof e!="string"||e.trim().length===0?"invalid-author":Xn(e,Lc)?"resource-limit":O(e)?null:"invalid-author"}function ml(e){return typeof e!="string"||e.length===0?"invalid-text":Xn(e,$c)?"resource-limit":O(e)?null:"invalid-text"}function Oo(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(Xn(t,dl))return {ok:false,rejection:"resource-limit"};if(!O(t))return {ok:false,rejection:"invalid-date"};let n=Le(t);return n===null?{ok:false,rejection:"invalid-date"}:Xn(n,dl)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function zg(e){if(e===void 0)return null;let t=Oo(e);return t.ok?null:t.rejection}function vo(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 Uc(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Io(e,t){if(!e){let a=Ob(t);return a?Pb(new Set,a,Mb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Uc(a,da,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=Mb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(e.root);let i=Ob(t);return i?Pb(r,i,Mb):String(n+1)}function pl(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=pl(i,t);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function Hc(e,t,n){let r=pl(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:ga}]};return Ma(e,e.root.id,o,{deferValidation:true})}function ul(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=Jb(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 m=Hc(s,c,l===null?d:null);if(!m.ok)return null;o=gc$1(o,m.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 Ka(e,e.root.id,[...r,...n],{deferValidation:true})}var yl="/word/comments.xml",xl="/word/commentsExtended.xml",Eo="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",To="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Vc=[To,"application/vnd.ms-word.commentsExtended+xml"],kl="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Co="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",Ye="http://schemas.microsoft.com/office/word/2012/wordml";function tn(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:da,localName:e,prefix:"w",value:t}}function We(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 Pl(e,t,n,r,o){let i=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let a of i)for(let s of ic$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=jc(e,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return o}function bo(e,t,n){let r=e.mainDocumentPart;for(let i of ic$1(e,r)){if(i.type!==t)continue;let a=w(r,i.rawTarget);if(a.ok&&a.partName===n)return e}let o=nc$1(e,r);return oc$1(o,r,t,Sg(r,n)).pkg}function Mo(e,t){return Pl(e,t,kl,Eo,yl)}function Rl(e,t){let n=rg(e,t),r=sg(e,t,n).extended;return r!==null?r:Pl(e,t,Co,Vc,xl)}function gl(e){let t=new Set;for(let n of e.parts.values())for(let r of Ib(n.root))t.add(r);return t}function Wc(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&tn(o,da,"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=tn(a,ga,"paraId");s!==void 0&&Eb(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),n}function zc(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&tn(o,da,"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 Ol(e){let t=Jb(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:ga}]},r=Ma(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(Ja(e.root,n),{part:{...e,root:n},prefix:"w14"})}function vl(e,t,n){return We(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===ga&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:ga,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function Kc(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let i=Ol(o),a=Ha(i.part,n);if(!a||a.kind!=="paragraph")return gc$1(e,i.part);let s=Ma(i.part,a.id,vl(a,r,i.prefix),{deferValidation:true});return gc$1(e,s.ok?s.part:i.part)}function Gc(e,t,n,r){let o=`${yl}#comment-${e}`,i=n.text!==n.text.trim(),a=We(`${o}.t`,"text",da,"w","t",i?[{kind:"xmlSpace",namespaceUri:ea,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=We(`${o}.rPr`,"runProperties",da,"w","rPr",[],[We(`${o}.rStyle`,"generic",da,"w","rStyle",[Mt("val","CommentReference")],[])]),l=We(`${o}.r`,"run",da,"w","r",[],[s,a]),d=We(`${o}.pPr`,"paragraphProperties",da,"w","pPr",[],[We(`${o}.pStyle`,"generic",da,"w","pStyle",[Mt("val","CommentText")],[])]),c=We(`${o}.p`,"paragraph",da,"w","p",[{kind:"genericExtension",namespaceUri:ga,localName:"paraId",prefix:r,value:t}],[d,l]);return We(o,"comment",da,"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 So(e,t){let n=xa(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function Ao(e,t){for(let x of [cl(t.author),ml(t.text)])if(x)return {ok:false,reason:vo(x)};let n;if(t.date!==void 0){let x=Oo(t.date);if(!x.ok)return {ok:false,reason:vo(x.rejection)};n=x.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,i=e.part.name,a=Mo(o,i),s=Rl(o,i),l=o.parts.get(a),d=Io(l,r.actorId),c=Hb(`${a}#${d}`,gl(o)),m=t.replyToCommentId===void 0?null:Wc(l,t.replyToCommentId),p=t.replyToCommentId!==void 0&&m===null?zc(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&m===null&&!p)return {ok:false,reason:"unknown-revision"};let g=p?Hb(`${a}#parent-${t.replyToCommentId}`,new Set([...gl(o),c])):null,u=m??g,h=t.anchor.endParagraphId??t.anchor.paragraphId,f=e.transact(x=>{let y=Jt(x);y.applyPackage(k=>{let I=k.parts.has(a)?k:(()=>{let O=So(a,`<w:comments xmlns:w="${da}"/>`);return O?pc(k,a,O,Eo):null})();return I===null?k:bo(I,kl,a)}),p&&g&&y.applyPackage(k=>Kc(k,a,p.id,g)),y.applyPackage(k=>{let I=k.parts.get(a);if(!I)return k;let O=Ol(I),v=La(O.part,O.part.root.id,O.part.root.children.length,[Gc(d,c,r,O.prefix)],{deferValidation:true});return v.ok?gc$1(k,v.part):k}),u!==null&&(y.applyPackage(k=>{let I=k.parts.has(s)?k:(()=>{let O=So(s,`<w15:commentsEx xmlns:w15="${Ye}"/>`);return O?pc(k,s,O,To):null})();return I===null?k:bo(I,Co,s)}),y.applyPackage(k=>{let I=k.parts.get(s);if(!I)return k;let v=[...Xc(I).has(u.toUpperCase())?[]:[wo(`${s}#ex-${u}`,u,void 0,false)],wo(`${s}#ex-${c}`,c,u,false)],D=La(I,I.root.id,I.root.children.length,v,{deferValidation:true});return D.ok?gc$1(k,D.part):k})),y.applyTo(i,{op:"insertCommentMarker",paragraphId:h,offset:t.anchor.end,commentId:d,marker:"reference"}),y.applyTo(i,{op:"insertCommentMarker",paragraphId:h,offset:t.anchor.end,commentId:d,marker:"end"}),y.applyTo(i,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return f.ok?{ok:true,commentId:d,change:f.change}:{ok:false,reason:f.reason}}function No(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=No(e);if(!t)return null;let n=tn(t,ga,"paraId");return n!==void 0&&Eb(n)?n.toUpperCase():null}function Xc(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===Ye&&r.localName==="commentEx"){let o=tn(r,Ye,"paraId");o!==void 0&&Eb(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function en(e,t){return {kind:"genericExtension",namespaceUri:Ye,localName:e,prefix:"w15",value:t}}function Yc(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 qc(e,t,n){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===Ye&&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===Ye&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&t!==void 0&&r.push(en("paraIdParent",t)),o||r.push(en("done",n?"1":"0")),Yc(e,r)}function wo(e,t,n,r){return {id:e,kind:"generic",namespaceUri:Ye,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[en("paraId",t),...n===void 0?[]:[en("paraIdParent",n)],en("done",r?"1":"0")],children:[]}}function Do(e,t,n){return Jc(e,t,n,qg())}function Jc(e,t,n,r){let o=e.package,i=e.part.name;if(rg(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=ug(o,t,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=tg(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,m=[];for(let h of s.ids){let f=s.records.get(h);if(!f)return {ok:false,reason:"unknown-comment"};if(!No(f.node))return {ok:false,reason:"unknown-comment"};let y=hl(f.node),k=y??Hb(`${f.partName}#done-${h}`,d);y===null&&d.add(k),c.set(h,k);}for(let h of s.ids){let f=s.records.get(h),x=No(f.node),y=c.get(h),k=hl(f.node),I=s.parentCommentIdByChildId.get(h),O=s.parentParaIdByCommentId.get(h)??(I===void 0?void 0:c.get(I)),v=s.commentExByParaId.get(y);m.push({paraId:y,stampParagraph:k===null?x:null,commentsPartName:f.partName,parentParaId:O,existing:v?.node,existingParentParaId:v?.parentParaId,existingDone:v?.done??false});}if(m.length===0)return {ok:false,reason:"unknown-comment"};if(m.every(h=>h.existingDone===n))return {ok:true,changed:false,change:null};let p=s.extendedPartName??xl,g=s.extendedPartName===null,u=e.transact(h=>{Jt(h).applyPackage(x=>{let y=ul(x,m,vl);if(y===null)return x;let k=y;if(!k.parts.has(p)){let U=So(p,`<w15:commentsEx xmlns:w15="${Ye}"/>`);if(!U)return x;let Y=pc(k,p,U,To);k=g?bo(Y,Co,p):Y;}let I=k.parts.get(p);if(!I)return x;let O=new Map,v=[];for(let U of m){let Y=U.existingParentParaId??U.parentParaId;U.existing?O.set(U.existing.id,qc(U.existing,Y,n)):v.push(wo(`${p}#done-${U.paraId}`,U.paraId,Y,n));}let D=fl(I,O,v);return D.ok?gc$1(k,D.part):x});});return u.ok?{ok:true,changed:true,change:u.change}:{ok:false,reason:u.reason}}function Qc(e,t){let n=Mo(e,t);return e.parts.has(n)&&jc(e,n)===Eo}function Zc(e,t){return Mo(e,t)}function em(e,t){return Rl(e,t)}var Il={kind:"body"};function tm(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()),Ca(e,()=>{let s=Ao(o,t);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Da(s))}function nm(e,t,n){let r=e.bodyStore(),o=e.currentPackage(),i=Wh(Lf(o),{op:"setCommentResolved"});if(i)return {ok:false,reason:i};let a=r.checkpoint();return r.graftPackage(()=>e.currentPackage()),Ca(e,()=>{let s=Do(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 rm(e,t,n=Il,r){if(t.length===0||Wh(Lf(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()),Ca(e,()=>{let d=false,c=false,m=a.transact(p=>{Jt(p).applyPackage(u=>{let h=u;for(let f of t){let x=f.parentCommentId===void 0?Dg(h,f.commentId,i):Eg(h,f.commentId,f.parentCommentId,i);if(x===null)return d=true,u;c||=x!==h,h=x;}return h});});return d||!m.ok||!c?false:(a.restoreHistoryStacks(l),e.installPackageSnapshot(a.package),e.adoptPackageUnit(s),e.publishStoryWrite(m.change),true)},d=>d)}var Sl=256*1024,Nl=4096;function _o(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>Nl)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(Lc$1(e.part.root).map(p=>p.node.id)),s=t.replaceControlId===void 0?[]:wl(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 h of s)p.applyPackage(f=>_g(f,h.partName,h.nodeId));}let g=t.replaceUntil;if(g!==void 0&&g<=t.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(g!==void 0&&p.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:g}),!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 u=null;p.applyPackage(h=>{let f=Vg(h,i,r.namespaceUri,r.rootLocalName);if(!f.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})`,h;if(u=dh(f.part,r.rootLocalName,r.nodeId),!u)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`,h;let x=Zg(f.pkg,f.part.partName,{id:r.nodeId,label:r.label,data:r.data});return Yg(x,f.part.partName,r.nodeId)?x:(l="store-not-authored",d="the payload node could not be written into the store",h)}),!(l!==null||!u)&&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:u});});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 m=om(e,a);return {ok:true,change:c.change,...m===void 0?{}:{nodeId:m}}}function om(e,t){for(let n of Lc$1(e.part.root))if(!t.has(n.node.id))return n.node.id}function wl(e,t,n){let r=Lc$1(e.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of Tg(e.package,t)){let a=gh(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Fo(e,t){let n=e.part.name,r=wl(e,n,t),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let a of r)i.applyPackage(s=>_g(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 am(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=Ug(r,t,i);if(!a)continue;let s=fh(r,a.itemId),l=$g(r,a.partName,s);if(l.pkg===r&&Xg(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 im(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=Tg(e,t).map(i=>({itemId:i.itemId,nodes:new Map(Xg(e,i.partName).map(a=>[a.id,a]))}));return n.set(t,o),o}function sm(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let i=im(e,n);if(i.length===0)return r;for(let a of Lc$1(o.root))for(let s of i){let l=gh(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 lm(e,t,n){let r=new Map,o=Ug(e,t,n);if(!o)return r;for(let i of Xg(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()),Ca(e,()=>{let s=n(o);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>Da(s))}function dm(e,t,n=El){return Tl(e,n,r=>_o(r,t,e.bodyStore().part.name))}function cm(e,t,n=El){return Tl(e,n,r=>Fo(r,t))}var mt="proposed";function mm(e,t){switch(e){case "revisionInsert":case "revisionMoveTo":return t!=="original";case "revisionDelete":case "revisionMoveFrom":return t!=="proposed";default:return false}}function Lo(e,t=mt,n){let r=[];return nn(e.children,t,n,0,r),r}function $o(e,t,n,r,o=mt,i){let a=[];for(let s of Lo(e,o,i)){let l=t.get(s.id);if(!l||l.end<=l.start)continue;let d=Math.max(l.start,n),c=Math.min(l.end,r);d>=c||a.push({run:s,start:d,end:c});}return a}function nn(e,t,n,r,o){if(!(r>=la)){for(let i of e)if(!(i.kind==="textValue"||i.kind==="paragraphProperties")){if(i.kind==="run"){o.push(i);continue}if(na(i)&&!ka(i.kind)){nn(i.children,t,n,r+1,o);continue}if(ka(i.kind)){let a=Ie(i,"author")??"",s=n?.includesNode?.(i.id,a)??!n?.hiddenAuthors.has(a),l=n&&!s?n.excludedNodeMode?.(i.id,a)??"proposed":t;if(!mm(i.kind,l))continue;nn(i.children,t,n,r+1,o);continue}if(fe(i)){nn(i.children,t,n,r+1,o);continue}if(Fe(i)){let a=He$1(i);a&&nn(a.children,t,n,r+1,o);continue}}}}var Cl=new Set(lg),qn=new Set(kg);function pm(e){return qn.has(e)}function rn(e,t,n){return !e||e.kind==="textValue"?void 0:e.children.find(o=>o.kind===t||o.kind==="generic"&&o.localName===n&&o.namespaceUri===da)}function Jn(e,t){if(!e||e.kind==="textValue")return [];let n=[];for(let r of e.children){if(r.kind==="textValue"||!t.has(r.localName))continue;let o=J$1();for(let i of r.attributes)o[i.localName]=i.value;n.push(Object.keys(o).length>0?{localName:r.localName,attributes:o}:{localName:r.localName});}return n}function um(e,t){let n=Ha(e,t);return Jn(rn(n,"paragraphProperties","pPr"),Cl)}function Ml(e,t){let n=Ha(e,t),r=rn(n,"paragraphProperties","pPr");return Jn(rn(r,"runProperties","rPr"),qn)}function Uo(e,t){let n=Array.isArray(t)?t:[t],r=new Set(n.map(i=>i.localName));return [...e.filter(i=>!r.has(i.localName)),...n]}var fm=new Map([["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","cstheme"]]);function Al(e,t){let n=e.find(o=>o.localName==="rFonts")?.attributes;if(!n)return t;let r={...n,...t.attributes??{}};for(let o of Object.keys(t.attributes??{})){let i=fm.get(o);i&&delete r[i];}return {localName:"rFonts",attributes:r}}function Qn(e){let t=new Map;for(let n of Se(e)){let r=n.formatRunIds&&n.formatRunIds.length>0?n.formatRunIds:n.runId?[n.runId]:[];for(let o of r){let i=t.get(o);i?(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end)):t.set(o,{start:n.start,end:n.end});}}return t}function Dl(e){let t=new Set;for(let n of Se(e))if(n.formatRunIds)for(let r of n.formatRunIds)t.add(r);return t}function Yn(e,t){if(t.localName==="rFonts")return Al(e,t);if(t.localName!=="u")return t;let n=e.find(r=>r.localName==="u")?.attributes;return n?{localName:"u",attributes:{...n,...t.attributes??{}}}:t}function gm(e,t,n){let r=Ml(e,t),o=Array.isArray(n)?n:[n];return Uo(r,o.map(i=>Yn(r,i)))}function hm(e,t){return Array.isArray(t)?t.map(n=>Yn(e,n)):Yn(e,t)}function ym(e,t,n,r,o,i=mt,a){let s=Ha(e,t);if(!s||s.kind!=="paragraph")return [];let l=[],d=Dl(s);for(let c of $o(s,Qn(s),n,r,i,a)){let m=Jn(rn(c.run,"runProperties","rPr"),qn);l.push({start:c.start,end:c.end,properties:Uo(m,hm(m,o)),...d.has(c.run.id)?{targetRunIds:[c.run.id]}:{}});}return l}function xm(e,t,n,r,o=mt,i){let a=Ha(e,t);if(!a||a.kind!=="paragraph"||r<=n)return [];let s=[];for(let l of $o(a,Qn(a),n,r,o,i)){let d=s[s.length-1];d&&l.start<=d.end?d.end=Math.max(d.end,l.end):s.push({start:l.start,end:l.end});}return s}function km(e,t,n,r,o=mt,i){let a=Ha(e,t);if(!a||a.kind!=="paragraph")return [];let s=Qn(a),l=[];for(let d of Lo(a,o,i)){let c=s.get(d.id);if(!c||c.end<=c.start)continue;(r>n?Math.max(c.start,n)<Math.min(c.end,r):c.start<=n&&n<c.end)&&l.push(d);}return l}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 pt(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return Xd$1(e);if(de(e))return "";let t="";for(let n of e.children)t+=pt(n);return t}var $l=new WeakMap;function ut(e,t){return $l.set(e,t),e}function ke(e){return $l.get(e)??[]}function Zn(e){return `${e.kind}-${e.id}`}function Bo(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function Ul(e){return Bo(e)[0]??null}function jo(e,t){let n=Ul(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 Pm(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 Rm=0,Om=1,vm=2;function Im(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?Rm:r===i&&t.offset===e.end.offset?vm:Om}function bm(e,t,n){let r=null;for(let o of Bo(e)){let i=Im(o,t,n);if(i===null)continue;let a=Pm(o,n);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var Ll={comment:0,custom:1,revision:2};function Sm(e,t,n){let r=[];for(let o of e){let i=bm(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?Ll[o.item.kind]-Ll[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function Xh(e,t,n){let o=Sm(e,t,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?Bl(e,o):o:null}function Yh(e,t){return Bl(e,t)}function Bl(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 jl(e,t,n,r){if(!e.some(u=>u.revisionKind==="paragraphMark"))return e;let o=new Map,i=(u,h)=>{if(!(u.kind==="textValue"||h>64))for(let f=0;f<u.children.length;f+=1){let x=u.children[f],y=u.children[f+1];x.kind==="paragraph"&&y?.kind==="paragraph"&&o.set(x.id,y.id),i(x,h+1);}};i(t.root,0);let a=e.map((u,h)=>h),s=u=>{for(;a[u]!==u;)a[u]=a[a[u]],u=a[u];return u},l=new Map,d=new Map,c=(u,h,f)=>JSON.stringify([u.revisionKind==="paragraphMark"?u.markDirection:u.revisionKind,u.author,u.nesting,h,f]),m=(u,h,f)=>{let x=u.get(h);x?x.push(f):u.set(h,[f]);};e.forEach((u,h)=>{if(!(u.readOnly||!["insert","delete","paragraphMark"].includes(u.revisionKind)))for(let f of u.ranges)m(l,c(u,f.start.paragraphId,f.start.offset),h),m(d,c(u,f.end.paragraphId,f.end.offset),h);});let p=(u,h)=>{for(let f of h){let x=e[u].date,y=e[f].date;x!==void 0&&y!==void 0&&!gg(x,y)||(a[s(f)]=s(u));}};e.forEach((u,h)=>{if(!(u.readOnly||u.revisionKind!=="paragraphMark"||!["insert","delete"].includes(u.markDirection??"")))for(let f of u.ranges){p(h,d.get(c(u,f.start.paragraphId,f.start.offset))??[]);let x=o.get(f.end.paragraphId);x&&p(h,l.get(c(u,x,0))??[]);}});let g=new Map;return e.forEach((u,h)=>{let f=s(h),x=g.get(f);x?x.push(u):g.set(f,[u]);}),[...g.values()].map(u=>{if(u.length===1)return u[0];let h=u.flatMap(I=>I.ranges).sort((I,O)=>n.get(I.start.paragraphId)-n.get(O.start.paragraphId)||I.start.offset-O.start.offset),f=u.flatMap(I=>ke(I)).flatMap(I=>{let O=r.get(I);return O?[O]:[]}).sort((I,O)=>n.get(I.range.start.paragraphId)-n.get(O.range.start.paragraphId)||I.range.start.offset-O.range.start.offset),x=u[0],y=u.find(I=>I.revisionKind!=="paragraphMark"),k=[...new Map(u.flatMap(I=>I.addresses).map(I=>[JSON.stringify(I),I])).values()];return ut({...x,id:u.map(I=>I.id).join("+"),revisionKind:y?.revisionKind??"paragraphMark",...y?{markDirection:void 0}:{},addresses:k,ranges:h,text:y?f.map(I=>I.text).join(""):""},u.flatMap(I=>ke(I)))})}function Ho(e){if(!e.propertyChange||!e.parent)return [];let t=(o,i)=>{let a=o?.children.find(s=>s.kind!=="textValue"&&s.namespaceUri===da&&s.localName==="lang");return a&&a.kind!=="textValue"?a.attributes.find(s=>s.namespaceUri===da&&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 Nm=[{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 Vo(e){if(!e.propertyChange||!e.parent)return [];let t=e.node.children.find(r=>r.kind!=="textValue"&&r.namespaceUri===da&&r.localName===e.parent.localName),n=[];for(let r of Nm){let o=a=>{let s=a?.children.find(d=>d.kind!=="textValue"&&d.namespaceUri===da&&d.localName===r.element);if(!s||s.kind==="textValue")return null;let l=s.attributes.find(d=>d.namespaceUri===da&&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 tr(e){return zl(e,true)}function oy(e){return zl(e,false)}function zl(e,t){let n=t?Vl.get(e.root):void 0;if(n)return n;let r=new Map,o=s=>{let l=t?Hl.get(s):void 0;if(l){for(let[c,m]of l)r.set(c,m);return}let d=new Map;Em(s,d,t),t&&Hl.set(s,d);for(let[c,m]of d)r.set(c,m);},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?Wl.get(s):void 0;if(!d){let c=[];Kl(s,0,c,t),d=c,t&&Wl.set(s,d);}for(let[c,m]of d)r.set(c,m);return}if(s.kind==="tableRow"){let d=t?er.get(s):void 0;d||(d=Gl(s),t&&er.set(s,d));for(let[c,m]of d)r.set(c,m);}for(let d of s.children)a(d,l+1);}};return a(e.root,0),t&&Vl.set(e.root,r),r}function Kl(e,t,n,r){if(!(e.kind==="textValue"||t>64)){if(e.kind==="tableRow"){let o=r?er.get(e):void 0;o||(o=Gl(e),r&&er.set(e,o));for(let i of o)n.push(i);}for(let o of e.children)Kl(o,t+1,n,r);}}function Gl(e){let t=null,n=(a,s)=>{if(!(t||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){t=a;return}for(let l of a.children)n(l,s+1);}};if(n(e,0),!t)return wm;let r={paragraphId:t.id,start:0,end:0},o=[],i=(a,s,l)=>{if(a.kind==="textValue"||l>64||a.kind==="paragraph")return;let d=s==="trPr"&&(a.localName==="ins"||a.localName==="del"),c=s==="tcPr"&&(a.localName==="cellIns"||a.localName==="cellDel");(d||c)&&o.push([a.id,r]);for(let m of a.children)i(m,a.localName,l+1);};return i(e,void 0,0),o}var wm=[],Hl=new WeakMap,Vl=vg(8),er=new WeakMap,Wl=new WeakMap;function Em(e,t,n){let r=n?Ue(e):We$1(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 m of s.children)o(m,l,d,c+1);}},i=(s,l)=>{if(s.kind==="textValue"||l>64)return;let d=r.spanOf(s);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 Cm={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function nr(e,t){for(let n of e.attributes)if(n.localName===t&&n.namespaceUri===da)return n.value}function Wo(e){return `${e.id}\0${e.author}\0${e.date??""}`}var Mm={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo"},ql={retainRevisionItems:true,revisionSites:Ih,locations:tr,commentAnchors:xg,deepOrder:Vh};function zo(e){return Jl(e,ql)}function Jl(e,t){let n=e.root.kind!=="paragraph";if(n&&t.retainRevisionItems){let o=Xl.get(e.root);if(o&&o.name===e.name)return o.items}let r=Am(e,t);return n&&t.retainRevisionItems&&Xl.set(e.root,{name:e.name,items:r}),r}var Xl=vg(8);function Am(e,t){let n=t.revisionSites(e);if(n.length===0)return [];let r=t.locations(e),o=n.some(c=>c.paragraphMark),i=new Map,a=new Map;for(let c of n){let m=nr(c.node,"id");if(m===void 0)continue;let p=nr(c.node,"author")??"",g=nr(c.node,"author")===void 0,u=nr(c.node,"date"),h=u===void 0?{id:m,author:p}:{id:m,author:p,date:u},f=c.propertyChange?"format":c.paragraphMark?"paragraphMark":Mm[c.node.kind]??"structural",x=c.paragraphMark?Cm[c.node.localName]:void 0,y=r.get(c.node.id),k=y?{partName:e.name,start:{paragraphId:y.paragraphId,offset:y.start},end:{paragraphId:y.paragraphId,offset:y.end}}:null;o&&k&&(f==="paragraphMark"||f==="insert"||f==="delete")&&i.set(c.node.id,{range:k,text:f==="paragraphMark"?`
|
|
2
|
-
`:pt(c.node)});let I=f==="structural"?`structural\0${Wo(h)}`:`${f}\0${c.node.localName}\0${Wo(h)}`,O=a.get(I);if(O){O.siteNodeIds.push(c.node.id),c.propertyChange&&(O.formattingLanguages=[...new Set([...O.formattingLanguages??[],...Ho(c)])],O.formattingChanges=[...new Map([...O.formattingChanges??[],...Vo(c)].map(v=>[JSON.stringify(v),v])).values()]),k&&!O.ranges.some(v=>v.partName===k.partName&&v.start.paragraphId===k.start.paragraphId&&v.start.offset===k.start.offset&&v.end.paragraphId===k.end.paragraphId&&v.end.offset===k.end.offset)&&O.ranges.push(k),f!=="structural"&&O.revisionKind==="structural"&&(O.revisionKind=f),(f==="insert"&&O.revisionKind==="delete"||f==="delete"&&O.revisionKind==="insert"||O.revisionKind==="replace")&&(O.revisionKind="replace"),O.readOnly||=c.refused||g,c.nesting>O.nesting&&(O.nesting=c.nesting),f==="delete"||f==="moveFrom"?O.deletedText+=pt(c.node):f!=="format"&&f!=="paragraphMark"&&(O.text+=pt(c.node));continue}a.set(I,{address:h,localName:c.node.localName,...c.propertyChange?{formattingLanguages:Ho(c),formattingChanges:Vo(c)}:{},revisionKind:f,...x?{markDirection:x}:{},author:p,...u===void 0?{}:{date:u},text:f==="format"||f==="paragraphMark"||f==="delete"||f==="moveFrom"?"":pt(c.node),deletedText:f==="delete"||f==="moveFrom"?pt(c.node):"",ranges:k?[k]:[],siteNodeIds:[c.node.id],nesting:c.nesting,readOnly:c.refused||g});}let s=[...a.values()].map(c=>ut({kind:"revision",id:`${c.revisionKind}${c.revisionKind==="format"||c.revisionKind==="paragraphMark"?`-${c.localName}`:""}-${e.name}\0${Wo(c.address)}`,address:c.address,addresses:[c.address],revisionKind:c.revisionKind,...c.revisionKind==="format"?{formattingKind:c.localName}:{},...c.formattingChanges?.length?{formattingChanges:c.formattingChanges}:{},...c.formattingLanguages?.length?{formattingLanguages:c.formattingLanguages}:{},...c.markDirection?{markDirection:c.markDirection}:{},author:c.author,...c.date===void 0?{}:{date:c.date},text:c.revisionKind==="replace"?c.text:c.text||c.deletedText,replacedText:c.revisionKind==="replace"?c.deletedText:"",ranges:c.ranges,nesting:c.nesting,readOnly:c.readOnly,replyIds:[]},c.siteNodeIds)),l=t.deepOrder(e),d=Ql(s,l);return Dm(jl(d,e,l,i),l)}function Dm(e,t){let n=Ql(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}`,m=a.get(c);m?m.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}`)??[],m=c.length>1?[...c].sort((p,g)=>(p.text.length>0?0:1)-(g.text.length>0?0:1)):c;for(let p of m){if(o.has(p.id)||p.author!==l.author)continue;o.add(l.id),o.add(p.id);let g=Bm(l.ranges[0],p.ranges[0],t)?l:p,u=Um(l.date,p.date);i.set(l.id,ut({...g,id:`replace-${l.id}-${p.id}`,revisionKind:"replace",...u===void 0?{}:{date:u},addresses:$m([...l.addresses,...p.addresses]),text:p.text,replacedText:l.text,ranges:[...l.ranges,...p.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||p.readOnly},[...ke(l),...ke(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 Ql(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}`,m=o.get(c);m?m.push(d):o.set(c,[d]);}let i=(d,c)=>{let m=d.ranges[0].start,p=c.ranges[0].start,g=(t.get(m.paragraphId)??0)-(t.get(p.paragraphId)??0);return g!==0?g:m.offset-p.offset};for(let d of o.values()){let c=true;for(let m=1;m<d.length&&c;m+=1)c=i(d[m-1],d[m])<=0;c||d.sort(i);}let a=new Set,s=new Map;for(let d of o.values()){let c=[],m="",p=()=>{if(c.length>1){s.set(c[0].id,Fm(c));for(let g=1;g<c.length;g+=1)a.add(c[g].id);}c=[];};for(let g of d){let u=r(g.ranges[0].start);c.length>0&&u!==m&&p();let h=c.length===0;c.push(g),(h||_m(g))&&(m=r(g.ranges[g.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 _m(e){return e.ranges.some(t=>t.start.paragraphId!==t.end.paragraphId||t.start.offset!==t.end.offset)}function Fm(e){let t=e[0],n=[...t.addresses],r=[...t.ranges],o=[...ke(t)],i=t.text,a=t.date;for(let s of e.slice(1)){for(let l of s.addresses)n.some(d=>Zl(d,l))||n.push(l);for(let l of s.ranges)r.push(l);for(let l of ke(s))o.push(l);i+=s.text,a=Lm(a,s.date);}return ut({...t,id:e.map(s=>s.id).join("+"),addresses:n,ranges:r,text:i,...a===void 0?{}:{date:a}},o)}function Lm(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 $m(e){let t=[];for(let n of e)t.some(r=>Zl(r,n))||t.push(n);return t}function Zl(e,t){return e.id===t.id&&e.author===t.author&&(e.date??"")===(t.date??"")}function Um(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 Bm(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 ed(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 m=r.get(c.id);if(!m||m.orphaned||m.start.paragraphId===m.end.paragraphId&&m.start.offset===m.end.offset)continue;let p=`${m.start.paragraphId}:${m.start.offset}|${m.end.paragraphId}:${m.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 m=c.paraId?n.get(c.paraId.toUpperCase()):void 0,p=m?.parentParaId?o.get(m.parentParaId):void 0,g=c.parentCommentId?i.get(c.parentCommentId):void 0,u=m===void 0?s.get(c.id):void 0,h=u?i.get(u):void 0,f=p??g??h;f&&f.id!==c.id&&l.set(c.id,f.id);}for(let c of [...l.keys()]){let m=new Set([c]),p=l.get(c);for(;p!==void 0;){if(m.has(p)){l.delete(c);break}m.add(p),p=l.get(p);}}let d=new Map;for(let[c,m]of l){let p=d.get(m);p?p.push(c):d.set(m,[c]);}return e.map(c=>{let m=r.get(c.id),p=c.paraId?n.get(c.paraId.toUpperCase()):void 0,g=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:m?{partName:m.partName,start:m.start,end:m.end}:null,resolved:p?.done??false,...g===void 0?{}:{parentId:g},replyIds:d.get(c.id)??[],orphaned:m===void 0||m.orphaned}})}function jm(e){return Hm(e,ql)}function Hm(e,t){let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let c of e.furnitureParts??[])r.has(c.name)||(r.add(c.name),n.push(c));let o=e.commentsPart?zg$1(e.commentsPart):[],i=e.commentsExtendedPart?Ag(e.commentsExtendedPart):new Map,a=[],s=[],l=n.length===1?t.deepOrder(n[0]):new Map;for(let c of n){for(let g of Jl(c,t))a.push(g);for(let g of t.commentAnchors(c))s.push(g);if(n.length===1)continue;let m=l,p=m.size;for(let[g,u]of t.deepOrder(c))m.has(g)||m.set(g,p+u);}return td([...a,...ed(o,s,i)]).sort((c,m)=>jo(c,l)-jo(m,l))}function Vm(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 Yl(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function td(e){let t=new Set;for(let l of e)l.kind==="comment"&&t.add(l.id);let n=e.map(l=>Vm(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=Yl(d),m=l.nesting??0,p=r.get(c);(p===void 0||m>p.nesting)&&r.set(c,{id:l.id,nesting:m});}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]),m=[...o.get(l)??[]];for(;m.length>0;){let p=m.shift();c.has(p)||(c.add(p),d.push(p),m.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(Yl(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 m=a.get(d);m?m.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:ut({...l,replyIds:d},ke(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,...m}=l;return m}return l.parentRevisionId===d?l:{...l,parentRevisionId:d}}return l})}var Wm=256,zm=2e3,nd=/[\p{L}\p{N}_]/u;function Ko(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 rd(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&nd.test(r)||o!==void 0&&nd.test(o))}function od(e){return typeof e=="string"&&e.length>0&&e.length<=256}function Km(e,t,n,r={}){let o={matches:[],truncated:false};if(!od(t)||e.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?t:Ko(t),l=i?e:Ko(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),m=[],p=l.indexOf(s,d);for(;p>=0;){let g=p+s.length;if(g>c)return {matches:m,truncated:false};if(!a||rd(e,p,g)){if(m.length>=n)return {matches:m,truncated:true};m.push({start:p,length:s.length});}p=l.indexOf(s,g);}return {matches:m,truncated:false}}var Gm=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),Xm=96;function Go(e,t){return e.kind!=="textValue"&&e.namespaceUri===da&&e.localName===t}function Ym(e){return e.kind==="textValue"&&e.value.trim()===""}function qm(e){let t=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>Xm)return;if(Fe(r)){let s=He$1(r),l=Jc$1(r);if(s&&l&&s.children.every(Ym)&&Gm.has(l.type)){t.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||Go(r,"p");for(let s of r.children)n(s,a,i+1);};return n(e,false,0),t}function Jm(e){return fi(e,"rPr",{kind:"runProperties",children:[fi(e,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function Qm(e){let t=e.find(r=>r.kind==="paragraph"||Go(r,"p"));if(!t||t.kind==="textValue")return null;let n=t.children.filter(r=>r.kind!=="paragraphProperties"&&!Go(r,"pPr"));return n.length>0?n:null}function Xo(e,t){let n=qm(t.root);if(n.length===0)return t;let r=null,o=d=>{if(d!==void 0)return r??=vf(e),r.find(c=>c.name===d)},i=Fa(t,"paste"),a=new Set(Ib(t.root)),s={value:0},l=t;for(let[d,c]of n.entries()){let m=o(c.docPart),p=null;if(m){let x=m.blocks.map((y,k)=>zi$1(Ne$1(y,i),a,`${c.control.id}:placeholder:${d}:${k}`,s));p=c.inline?Qm(x):x;}if(!p){let x=gi(i,ai(c.kind),Jm(i));p=c.inline?[x]:[fi(i,"p",{kind:"paragraph",children:[x]})];}let g=hi(Ge$1(c.control),{showingPlaceholder:true},i),u={...c.content,children:p},h=c.control.children.map(x=>x.id===c.content.id?u:x.kind!=="textValue"&&x.localName==="sdtPr"?g:x),f=Ka(l,c.control.id,h);f.ok&&(l=f.part);}return l}function Zm(e,t,n,r){let o=r??e.root,i=o.kind==="textValue"?e:{...e,root:o},a=zo(i);if(n?.length===0||a.length===0)return {ops:[],result:{resolved:[],skipped:[...new Set(n??[])].map(S=>({key:S,reason:"unknown-revision"})),remaining:a.length}};let s=new Set(n??a.map(Zn)),l=new Map(a.map(S=>[Zn(S),S])),d=new Set;for(let S of s){let b=l.get(S);if(b)for(let A of ke(b))d.add(A);}let c=Ih(i),m=new Map(c.map((S,b)=>[S.node.id,b])),p=c.map((S,b)=>b),g=S=>{for(;p[S]!==S;)p[S]=p[p[S]],S=p[S];return S},u=(S,b)=>{p[g(b)]=g(S);},h=new Map;for(let S of a){let b=ke(S).flatMap(A=>{let _=m.get(A);return _===void 0?[]:[_]});for(let A of b)u(b[0],A);}let f=new Map,x=new Map;for(let[S,b]of c.entries()){if(t==="reject"&&b.propertyChange&&b.parent&&d.has(b.node.id))for(let H of b.parent.children)(b.node.localName==="pPrChange"?ig(H,"rPr")||ig(H,"sectPr"):Ee(H))||h.set(H.id,S);let A=t==="accept"?b.node.localName==="del"||b.node.localName==="moveFrom":b.node.localName==="ins"||b.node.localName==="moveTo";if(b.paragraphMark&&b.parent&&A&&d.has(b.node.id)){let H=Ia(e,b.parent.id),G=H&&Ia(e,H.id),te=G&&Ia(e,G.id);if(H&&G&&te){let de=x.get(te.id);de||(de=Eh(te.children),x.set(te.id,de)),de.has(G.id)&&h.set(H.id,S);}}if(!((b.node.localName==="ins"||b.node.localName==="del")&&b.parent?.localName==="trPr")&&b.node.localName!=="cellIns"&&b.node.localName!=="cellDel")continue;let _=b.node;for(;_&&_.kind!=="tableRow";)_=Ia(e,_.id);if(_){let H=f.get(_.id)??[];H.length&&u(m.get(H[0].node.id),S),H.push(b),f.set(_.id,H);}}let y=new Map;for(let[S,b]of f){let A=Lh(e,b);if(typeof A=="string")continue;if(A.get(S)?.kind===(t==="accept"?"del":"ins")&&b.every(G=>d.has(G.node.id))){h.set(S,m.get(b[0].node.id));let G=Ia(e,S);G?.kind==="table"&&y.set(G.id,G);}}let k=(S,b)=>{let A=m.get(S.id),_=h.get(S.id);A!==void 0&&_!==void 0&&u(_,A);let H=A??_;H!==void 0&&b!==void 0&&u(b,H);let G=H??b;if(S.kind!=="textValue")for(let te of S.children)k(te,G);};k(o);for(let S of Kh(o).values()){let b=S.wrappers.flatMap(A=>{let _=m.get(A.id);return _===void 0?[]:[_]});for(let A of b)u(b[0],A);}let I=new Map;for(let[S,b]of c.entries()){let A=g(S),_=I.get(A)??[];_.push(b),I.set(A,_);}let O=new Map;for(let[S,b]of I)b.some(A=>A.refused||t==="reject"&&A.propertyChange&&Gh(A.node)===null)||typeof Lh(e,b)=="string"?O.set(S,"unsupported-revision"):b.some(A=>!d.has(A.node.id))&&O.set(S,"incomplete-group");for(let S of a)if(S.readOnly)for(let b of ke(S)){let A=m.get(b);A!==void 0&&O.set(g(A),"unsupported-revision");}let v=false;for(let S of y.values()){if(S.kind!=="table")continue;let b=S.children.filter(A=>A.kind==="tableRow");b.length&&b.every(A=>{let _=h.get(A.id);return _!==void 0&&!O.has(g(_))})&&(h.set(S.id,h.get(b[0].id)),v=true);}if(v){k(o);for(let[S,b]of [...O]){let A=g(S);O.get(A)!=="unsupported-revision"&&O.set(A,b);}}let D=[],U=[],Y=new Set;for(let S of s){let b=l.get(S);if(!b){U.push({key:S,reason:"unknown-revision"});continue}let A={key:S,author:b.author,partName:e.name,revisionKind:b.revisionKind},_=ke(b),H;for(let G of _){let te=m.get(G);if(H=te===void 0?"incomplete-group":O.get(g(te)),H)break}if(_.length||(H="unsupported-revision"),H)U.push({key:S,reason:H,revision:A});else {D.push(A);for(let G of _)Y.add(G);}}return {ops:Y.size?[{op:t==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:[...Y],...r?{scopeRootId:r.id}:{}}]:[],result:{resolved:D,skipped:U,remaining:a.length-D.length}}}function Yo(e){return e.kind!=="textValue"}function rr(e,t){for(let n of e.children)if(Yo(n)&&n.localName===t)return n;return null}function ep(e,t){let n=[e];for(;n.length>0;){let r=n.pop();if(Yo(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 ld=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function At(e,t,n){let r=rr(e,t),i=(r?rr(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&ld.test(i)?i:null}var ad=new WeakMap;function tp(e){let t=e?ad.get(e):void 0;if(t)return t;let n=e?ep(e,"fontScheme"):null;if(!n)return dd;let r=Object.freeze({major:At(n,"majorFont","latin"),minor:At(n,"minorFont","latin"),majorEastAsia:At(n,"majorFont","ea"),minorEastAsia:At(n,"minorFont","ea"),majorBidi:At(n,"majorFont","cs"),minorBidi:At(n,"minorFont","cs"),...ap(n)});return e&&ad.set(e,r),r}var id=new WeakMap,dd=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null});function qo(e,t=null){let n=e?tp(e):dd,r=t?rr(t,"themeFontLang"):null;if(!r||!t)return n;let o=id.get(t);o||id.set(t,o=new WeakMap);let i=o.get(n);if(i)return i;let a=g=>r.attributes.find(u=>u.localName===g)?.value,s=sd(a("val")),l=sd(a("bidi")),d=a("eastAsia"),c=or(d),m=(g,u,h)=>u&&(g?n.majorSupplemental:n.minorSupplemental)?.[u]||h||null,p=Object.freeze({major:m(true,s,n.major),minor:m(false,s,n.minor),majorEastAsia:m(true,c,n.majorEastAsia),minorEastAsia:m(false,c,n.minorEastAsia),majorBidi:m(true,l,n.majorBidi),minorBidi:m(false,l,n.minorBidi),...d===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,p),p}var np=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 Tx(e,t,n){if(e===void 0)return null;let r=np.get(e)?.(t)??null;if(r!==null)return r;let o=or(n);return o?(e==="majorEastAsia"?t.majorSupplemental:e==="minorEastAsia"?t.minorSupplemental:void 0)?.[o]??null:null}function or(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 rp=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function sd(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):or(e)??rp.get(t[0])??null}var op=new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]);function Cx(e){return op.get(or(e)??"")??null}function ap(e){let t={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of rr(e,n)?.children??[]){if(!Yo(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&&ld.test(s)&&(o[a]=s);}Object.keys(o).length&&(t[r]=Object.freeze(o));}return t}var ft=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Jo(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 Hx(e){let t=ec$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 Zt(t.package,Xo(t.package,Lb(n)));return {ok:true,view:ip(r)}}function ip(e){let t=()=>e.currentPackage(),n=()=>e.bodyStore().part,r=(d,c)=>Jo(t(),t().mainDocumentPart,d,c)?.root??null,o=Object.freeze(qo(null)),i=null,a=Kg,s=null;return Object.freeze({part:n,currentPackage:t,packageRevision:()=>e.packageRevision,stylesRoot:()=>r(ft.styles,"/word/styles.xml"),numberingRoot:()=>r(ft.numbering,"/word/numbering.xml"),settingsRoot:()=>r(ft.settings,"/word/settings.xml"),documentThemeFonts(){let d=t();return i!==d&&(o=Object.freeze(qo(r(ft.theme,"/word/theme/theme1.xml"),r(ft.settings,"/word/settings.xml"))),i=d),o},documentProperties(){let d=t();if(s!==d){let c=Jo(d,"/",ft.coreProperties,"/docProps/core.xml"),m=Jo(d,"/",ft.extendedProperties,"/docProps/app.xml");a=Lg(c?.root??null,m?.root??null),s=d;}return a},headerFooterPartsBySection:()=>Qd$1(t()),headerFooterResolutionBySection:()=>Pd$1(t()),relationshipTarget:d=>Af(t(),n().name,d)})}
|
|
3
|
-
export{rm as $,Hx as $a,Kt as A,xm as Aa,Vr as B,km as Ba,Wr as C,_l as Ca,zr as D,Fl as Da,Kr as E,ke as Ea,Gr as F,Zn as Fa,bd as G,Bo as Ga,Mi as H,Ul as Ha,zd as I,jo as Ia,po as J,Sm as Ja,fs as K,Xh as Ka,uo as L,Yh as La,lt as M,tr as Ma,ll as N,oy as Na,Zt as O,zo as Oa,cl as P,ed as Pa,ml as Q,jm as Qa,Oo as R,Hm as Ra,zg as S,td as Sa,Io as T,Wm as Ta,Ao as U,zm as Ua,Do as V,Ko as Va,Qc as W,rd as Wa,Zc as X,od as Xa,em as Y,Km as Ya,tm as Z,Xo as Za,nm as _,Zm as _a,qo as a,Sl as aa,ip as ab,Tx as b,Nl as ba,Cx as c,_o as ca,md as d,Fo as da,Si as e,am as ea,wn as f,sm as fa,ot as g,lm as ga,En as h,dm as ha,Tn as i,cm as ia,pe as j,mt as ja,gd as k,Lo as ka,at as l,$o as la,Wt as m,Cl as ma,Cn as n,qn as na,zt as o,pm as oa,Mn as p,rn as pa,$r as q,Jn as qa,Ur as r,um as ra,Br as s,Ml as sa,kd as t,Uo as ta,Pd as u,Al as ua,Hr as v,Qn as va,wi as w,Dl as wa,Rd as x,Yn as xa,jr as y,gm as ya,Od as z,ym as za};
|