@docx-editor.dev/core 2.31.0 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +16 -16
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +17 -15
- package/dist/binding.js +1 -1
- package/dist/{chrome-print-BWvaVEhD.d.ts → chrome-print-CznJ0ucN.d.ts} +58 -23
- package/dist/chunk-25EXMBV2.cjs +5 -0
- package/dist/chunk-2CWQY27B.cjs +1 -0
- package/dist/chunk-3IEXDEFH.cjs +7 -0
- package/dist/chunk-65XBN67F.cjs +2 -0
- package/dist/{chunk-5JPIEN54.cjs → chunk-6NVZNB7O.cjs} +2 -2
- package/dist/chunk-6UDJUI3W.cjs +2 -0
- package/dist/chunk-ACLR4DMK.js +1 -0
- package/dist/{chunk-2E2RPEKX.js → chunk-B2BEELUE.js} +1 -1
- package/dist/chunk-DDFHKQFU.js +30 -0
- package/dist/{chunk-MOYYRVFV.cjs → chunk-E4IAO4CY.cjs} +1 -1
- package/dist/chunk-ETDZFNMI.js +2 -0
- package/dist/chunk-FDSL5OJU.cjs +30 -0
- package/dist/chunk-FS7CMYLT.js +4 -0
- package/dist/chunk-GDS24SZN.js +30 -0
- package/dist/chunk-GIY6NT2X.js +5 -0
- package/dist/chunk-GWM3AKUD.js +18 -0
- package/dist/chunk-HDOXACHP.js +2 -0
- package/dist/chunk-IILEENID.js +1 -0
- package/dist/chunk-L5TYBFDB.js +1 -0
- package/dist/chunk-MNF2K7NN.cjs +30 -0
- package/dist/chunk-O324RB6R.cjs +1 -0
- package/dist/chunk-OKMEMSKB.cjs +1 -0
- package/dist/chunk-QXJKYNYZ.js +1 -0
- package/dist/chunk-RALTVLB6.js +2 -0
- package/dist/chunk-SRVKFUFI.js +3 -0
- package/dist/chunk-TELQ52LG.cjs +1 -0
- package/dist/chunk-TJHE5EET.cjs +1 -0
- package/dist/chunk-UMMRURPE.js +7 -0
- package/dist/chunk-WN7ICTA5.js +1 -0
- package/dist/{chunk-XSTGE3NI.cjs → chunk-XJYZVGQR.cjs} +1 -1
- package/dist/chunk-ZGTIE3QJ.cjs +4 -0
- package/dist/chunk-ZOZI27AW.cjs +18 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +20 -4
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.cjs +1 -1
- package/dist/collaboration.d.ts +5 -5
- package/dist/collaboration.js +1 -1
- package/dist/contracts/document.d.ts +3 -3
- package/dist/contracts/editor.d.ts +13 -9
- package/dist/contracts/interaction.d.ts +2 -2
- package/dist/contracts/modules.d.ts +15 -12
- package/dist/contracts/types.d.ts +135 -2
- package/dist/{custom-node-writes-TeUvMP13.d.ts → custom-node-writes-CLJKGD9t.d.ts} +7 -2
- package/dist/{diagnostic-context-DJ0P1uZE.d.ts → diagnostic-context-BtDUY3v2.d.ts} +1 -1
- package/dist/{diagnostic-hints-C9JlLz1L.d.ts → diagnostic-hints-DK8-V0fk.d.ts} +2 -2
- package/dist/{document-protection-C8x3P2J6.d.ts → document-protection-NaniLHWF.d.ts} +1 -1
- package/dist/{editor-B2ShlO23.d.ts → editor-DZwOTmlR.d.ts} +104 -239
- package/dist/editor-fonts-D_-vjuJi.d.ts +53 -0
- package/dist/{editor-scope-C7ke1KJG.d.ts → editor-scope-B3L-1ALc.d.ts} +1 -1
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +2 -2
- package/dist/editor.d.ts +74 -30
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +9 -15
- package/dist/export.js +1 -1
- package/dist/{failure-NS2lsya4.d.ts → failure-6KGFrDO9.d.ts} +1 -1
- package/dist/{font-resolver-CWh40DYp.d.ts → font-resolver-BlQNGdvR.d.ts} +1 -1
- package/dist/{headless-document-view-qOpaCF82.d.ts → headless-document-view-Bcz9_Qva.d.ts} +115 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +27 -25
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-CWS3j0Xr.d.ts → layout-shaping-E5J4Z1Gf.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +24 -17
- package/dist/layout.js +1 -1
- package/dist/{note-properties-QsKh24sM.d.ts → note-properties-Ds5R2_3F.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +11 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-COZJUKUY.d.ts → protocol-DKa4qt7F.d.ts} +75 -5
- package/dist/{review-paragraph-order-C_QbCKcH.d.ts → review-paragraph-order-Dc17w_6v.d.ts} +1 -1
- package/dist/revision-projection-Cn6rZJ7H.d.ts +258 -0
- package/dist/{semantic-cell-selection-Cub9FDa8.d.ts → semantic-cell-selection-BaUR0iJ4.d.ts} +2 -2
- package/dist/{semantic-interaction-dApRIYpt.d.ts → semantic-interaction-CJoHLoOl.d.ts} +1 -1
- package/dist/{semantic-paint-DLzA8sjP.d.ts → semantic-paint-BPw_n0li.d.ts} +7 -4
- package/dist/{semantic-record-queries-3yp9o11g.d.ts → semantic-record-queries-C0rJ3sB4.d.ts} +1 -1
- package/dist/{semantic-records-B-akgRch.d.ts → semantic-records-BvN-WWst.d.ts} +216 -406
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +13 -14
- package/dist/store.js +1 -1
- package/dist/{types-barrel-CkF2JbU4.d.ts → tree-op-types-C_S2niXW.d.ts} +117 -26
- package/dist/{tree-package-store-B8l8DX3Z.d.ts → tree-package-store-CRHvMyNj.d.ts} +2 -2
- package/dist/{tree-session-contract-DeLRqohz.d.ts → tree-session-contract-D1awo_dA.d.ts} +5 -5
- package/dist/unsupported-elements-CVos5cqe.d.ts +23 -0
- package/docs/accept-reject-without-scrolling.md +95 -0
- package/docs/comment-on-found-text.md +72 -0
- package/docs/custom-review-cards.md +178 -0
- package/docs/highlight-ranges.md +48 -0
- package/docs/index.md +36 -0
- package/docs/propose-rewrite.md +247 -0
- package/docs/tracked-replacement.md +68 -0
- package/package.json +3 -2
- package/dist/chunk-243W4WW2.cjs +0 -2
- package/dist/chunk-4S24UOPG.js +0 -30
- package/dist/chunk-5SO5QDMV.cjs +0 -2
- package/dist/chunk-6IDOVU6L.cjs +0 -1
- package/dist/chunk-6JIJOZDW.js +0 -1
- package/dist/chunk-BTQKU64Q.cjs +0 -1
- package/dist/chunk-DBOOTED4.cjs +0 -30
- package/dist/chunk-EOTAXOJY.cjs +0 -5
- package/dist/chunk-FDAKJ2SJ.cjs +0 -30
- package/dist/chunk-FNNOJNGY.js +0 -3
- package/dist/chunk-FT33HRZP.js +0 -5
- package/dist/chunk-HC6YNKUI.cjs +0 -1
- package/dist/chunk-HZ66UCIS.js +0 -2
- package/dist/chunk-IBRBNT37.cjs +0 -1
- package/dist/chunk-IVIN7X43.js +0 -30
- package/dist/chunk-LZY6B6IV.js +0 -4
- package/dist/chunk-N6B3BXCL.js +0 -1
- package/dist/chunk-Q5K2GGNG.js +0 -2
- package/dist/chunk-R2XINWVE.js +0 -7
- package/dist/chunk-SUEXVBPR.js +0 -1
- package/dist/chunk-T2QQHG5C.js +0 -18
- package/dist/chunk-VWIJKH4A.js +0 -1
- package/dist/chunk-WO4V6PNS.cjs +0 -18
- package/dist/chunk-XMJKFURD.cjs +0 -4
- package/dist/chunk-YQWMI6J5.cjs +0 -7
- package/dist/chunk-ZCJS7D7S.js +0 -2
- package/dist/omml-equation-BsLAa2lX.d.ts +0 -115
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {h,i,u,k,p,o,n,v,w,pa,aj,tg,Ql as Ql$1,qh,Pe,_d as _d$1,H,Qe as Qe$1,W,F,Zd as Zd$1,hl as hl$1,eg,Mb,Qb,ki,Za,Ne,Ma,Xe,We,Ve as Ve$1,Je as Je$1,Ra,Sa,pj,Lb,sf,g,fh,sj,tj,kj,Ka,Ye,Ul as Ul$1,ji as ji$1,Vl as Vl$1,si,wi as wi$1,hi,ii,_g,$g,N,Ib,Sl as Sl$1,X as X$1,hg,Ob,Jb,Cb,ab,be,ce,li,ee,ui,vi,dc as dc$1,Ri,Mi as Mi$1,Wi as Wi$1,Qi as Qi$1,Pi,Ki as Ki$1,Zi as Zi$1,Li as Li$1,Yi as Yi$1,Si,Oi,Va,Db,Fb,Hb,jg,Nb,Gk,zk,Fk,Hk,cg,$a,sk,Aj,lk,Fj,Ej,Cj,ok,fk,ck,Ya,jk,gk,hk,Xa,$j,nk,ik,ek,bk,pk,Vg,mf,nf,Ci as Ci$1,Bi as Bi$1,E,Fa,Ug,f,Be as Be$1,Te,Ek,uj,wj,yj,Ml as Ml$1,Rl as Rl$1,Qg,Sk,Pk,_a,pg,fd as fd$1,bb,De as De$1,ye,Ae,Ee,Ge,ul as ul$1,He,Ed as Ed$1,de,Ji as Ji$1,Eb,ua,zb,ke,xe,dk as dk$1,Pb,Kb,Rk,Ud as Ud$1,Md as Md$1,Nd as Nd$1,Pd as Pd$1,O,Ia,l,Ja,C,bg,dg,bc as bc$1,Dk,Ck,rg,Ch,Dh,Qd as Qd$1,Ha,Y,ea,Qk,Wg,Dl as Dl$1,El as El$1,qa,ve,we as we$1,ue}from'./chunk-GWM3AKUD.js';import {strFromU8,strToU8}from'fflate';var lc=["extension","capability","command","query","schema","dependencyKey","runtimePort","result","origin"],cc=/^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)+$/,dc=/^@[a-z0-9.-]+\/[a-z0-9.-]+(?:#[a-z0-9]+(?:[/._-][a-z0-9]+)*)?$/;function Ei(t){return cc.test(t)||dc.test(t)}function Cn(t,e){if(!Ei(t))throw new Error(`invalid ${e??"registry"} id ${JSON.stringify(t)}: must be reverse-domain (dev.docx-editor.core.x) or package-owned (@scope/pkg#kind/name)`)}var mc=/^(\d+)\.(\d+)\.(\d+)$/;function mt(t){let e=mc.exec(t);if(!e)throw new Error(`invalid semantic version: ${JSON.stringify(t)}`);return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3])}}function Mn(t,e){return t.major!==e.major?t.major<e.major?-1:1:t.minor!==e.minor?t.minor<e.minor?-1:1:t.patch!==e.patch?t.patch<e.patch?-1:1:0}function An(t,e){let n=mt(t),r=e.trim();if(r==="*")return true;if(r.startsWith("^")){let o=mt(r.slice(1));return Mn(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(e)}`);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(e)}`);let l=mt(a.slice(s.length)),c=Mn(n,l);s===">="?i=i&&c>=0:i=i&&c<0;}return i}return Mn(n,mt(r))===0}var ge=class extends Error{constructor(n,r,o=[]){super(r);this.code=n;this.responsible=o;this.name="RegistryError";}code;responsible},Dr=(t,e)=>`${t}:${e}`;function uc(t,e={}){let n=new Map;for(let c of t){if(Cn(c.id,"extension"),Ti(c.version,c.id),n.has(c.id))throw new ge("duplicate-extension",`duplicate extension id ${c.id}`,[c.id]);n.set(c.id,c);for(let d of c.contributions)Cn(d.id,d.kind),Ti(d.version,`${c.id} \u2192 ${d.id}`),d.replaces&&gc(d.replaces.targetRange,`${c.id} \u2192 replaces ${d.replaces.targetId}`);}for(let c of t){for(let d of c.dependencies??[])if(!n.has(d))throw new ge("missing-dependency",`${c.id} requires missing extension ${d}`,[c.id,d]);for(let d of c.conflicts??[])if(n.has(d)){let u=[c.id,d].sort();throw new ge("conflict",`extensions ${u[0]} and ${u[1]} conflict`,u)}}fc(n);let r=new Set(e.availablePorts??[]);for(let c of t)for(let d of c.contributions)d.kind==="runtimePort"&&r.add(d.id);for(let c of t)for(let d of c.requiredPorts??[])if(!r.has(d))throw new ge("missing-port",`${c.id} requires unavailable port ${d}`,[c.id,d]);let o=new Map,i=new Map,a=new Map;for(let c of t)for(let d of c.contributions){let u=Dr(d.kind,d.id);if(d.replaces){let m=Dr(d.kind,d.replaces.targetId),f=a.get(m)??[];f.push({ext:c.id,c:d}),a.set(m,f);continue}if(i.has(u)){let m=[o.get(u),c.id].sort();throw new ge("id-collision",`${d.kind} id ${d.id} registered by both ${m[0]} and ${m[1]}`,m)}i.set(u,d),o.set(u,c.id);}let s=new Map(i);for(let[c,d]of a){let u=i.get(c);if(!u){let h=d[0];throw new ge("replacement-target-missing",`${h.ext} replaces missing target ${h.c.replaces.targetId}`,[h.ext,h.c.replaces.targetId])}let m=u.replaceable??{kind:"none"};for(let{ext:h,c:b}of d){if(!An(u.version,b.replaces.targetRange))throw new ge("replacement-version-mismatch",`${h} replaces ${b.replaces.targetId}@${u.version} outside range ${b.replaces.targetRange}`,[h,b.replaces.targetId]);if(m.kind==="none")throw new ge("unauthorized-replacement",`${b.replaces.targetId} does not authorize replacement (attempted by ${h})`,[h,b.replaces.targetId])}let f=pc(u,d);s.set(c,f);}return {extensions:n,contributions:s,get:(c,d)=>s.get(Dr(c,d))}}function pc(t,e){let n=t.replaceable??{kind:"none"};if(e.length===1)return e[0].c;if(n.kind==="priority"){let o=[...e].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 ge("ambiguous-replacement",`multiple replacers of ${t.id} share top priority ${i}: ${s.join(", ")}`,s)}return o[0].c}let r=e.map(o=>o.ext).sort();throw new ge("ambiguous-replacement",`multiple replacers of ${t.id}: ${r.join(", ")}`,r)}function fc(t){let o=new Map,i=[],a=s=>{o.set(s,1),i.push(s);let l=[...t.get(s)?.dependencies??[]].sort();for(let c of l){let d=o.get(c)??0;if(d===1){let u=i.indexOf(c),m=[...i.slice(u),c];throw new ge("dependency-cycle",`dependency cycle: ${m.join(" -> ")}`,m)}d===0&&a(c);}i.pop(),o.set(s,2);};for(let s of [...t.keys()].sort())(o.get(s)??0)===0&&a(s);}function Ti(t,e){try{mt(t);}catch{throw new ge("invalid-version",`invalid version ${JSON.stringify(t)} in ${e}`,[e])}}function gc(t,e){try{An("0.0.0",t);}catch{throw new ge("invalid-version",`invalid version range ${JSON.stringify(t)} in ${e}`,[e])}}var ut=class extends Error{constructor(e){super(e),this.name="BudgetError";}},Vt=class t{constructor(e,n){this.label=e;this.capacity=n;this.used=new u(`${e}.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(e){this.assertLive(),this.used.add(e),this.activeReservations+=1;let n=false,r=this;return {amount:e,get released(){return n},release(){n||(n=true,r.used.release(e),r.activeReservations-=1);}}}child(e,n){this.assertLive(),this.used.add(n);let r=new t(e,n);return r.parent=this,r.carveAmount=n,this.children.add(r),r}onRelease(e){this.assertLive(),this.cleanups.push(e);}dispose(){if(this.disposed)return;if(this.children.size>0)throw new ut(`${this.label}: cannot release with ${this.children.size} child budget(s) outstanding`);if(this.activeReservations>0)throw new ut(`${this.label}: cannot release with ${this.activeReservations} reservation(s) outstanding`);let e=[];for(let n=this.cleanups.length-1;n>=0;n--)try{this.cleanups[n]();}catch(r){e.push(r);}if(this.disposed=true,this.parent&&(this.parent.children.delete(this),this.parent.used.release(this.carveAmount),this.parent=void 0),e.length>0)throw new ut(`${this.label}: ${e.length} cleanup error(s); first: ${String(e[0])}`)}assertLive(){if(this.disposed)throw new ut(`${this.label}: budget already released`)}};var Dn=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(e){this._cancelled=true,e!==void 0&&(this._reason=e);}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 e=this;return {get isCancelled(){return e._cancelled},get phase(){return e._phase},get derivedOnly(){return e.derivedOnly},checkpoint(){if(e._cancelled)throw new Dn(e.derivedOnly,e._reason)}}}};var _n=class extends Error{constructor(n){super(`runtime port not available: ${n}`);this.portId=n;this.name="PortResolutionError";}portId},_r=class{ports=new Map;provide(e,n){return this.ports.set(e,n),this}has(e){return this.ports.has(e)}resolve(e){if(!this.ports.has(e))throw new _n(e);return this.ports.get(e)}missing(e){return e.filter(n=>!this.ports.has(n))}availablePorts(){return [...this.ports.keys()]}clock(){return this.resolve(k.clock)}identity(){return this.resolve(k.identity)}},Fr=class{constructor(e=0,n=1){this.step=n;this.t=e;}step;t;now(){let e=this.t;return this.t+=this.step,e}},Lr=class{constructor(e="id"){this.prefix=e;}prefix;n=0;newId(){return this.n+=1,`${this.prefix}-${this.n}`}};function hc(t){let e=p(t.limits),n=Object.freeze({...t.config??{}}),r=t.capacity??e.maxDecompressedBytes,o=t.id??"op",i={id:o,limits:e,config:n,ports:t.ports,budget:new Vt(`op:${o}`,r),cancellation:new zt};return Object.freeze(i)}function yc(t){t.budget.dispose();}var Ur=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(Ur);function xc(t,e){return new u(`${Ur[e].phase}:${e}`,t[e])}var Hr=class{counter;current=0;peak=0;constructor(e){this.counter=new u("memory",e);}allocate(e){this.counter.add(e),this.current+=e,this.current>this.peak&&(this.peak=this.current);}free(e){this.counter.release(e),this.current=Math.max(0,this.current-e);}get currentBytes(){return this.current}get peakBytes(){return this.peak}reset(){this.counter.release(this.current),this.current=0;}};function kc(){for(let t of wi){let e=o[t],n$1=n[t];if(!Number.isFinite(e)||e<=0)throw new Error(`default ${t} must be finite > 0`);if(!Number.isFinite(n$1)||n$1<=0)throw new Error(`ceiling ${t} must be finite > 0`);if(e>n$1)throw new Error(`default ${t} exceeds ceiling`)}}var De="dev.docx-editor.core.comparator",$r={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 Br(t,e,n,r={}){let o=$r[t];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:Ci(e,n,r.epsilon)}}case "exact":case "canonical-exact":{let i=o.mode==="canonical-exact"?new Set(o.ephemera):new Set,a=v(e,i),s=v(n,i);return a===s?{equal:true}:{equal:false,left:a,right:s}}}}function jr(t,e){let n=$r[t];if(n.mode==="tolerance"||n.mode==="sync-optimization-only")throw new Error(`${n.id} has no canonical fingerprint (${n.mode})`);let r=n.mode==="canonical-exact"?new Set(n.ephemera):void 0;return w(e,r)}function Ci(t,e,n){return typeof t=="number"&&typeof e=="number"?Number.isFinite(t)&&Number.isFinite(e)&&Math.abs(t-e)<=n:Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((r,o)=>Ci(r,e[o],n)):false}var Ai=new Set([...h,...i]),Mi=/^[0-9a-f]{16}$/,Pc=/^[0-9a-f]*$/;function Vr(t){let e=[],n=o=>e.push(o);t.formatVersion!==1&&n(`unsupported formatVersion ${t.formatVersion}`),t.documentId||n("documentId is required"),t.source.kind==="docx"&&!/^[0-9a-f]{64}$/.test(t.source.sha256)&&n("docx source requires a 64-hex sha256");let r=-1;t.steps.forEach((o,i)=>{let a=`step[${i}]`;Ai.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&&Oc(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&&!Mi.test(s.authoredStateHash)&&n(`${a}: authoredStateHash must be 16-hex`),s.outputHash!==void 0&&!Mi.test(s.outputHash)&&n(`${a}: outputHash must be 16-hex`);});for(let o of [...t.snapshots??[],...t.updates??[]])o.documentId!==t.documentId&&n(`envelope documentId ${o.documentId} != ${t.documentId}`),Pc.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:e.length===0,errors:e}}function Oc(t,e,n){Ai.has(t.origin)||n(`${e}: modelChange origin ${t.origin} unknown`),t.toRevision<=t.fromRevision&&n(`${e}: modelChange revision must advance`);}function bc(t,e){let n=Vr(t);if(!n.valid)return {ok:false,mismatches:n.errors};let r=[];return e.init(t),t.steps.forEach((o,i)=>{let a=`step[${i}]`,s=e.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 {Br("authoredState",s.authoredState,s.authoredState).equal||r.push(`${a}: authored state is not self-consistent`);let d=Di(s.authoredState);d!==l.authoredStateHash&&r.push(`${a}: authoredStateHash ${d} != expected ${l.authoredStateHash}`);}}),{ok:r.length===0,mismatches:r}}function Di(t){return jr("authoredState",t)}var Sc="urn:schemas-microsoft-com:office:office";function Rc(t){return t.kind==="textValue"||t.namespaceUri!==pa?false:t.localName==="object"?true:t.localName==="pict"&&t.children.some(e=>e.kind!=="textValue"&&e.namespaceUri===Sc&&e.localName==="OLEObject")}function Gt(t){let e=[...t];for(;e.length;){let n=e.pop();if(n.kind!=="textValue"){if(Rc(n))return true;for(let r of n.children)e.push(r);}}return false}var _i=24,Ln=Object.freeze([Object.freeze({localName:"kern",attributes:Object.freeze({val:"2"})}),Object.freeze({localName:"sz",attributes:Object.freeze({val:String(_i)})}),Object.freeze({localName:"szCs",attributes:Object.freeze({val:String(_i)})})]),Hn=Object.freeze([Object.freeze({localName:"spacing",attributes:Object.freeze({after:"160",line:"278",lineRule:"auto"})})]),Li=Object.freeze({run:true,paragraph:true}),Hi=Object.freeze({run:false,paragraph:false});function Ui(t){if(!t)return Li;let e=n=>t.children.some(r=>r.kind!=="textValue"&&r.namespaceUri===pa&&r.localName===n);return {run:!e("rPrDefault"),paragraph:!e("pPrDefault")}}function zr(t,e){return t&&t.namespaceUri!==pa?Hi:Ui(e)}function Lu(t){return t?t.namespaceUri!==pa?Hi:Ui(Ic(t)):Li}function Fn(t,e,n,r){return {id:n,kind:t,namespaceUri:pa,localName:e,prefix:"w",namespaceBindings:[],attributes:[],children:r}}function Fi(t,e){let n=t==="rPr"?Ln:Hn;return Fn(t==="rPr"?"runProperties":"paragraphProperties",t,`${e}-${t}`,n.map(r=>aj(r,`${e}-${t}-${r.localName}`)))}function Ic(t){let e=t.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===pa&&n.localName==="docDefaults");return e&&e.kind!=="textValue"?e:void 0}function $i(t,e,n){let r=zr(t,e);if(!r.run&&!r.paragraph)return e;let o=[];r.run&&o.push(Fn("generic","rPrDefault",`${n}-rPrDefault`,[Fi("rPr",n)])),r.paragraph&&o.push(Fn("generic","pPrDefault",`${n}-pPrDefault`,[Fi("pPr",n)]));let i=r.run?[...o,...e?.children??[]]:[...e?.children??[],...o];return e?{...e,children:i}:Fn("generic","docDefaults",`${n}-docDefaults`,i)}var pt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Nc="http://schemas.openxmlformats.org/package/2006/relationships",vc="http://schemas.openxmlformats.org/drawingml/2006/main",Vi="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",zi="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",Gi="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Wi="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",Ki="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",Gr="application/vnd.openxmlformats-package.relationships+xml",Wr=`${pt}/styles`,Kr=`${pt}/numbering`,Xi=`${pt}/footnotes`,Yi=`${pt}/endnotes`,qi=`${pt}/officeDocument`,Ec=`${pt}/theme`;function we(t){return t.kind!=="textValue"}function Bi(t,e){return {...t,children:e}}function Je(t,e){if(e(t),t.kind!=="textValue")for(let n of t.children)Je(n,e);}var Tc=new Set(["pStyle","rStyle","tblStyle"]);function Xr(t,e){for(let n of t)Je(n,r=>{if(r.kind!=="textValue"&&Tc.has(r.localName)&&r.namespaceUri===pa){let o=eg(r,"val");o&&e.add(o);}});}function Yr(t,e){for(let n of t)Je(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===pa){let o=eg(r,"val");o&&e.add(o);}});}function qr(t){let e=new Set;return Wt(t,e),e}function Wt(t,e){for(let n of t)Je(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===pt&&o.value.length>0&&e.add(o.value);});}function Ie(t){return /^\d+$/.test(t)?t.replace(/^0+(?=\d)/,""):t}function $n(t,e){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)Je(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",c=eg(s,"id");if(c===void 0)return;let d=Ie(c);n[l].has(d)||(n[l].add(d),r.push({kind:l,id:d}));});};for(o(t);r.length>0;){let i=r.pop(),a=e(i.kind,i.id);a!==null&&o([a]);}return n}function Jr(t,e,n){if(t.kind==="textValue")return t;let r=[],o=false;for(let i of t.children){if(i.kind!=="textValue"&&i.namespaceUri===pa&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?e:n,c=eg(i,"id");if(i.kind!=="noteReference"||c===void 0||!l.has(Ie(c))){o=true;continue}}let s=Jr(i,e,n);s!==i&&(o=true),r.push(s);}return o?{...t,children:r}:t}function wc(t,e){for(let n of Pe(t,e)){if(n.type!==Wr||n.targetMode==="External")continue;let r=E(n.ownerPart,n.rawTarget);if(r.ok)return t.parts.get(r.partName)??null}return t.parts.get("/word/styles.xml")??null}function Ji(t,e,n){for(let r of Pe(t,e)){if(r.type!==n||r.targetMode==="External")continue;let o=E(r.ownerPart,r.rawTarget);if(o.ok)return t.parts.get(o.partName)??null}return null}function Qi(t,e){let n=wc(t,e),r=new Map,o=[],i=null;if(n&&we(n.root))for(let a of n.root.children){if(!we(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===pa){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==pa)continue;let s=eg(a,"styleId");s&&r.set(s,a),(eg(a,"default")==="1"||eg(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var Cc=new Set(["basedOn","link","next"]);function Zi(t,e){let n=new Set,r=[...e];for(let a of t.defaults){let s=eg(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=t.byId.get(a);if(s){o.push(s);for(let l of s.children)if(we(l)&&Cc.has(l.localName)&&l.namespaceUri===pa){let c=eg(l,"val");c&&r.push(c);}}}if(!t.part||!we(t.part.root))return o;let i=new Map;return t.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function Qr(t,e,n){let r=Ji(t,e,Kr)??t.parts.get("/word/numbering.xml")??null;if(!r||!we(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!we(s)||s.localName!=="num"||s.namespaceUri!==pa)continue;let l=eg(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let c of s.children)if(we(c)&&c.localName==="abstractNumId"){let d=eg(c,"val");d&&i.add(d);}}}let a=[];for(let s of r.root.children){if(!we(s)||s.localName!=="abstractNum"||s.namespaceUri!==pa)continue;let l=eg(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var Un={latin:null,eastAsia:null,cs:null};function es(t,e){let n=Ji(t,e,Ec);if(!n)return {major:Un,minor:Un};let r={major:{...Un},minor:{...Un}};return Je(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==vc||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!we(a))continue;let s=eg(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 Mc(t,e){let n=e.startsWith("major")?t.major:t.minor;return e.endsWith("EastAsia")?n.eastAsia??n.latin:e.endsWith("Bidi")?n.cs??n.latin:n.latin}var Ac=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],ji=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Qe(t,e){if(t.kind==="textValue")return t;let n=t.attributes;if(t.localName==="rFonts"&&t.namespaceUri===pa){let i=[],a=new Map;for(let s of t.attributes){let l=Ac.find(([c])=>c===s.localName);if(l&&s.namespaceUri===pa){let c=Mc(e,s.value);c&&a.set(l[1],c);continue}i.push(s);}for(let[s,l]of a)i.some(c=>c.localName===s)||i.push({kind:"genericExtension",namespaceUri:pa,localName:s,prefix:"w",value:l});n=i;}else t.attributes.some(i=>ji.has(i.localName)&&i.namespaceUri===pa&&t.attributes.some(a=>a.localName==="val"))&&(n=t.attributes.filter(i=>!(ji.has(i.localName)&&i.namespaceUri===pa)));let r=t.children.map(i=>Qe(i,e)),o=r.some((i,a)=>i!==t.children[a]);return n===t.attributes&&!o?t:{...t,attributes:n,children:r}}function ts(t,e,n){return {id:t,name:t,contentType:e,root:n}}function ns(t,e){if(t.root.kind==="document"){let r=t.root.children.find(i=>i.kind==="body"),o=r&&we(r)?Bi(r,e):{id:"fragment#body",kind:"body",namespaceUri:pa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:e};return Bi(t.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:pa,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:e};return {id:"fragment#document",kind:"document",namespaceUri:pa,localName:"document",prefix:"w",namespaceBindings:we(t.root)?t.root.namespaceBindings:[],attributes:[],children:[n]}}function Kt(t){let e=t.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${W(n.id)}" Type="${W(n.type)}" Target="${W(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${Nc}">${e}</Relationships>`}function rs(t,e){let n=e;for(;t.has(`rId${n}`);)n+=1;return `rId${n}`}function os(t){let e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1).toLowerCase()}function Bn(t,e){return {...t,children:e}}function jn(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===pa}function Xt(t,e=[]){if(t.kind==="textValue")return e;t.kind==="paragraph"&&e.push(t.id);for(let n of t.children)Xt(n,e);return e}function as(t,e){if(t.kind==="textValue")return null;if(t.kind==="paragraph"&&t.id===e)return t;for(let n of t.children){let r=as(n,e);if(r)return r}return null}function Dc(t){let e=(n,r)=>{if(n.kind==="textValue")return n;if(r&&jn(n,"vMerge")){if(eg(n,"val")==="restart")return n;let i=[...n.attributes.filter(a=>!(a.localName==="val"&&a.namespaceUri===pa)),{kind:"wmlVal",namespaceUri:pa,localName:"val",prefix:"w",value:"restart"}];return {...n,attributes:i}}if(n.kind==="paragraph"||n.kind==="table")return n;let o=r||jn(n,"tc");return Bn(n,n.children.map(i=>e(i,o)))};return Bn(t,t.children.map(n=>e(n,false)))}function is(t,e){if(!(t.kind==="textValue"||t.kind==="table")){if(jn(t,"tr")){e.push(t);return}for(let n of t.children)is(n,e);}}function ss(t,e,n){if(t.kind==="textValue"||t.kind==="table")return {node:t,hadRows:false,keptRows:false};if(jn(t,"tr")){if(!e.has(t))return {node:null,hadRows:true,keptRows:false};let a=n.value?Dc(t):t;return n.value=false,{node:a,hadRows:true,keptRows:true}}let r=false,o=false,i=[];for(let a of t.children){let s=ss(a,e,n);r||=s.hadRows,o||=s.keptRows,s.node!==null&&i.push(s.node);}return r?{node:o?Bn(t,i):null,hadRows:true,keptRows:o}:{node:t,hadRows:false,keptRows:false}}function ls(t,e,n){let r=[];for(let l of t.children)is(l,r);let o=new Set(Xt(t).filter(l=>e.inRange.has(l)));if(o.size===0)return;let i=r.filter(l=>{let c=Xt(l);return c.length>0&&c.every(d=>e.covered.has(d))}),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},c=new Set(i),d=[];for(let u of t.children){let m=ss(u,c,l);m.node!==null&&d.push(m.node);}n.push(Bn(t,d));return}for(let l of Xt(t)){if(!e.inRange.has(l))continue;let c=as(t,l);c&&n.push(c);}}var _c="http://schemas.openxmlformats.org/package/2006/content-types",Fc=5e4;function _e(t){return t.kind!=="textValue"}function cs(t,e=[]){if(t.kind==="textValue")return e;t.kind==="paragraph"&&e.push(t.id);for(let n of t.children)cs(n,e);return e}function Zr(t,e){if(t.kind==="textValue")return null;if(t.kind==="paragraph"&&t.id===e)return t;for(let n of t.children){let r=Zr(n,e);if(r)return r}return null}function Lc(){return {id:"fragment#styles",kind:"generic",namespaceUri:pa,localName:"styles",prefix:"w",namespaceBindings:[{prefix:"w",namespaceUri:pa}],attributes:[],children:[]}}function Be(t,e){return {...t,children:e}}function Hc(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===pa}function Uc(t){if(t.root.kind==="document"){let e=t.root.children.find(n=>n.kind==="body");return e&&_e(e)?e:null}return _e(t.root)?t.root:null}function $c(t,e){return cs(t).some(n=>e.has(n))}function eo(t,e,n){for(let r of t)if(_e(r)){if(r.kind==="paragraph"){e.inRange.has(r.id)&&n.push(r);continue}if(e.fullBlocks.has(r.id)){n.push(r);continue}if(r.kind==="table"){ls(r,e,n);continue}if(r.kind==="contentControl"){let o=r.children.find(i=>i.kind==="contentControlContent");o&&_e(o)&&eo(o.children,e,n);continue}$c(r,e.inRange)&&eo(r.children,e,n);}}var Bc=new Set(["commentRangeStart","commentRangeEnd"]);function jc(t){return t.kind==="run"&&t.children.some(e=>e.kind==="commentReference")}function to(t){if(t.kind==="textValue")return t;if(Bc.has(t.localName)&&t.namespaceUri===pa||jc(t)||Hc(t,"sectPr"))return null;let e=false,n=[];for(let r of t.children){let o=to(r);if(o===null){e=true;continue}o!==r&&(e=true),n.push(o);}return e?Be(t,n):t}function Vc(t){let e=[],n=l=>{if(l.kind!=="textValue"){if(l.kind==="run"){for(let c of l.children)if(c.kind==="fldChar"){let d=eg(c,"fldCharType");e.push({nodeId:c.id,type:d==="separate"||d==="end"?d:"begin"});}else c.kind==="instrText"&&e.push({nodeId:c.id,type:"instr"});return}for(let c of l.children)n(c);}};for(let l of t)n(l);if(e.length===0)return t;let r=new Set,o=[],i=null,a=[];for(let l of e){if(l.type==="begin"){o.push({beginId:l.nodeId,separateId:null,instrIds:[]});continue}if(l.type==="separate"){let d=o[o.length-1];d?d.separateId=l.nodeId:i=l.nodeId;continue}if(l.type==="instr"){let d=o[o.length-1];d?d.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 d of a)r.add(d);i=null,a=[];}}for(let l of o){r.add(l.beginId),l.separateId!==null&&r.add(l.separateId);for(let c of l.instrIds)r.add(c);}i!==null&&r.add(i);for(let l of a)r.add(l);if(r.size===0)return t;let s=l=>{if(l.kind==="textValue")return l;if(r.has(l.id))return null;let c=[],d=false;for(let u of l.children){let m=s(u);if(m===null){d=true;continue}m!==u&&(d=true),c.push(m);}return d?Be(l,c):l};return t.map(l=>s(l)).filter(l=>l!==null)}function no(t){if(t.kind==="textValue")return t.value.length;let e=0;for(let n of t.children)e+=no(n);return e}function zc(t,e){let n=[];for(let r of t.children){if(r.kind!=="contentControl"){n.push(r);continue}let o=e.get(r.id),i=no(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&&_e(a)?n.push(...a.children):n.push(r);}return Be(t,n)}function Gc(t){let e=new Set,n=new Set,r=a=>{if(a.kind!=="textValue"){if(a.kind==="bookmarkStart"){let s=eg(a,"id");s!==void 0&&e.add(s);}if(a.kind==="bookmarkEnd"){let s=eg(a,"id");s!==void 0&&n.add(s);}for(let s of a.children)r(s);}};for(let a of t)r(a);let o=new Set([...e].filter(a=>n.has(a)));if(o.size===e.size&&o.size===n.size)return t;let i=a=>{if(a.kind==="textValue")return a;if(a.kind==="bookmarkStart"||a.kind==="bookmarkEnd"){let c=eg(a,"id");return c!==void 0&&o.has(c)?a:null}let s=[],l=false;for(let c of a.children){let d=i(c);if(d===null){l=true;continue}d!==c&&(l=true),s.push(d);}return l?Be(a,s):a};return t.map(a=>i(a)??a)}function Wc(t,e,n){let r=t.parts.get(e.partName);if(!r)return {ok:false,reason:"unknown-part"};if(e.paragraphIds.length===0)return {ok:false,reason:"empty-range"};let o=e.paragraphIds[0],i=e.paragraphIds[e.paragraphIds.length-1],a=new Map;for(let x of [o,i]){let H=Zr(r.root,x);if(!H)return {ok:false,reason:"empty-range"};for(let j of H.children)j.kind==="contentControl"&&a.set(j.id,no(j));}let s=r,l=Zr(s.root,i);if(!l)return {ok:false,reason:"empty-range"};let c=tg(l);if(e.endOffset<c){let x=Ql$1(s,{op:"deleteText",paragraphId:i,start:e.endOffset,end:c},{deferValidation:true});if(!x.ok)return {ok:false,reason:"trim-refused"};s=x.part;}if(e.startOffset>0){let x=Ql$1(s,{op:"deleteText",paragraphId:o,start:0,end:e.startOffset},{deferValidation:true});if(!x.ok)return {ok:false,reason:"trim-refused"};s=x.part;}let d=Uc(s);if(!d)return {ok:false,reason:"unknown-part"};let u={inRange:new Set(e.paragraphIds),covered:new Set(e.coveredParagraphIds),fullBlocks:new Set(e.fullyCoveredBlockIds)},m=[];if(eo(d.children,u,m),m.length===0)return {ok:false,reason:"empty-range"};if(m.length>Fc)return {ok:false,reason:"resource-limit"};let f=m.map(x=>to(x)).filter(x=>x!==null).map(x=>x.kind!=="paragraph"||x.id!==o&&x.id!==i?x:zc(x,a));f=[...Vc(f)],f=[...Gc(f)];let h=qh(t,"footnote"),b=qh(t,"endnote"),R=(x,H)=>_e(x)&&x.namespaceUri===pa&&x.localName===H,g=$n(f,(x,H)=>{let j=x==="footnote"?h:b;if(!j||!_e(j.root))return null;for(let Y of j.root.children){if(!R(Y,x))continue;let G=eg(Y,"id");if(G!==void 0&&Ie(G)===H)return Y}return null}),p=g.footnote,P=g.endnote;p.size===0&&(h=null),P.size===0&&(b=null);let M=(x,H,j)=>{if(!x||!_e(x.root))return [];let Y=[];for(let G of x.root.children){if(!R(G,H))continue;let ne=eg(G,"id"),Ke=eg(G,"type");if(Ke==="separator"||Ke==="continuationSeparator"){Y.push(G);continue}if(ne!==void 0&&j.has(Ie(ne))){let Xe=to(G);Xe&&_e(Xe)&&Y.push(Xe);}}return Y},F$1=M(h,"footnote",p),$=M(b,"endnote",P),w=[...F$1,...$];if(Gt(f)||Gt(w))return {ok:false,reason:"unsupported-content"};let L=[...f,...w],q=new Set;Xr(L,q);let U=Qi(t,t.mainDocumentPart),J=new Set;Yr(L,J);let ee=[],B=Qr(t,t.mainDocumentPart,J);for(;;){let x=q.size,H=J.size;ee=Zi(U,q),Yr(ee,J),B=Qr(t,t.mainDocumentPart,J);let j=[...B.nums,...B.abstracts];Xr(j,q);for(let Y of j)Je(Y,G=>{if(G.kind!=="textValue"&&(G.localName==="styleLink"||G.localName==="numStyleLink")&&G.namespaceUri===pa){let ne=eg(G,"val");ne&&q.add(ne);}});if(q.size===x&&J.size===H)break}let re=es(t,t.mainDocumentPart),ue=ee.map(x=>Qe(x,re)),le=U.part&&_e(U.part.root)?U.part.root:null,A=$i(le,U.docDefaults,"fragment#doc-defaults"),_=A?Qe(A,re):null;f=f.map(x=>Qe(x,re));let V=F$1.map(x=>Qe(x,re)),te=$.map(x=>Qe(x,re)),oe=new Set;Wt(f,oe);let de=Pe(t,r.name).filter(x=>oe.has(x.id)),S=new Map,k=0,E$1=x=>{let H=new Set;for(let j of x){if(j.targetMode==="External")continue;let Y=E(j.ownerPart,j.rawTarget);if(!Y.ok){H.add(j.id);continue}if((Qe$1(t,Y.partName)??"").toLowerCase().startsWith("image/")&&n?.omitMedia!==true){let ne=t.partBytes.get(Y.partName)??t.partBytes.get(Y.partName.replace(/^\//,""));ne?(S.set(Y.partName,ne),k+=ne.byteLength):H.add(j.id);continue}H.add(j.id);}return H},N=E$1(de),W$1=(x,H)=>{if(x.kind==="textValue")return x;if(x.kind==="drawing"||x.namespaceUri===pa&&(x.localName==="pict"||x.localName==="object")){let G=new Set;Wt([x],G);for(let ne of G)if(H.has(ne))return null;return x}let j=[],Y=false;for(let G of x.children){let ne=W$1(G,H);if(ne===null){Y=true;continue}ne!==G&&(Y=true),j.push(ne);}return Y?Be(x,j):x};N.size>0&&(f=f.map(x=>W$1(x,N)).filter(x=>x!==null));let Q=de.filter(x=>!N.has(x.id)),ce=(x,H)=>{if(!x)return [];let j=new Set;Wt(H,j);let Y=Pe(t,x.name).filter(ne=>j.has(ne.id)),G=E$1(Y);if(G.size>0)for(let ne=0;ne<H.length;ne+=1){let Ke=W$1(H[ne],G);Ke!==null&&(H[ne]=Ke);}return Y.filter(ne=>!G.has(ne.id))},Fe=ce(h,V),rn=ce(b,te),Oe=new Map,yt=[],tr=new Map,nt=(x,H,j)=>{let Y=ts(x,H,j);Oe.set(x.slice(1),_d$1(Fa(Y))),yt.push([x,H]),tr.set(x,Y);},y=(x,H)=>x.map(j=>{if(j.targetMode==="External")return {...j,ownerPart:H};let Y=E(j.ownerPart,j.rawTarget);return {...j,ownerPart:H,rawTarget:Y.ok?Y.partName:j.rawTarget}}),v=y(Q,"/word/document.xml"),T=y(Fe,"/word/footnotes.xml"),D=y(rn,"/word/endnotes.xml"),z=new Set(v.map(x=>x.id)),K=9001,ie=(x,H)=>{let j=rs(z,K);K+=1,z.add(j),v.push({ownerPart:"/word/document.xml",id:j,type:x,rawTarget:H,targetMode:"Internal",order:v.length});},Ne=ns(s,f);if(nt("/word/document.xml",Vi,Ne),ue.length>0||_){let x=Be(le??Lc(),[..._?[_]:[],...ue]);nt("/word/styles.xml",zi,x),ie(Wr,"styles.xml");}if(B.part&&(B.nums.length>0||B.abstracts.length>0)){let x=Be(B.part.root,[...B.abstracts.map(H=>Qe(H,re)),...B.nums]);nt("/word/numbering.xml",Gi,x),ie(Kr,"numbering.xml");}h&&V.length>0&&(nt("/word/footnotes.xml",Wi,Be(h.root,V)),ie(Xi,"footnotes.xml"),T.length>0&&Oe.set("word/_rels/footnotes.xml.rels",_d$1(Kt(T)))),b&&te.length>0&&(nt("/word/endnotes.xml",Ki,Be(b.root,te)),ie(Yi,"endnotes.xml"),D.length>0&&Oe.set("word/_rels/endnotes.xml.rels",_d$1(Kt(D))));let pe=new Map;for(let[x,H$1]of S){Oe.set(x.slice(1),H$1);let j=os(x);j&&!pe.has(j)&&pe.set(j,H(Qe$1(t,x)??"application/octet-stream"));}let Me={ownerPart:"/",id:"rId1",type:qi,rawTarget:"word/document.xml",targetMode:"Internal",order:0};Oe.set("word/_rels/document.xml.rels",_d$1(Kt(v))),Oe.set("_rels/.rels",_d$1(Kt([Me])));let rt=[`<Default Extension="rels" ContentType="${Gr}"/>`,'<Default Extension="xml" ContentType="application/xml"/>',...[...pe].map(([x,H])=>`<Default Extension="${W(x)}" ContentType="${W(H)}"/>`)].join(""),ze=yt.map(([x,H])=>`<Override PartName="${W(x)}" ContentType="${W(H)}"/>`).join("");Oe.set("[Content_Types].xml",_d$1(`<Types xmlns="${_c}">${rt}${ze}</Types>`));let Ge=new Map;Ge.set("/",[Me]),Ge.set("/word/document.xml",v),T.length>0&&Ge.set("/word/footnotes.xml",T),D.length>0&&Ge.set("/word/endnotes.xml",D);let se=[];for(let x of Ge.values())for(let H of x)H.targetMode==="External"&&se.push({ownerPart:H.ownerPart,id:H.id,type:H.type,rawTarget:H.rawTarget,sinkSafe:F(H.rawTarget).ok});let me=new Map;me.set("rels",Gr),me.set("xml","application/xml");for(let[x,H]of pe)me.set(x,H);let We={defaults:me,overrides:new Map(yt)},Dt=new Map;for(let[x,H]of Oe)Dt.set(x.startsWith("/")?x:`/${x}`,H);return {ok:true,bytes:Zd$1(Oe),package:Object.freeze({parts:tr,partBytes:Dt,relationships:Ge,externalTargets:se,contentTypes:We,mainDocumentPart:"/word/document.xml"}),lastMarkCovered:e.lastMarkCovered,blockCount:f.length,mediaBytes:k}}function ae(t){return t.kind!=="textValue"}function X(t,e){return t.kind!=="textValue"&&t.localName===e&&t.namespaceUri===pa}function Ce(t,e){for(let n of t)e(n),n.kind!=="textValue"&&Ce(n.children,e);}function Ze(t){if(t.kind==="textValue")return `T(${t.value})`;if(t.namespaceUri===pa&&t.localName.startsWith("rsid"))return "";let e=t.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===ua&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=t.children.map(Ze).join("");return `E(${t.namespaceUri}:${t.localName}[${e}]{${n}})`}function qt(t){return `S[${t.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${t.children.map(Ze).join("")}`}function Gn(t){let e=[],n=new Map,r=new Set,o=null;if(t&&ae(t.root))for(let i of t.root.children){if(!ae(i))continue;if(X(i,"docDefaults")){o=i;continue}if(!X(i,"style"))continue;e.push(i);let a=eg(i,"styleId");a&&n.set(a,i);let s=i.children.find(c=>X(c,"name")),l=s?eg(s,"val"):void 0;l&&r.add(l);}return {part:t,styles:e,docDefaults:o,byId:n,names:r}}function Vn(t,e,n){let r=new Map;if(!t)return r;let o=t.children.find(a=>X(a,e));if(!o||!ae(o))return r;let i=o.children.find(a=>X(a,n));if(!i||!ae(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function ms(t){let e=t.part?.root;return e&&ae(e)?e:null}function ds(t){return zr(ms(t),t.docDefaults)}function zn(t){return new Map(t.map(e=>[e.localName,aj(e,`fragment#application-${e.localName}`)]))}function Kc(t,e){let n=new Set,r=e;for(let o=0;o<16&&r;o+=1){let i=t.byId.get(r);if(!i)break;let s=Yt(i,"pPr")?.children.find(c=>X(c,"spacing"));if(s&&ae(s))for(let c of s.attributes)n.add(c.localName);let l=i.children.find(c=>X(c,"basedOn"));r=l?eg(l,"val"):void 0;}return n}function ro(t,e,n,r){let o=e;for(let i=0;i<16&&o;i+=1){let a=t.byId.get(o);if(!a)return false;let s=a.children.find(c=>X(c,n));if(s&&ae(s)&&s.children.some(c=>c.kind!=="textValue"&&c.localName===r))return true;let l=a.children.find(c=>X(c,"basedOn"));o=l?eg(l,"val"):void 0;}return false}function Xc(t,e){for(let n of t.styles){if(eg(n,"type")!==e)continue;let r=eg(n,"default");if(r==="1"||r==="true")return eg(n,"styleId")}}function Yt(t,e){let n=t.children.find(r=>X(r,e));return n&&ae(n)?n:null}var Yc=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((t,e)=>[t,e])),qc=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((t,e)=>[t,e]));function oo(t,e,n){let r=ms(e)?ds(e):null,o=ds(n),i=r?.run?zn(Ln):Vn(e.docDefaults,"rPrDefault","rPr"),a=o.run?zn(Ln):Vn(n.docDefaults,"rPrDefault","rPr"),s=r?.paragraph?zn(Hn):Vn(e.docDefaults,"pPrDefault","pPr"),l=o.paragraph?zn(Hn):Vn(n.docDefaults,"pPrDefault","pPr"),c=(p,P,M)=>{let F=Xc(p,"paragraph"),$=F?p.byId.get(F):void 0;if(!$)return F;for(let[w,L]of [["rPr",P],["pPr",M]]){let q=Yt($,w);if(q)for(let U of q.children)U.kind!=="textValue"&&L.set(U.localName,U);}return F};c(e,i,s),c(n,a,l);let d=new Map;for(let[p,P]of i){let M=a.get(p);(!M||Ze(M)!==Ze(P))&&d.set(p,P);}let u=new Map;for(let[p,P]of s){if(p==="sectPr")continue;let M=l.get(p);(!M||Ze(M)!==Ze(P))&&u.set(p,P);}if(d.size===0&&u.size===0)return t;let m=0,f=()=>`fragment#materialized-${m++}`,h=p=>{let P=M=>M.kind==="textValue"?{id:f(),kind:"textValue",value:M.value}:{...M,id:f(),children:M.children.map(P)};return P(p)},b=(p,P,M)=>{if(M.length===0)return p;let F=Yt(p,P);if(F){let w=P==="rPr"?qc:Yc,L=[...F.children];for(let U of M){let J=U.kind==="textValue"?Number.MAX_SAFE_INTEGER:w.get(U.localName)??Number.MAX_SAFE_INTEGER,ee=L.length;for(let B=0;B<L.length;B+=1){let re=L[B];if(re.kind==="textValue")continue;let ue=w.get(re.localName);if(ue!==void 0&&ue>J){ee=B;break}}L.splice(ee,0,U);}let q={...F,children:L};return {...p,children:p.children.map(U=>U===F?q:U)}}let $={id:f(),kind:P==="rPr"?"runProperties":"paragraphProperties",namespaceUri:pa,localName:P,prefix:"w",namespaceBindings:[],attributes:[],children:M};return {...p,children:[$,...p.children]}},R=(p,P,M,F,$)=>{let w=Kc(e,$),L=P.children.find(B=>X(B,"spacing"));if(L&&ae(L))for(let B of L.attributes)w.add(B.localName);let q=new Map(F&&ae(F)?F.attributes.map(B=>[B.localName,B.value]):[]),U=M.attributes.filter(B=>!w.has(B.localName)&&q.get(B.localName)!==B.value);if(U.length===0)return p;let J=L&&ae(L)?{...L,attributes:[...L.attributes,...U]}:{...M,id:f(),attributes:U,children:[]},ee=L?{...P,children:P.children.map(B=>B===L?J:B)}:b(p,"pPr",[J]).children.find(B=>X(B,"pPr"));return {...p,children:p.children.map(B=>B===P?ee:B)}},O=p=>{let P=Yt(p,"pPr"),M=P?.children.find(U=>X(U,"pStyle")),F=M?eg(M,"val"):void 0,$=[],w=p;for(let[U,J]of u){let ee=P?.children.some(re=>re.kind!=="textValue"&&re.localName===U),B=!!F&&ro(e,F,"pPr",U);U==="spacing"&&(ee||B)&&P!==null&&ae(J)&&(w=R(w,P,J,l.get("spacing"),F)),!(ee||B)&&$.push(h(J));}let L=U=>{if(U.kind==="textValue")return U;if(U.kind==="run"){let ee=Yt(U,"rPr"),B=ee?.children.find(le=>X(le,"rStyle")),re=B?eg(B,"val"):void 0,ue=[];for(let[le,A]of d)ee?.children.some(V=>V.kind!=="textValue"&&V.localName===le)||re&&ro(e,re,"rPr",le)||F&&ro(e,F,"rPr",le)||ue.push(h(A));return b(U,"rPr",ue)}if(U.kind==="paragraphProperties"||U.kind==="runProperties")return U;let J=U.children.map(L);return J.some((ee,B)=>ee!==U.children[B])?{...U,children:J}:U};return L(b(w,"pPr",$))},g=p=>{if(p.kind==="textValue")return p;if(p.kind==="paragraph")return O(p);let P=p.children.map(g);return P.some((M,F)=>M!==p.children[F])?{...p,children:P}:p};return t.map(g)}var us="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function he(t,e,n,r){return {...t,attributes:t.attributes.map(o=>o.localName===n&&o.namespaceUri===e?{...o,value:r}:o)}}var Jc=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),ao=Dh,je=new Map;function It(t,e){let n=e.styleIds??je,r=e.numIds??je,o=e.relIds??je,i=e.footnoteIds??je,a=e.endnoteIds??je,s=e.bookmarkIds??je,l=e.sdtIds??je,c=e.revisionIds??je,d=e.docPrIds??je,u=(m,f)=>{if(m.kind==="textValue")return m;let h=m;if(m.namespaceUri===pa&&Jc.has(m.localName)){let g=eg(m,"val"),p=g!==void 0?n.get(g):void 0;p!==void 0&&(h=he(h,pa,"val",p));}if(X(m,"numId")){let g=eg(m,"val"),p=g!==void 0?r.get(g):void 0;p!==void 0&&(h=he(h,pa,"val",p));}if(m.kind==="noteReference"){let g=m.localName==="footnoteReference"?i:a,p=eg(m,"id"),P=p!==void 0?g.get(Ie(p)):void 0;P!==void 0&&(h=he(h,pa,"id",P));}if(m.kind==="bookmarkStart"||m.kind==="bookmarkEnd"){let g=eg(m,"id"),p=g!==void 0?s.get(g):void 0;p!==void 0&&(h=he(h,pa,"id",p));}if(X(m,"id")&&f==="sdtPr"){let g=eg(m,"val"),p=g!==void 0?l.get(g):void 0;p!==void 0&&(h=he(h,pa,"val",p));}if(ao(m)){let g=eg(m,"id"),p=g!==void 0?c.get(g):void 0;p!==void 0&&(h=he(h,pa,"id",p));}if(m.kind==="drawingDocPr"){let g=m.attributes.find(P=>P.localName==="id"&&P.namespaceUri==="")?.value,p=g!==void 0?d.get(g):void 0;p!==void 0&&(h=he(h,"","id",p));}for(let g of h.attributes){if(g.namespaceUri!==us)continue;let p=o.get(g.value);p!==void 0&&p!==g.value&&(h=he(h,us,g.localName,p));}let b=m.localName,R=h.children.map(g=>u(g,b));return h!==m||R.some((g,p)=>g!==h.children[p])?{...h,children:R}:m};return u(t,"")}function ps(t,e,n){let r=t,o=n.get(t)??2;for(;e.has(r);)r=`${t}${o}`,o+=1;return n.set(t,o),r}function fs(t,e,n){let r=`${t} (pasted)`,o=n.get(t)??2;for(;e.has(r);)r=`${t} (pasted ${o})`,o+=1;return n.set(t,o),r}var Qc=1e5;function gs(t){let e=Mb(),n=Zc(t,e),r=ed(t,e),o=td(t,e);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function io(t,e,n,r){if(t)return Pb(e,t,r);let o=n;return ()=>String(o++)}function hs(t,e){if(t.add(e),!/^\d{1,10}$/.test(e))return;let n=Number(e);n<=Jb&&t.add(String(n));}function ys(t,e){if(e===void 0)return t;let n=Number(e);return Number.isInteger(n)&&n>t?n:t}function Zc(t,e){let n=new Map;if(t.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [t.ownerPart,...t.notesParts])Ce([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=eg(s,"id");l!==void 0&&(hs(o,l),s.kind==="bookmarkStart"&&(r=ys(r,l)));});let i=io(e,o,r+1,Jb);for(let a of t.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function ed(t,e){let n=new Map;if(!t.hasRevision)return n;let r=0,o=new Set;for(let s of [t.ownerPart,...t.notesParts]){let l=s===t.ownerPart;Ce([s.root],c=>{if(!Dh(c))return;let d=eg(c,"id");d!==void 0&&hs(o,d),l&&(r=ys(r,d));});}let i=io(e,o,r+1,Jb),a=false;return Ce(t.travelling,s=>{if(a||!Dh(s))return;let l=eg(s,"id");if(l===void 0||n.has(l))return;let c=i();c===null?a=true:n.set(l,c);}),a?null:n}function td(t,e){let n=new Map;if(!t.hasDocPr)return n;let{used:r}=ve(t.pkg),o=Qc;if(!e){let s=we$1(t.pkg);s.ok&&(o=s.id);}let i=io(e,r,o,ue),a=false;return Ce(t.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(d=>d.localName==="id"&&d.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let c=i();c===null?a=true:n.set(l,c);}),a?null:n}function xs(t,e){return `${e?qt(e):"none"}::${t.children.filter(n=>X(n,"lvlOverride")).map(Ze).join("")}`}function ks(t){let e=t.children.find(n=>X(n,"abstractNumId"));return e?eg(e,"val"):void 0}function Ps(t,e,n){let r=new Set(["0"]),o=0;for(let s of t?.root.children??[]){if(!ae(s)||!X(s,e))continue;let l=eg(s,n);if(l===void 0)continue;let c=Number(l);Number.isInteger(c)&&(r.add(String(c)),c>o&&(o=c));}let i=Mb();if(i)return Pb(r,i,Kb);let a=o+1;return ()=>String(a++)}function Os(t,e){let n={numIdMap:new Map,numsToImport:[],abstractsToImport:[]};if(!t||!ae(t.root))return n;let r=new Map,o=[];for(let c of t.root.children)if(ae(c))if(X(c,"abstractNum")){let d=eg(c,"abstractNumId");d&&r.set(d,c);}else X(c,"num")&&o.push(c);let i=new Map;if(e&&ae(e.root)){let c=new Map;for(let d of e.root.children){if(!ae(d)||!X(d,"abstractNum"))continue;let u=eg(d,"abstractNumId");u&&c.set(u,d);}for(let d of e.root.children){if(!ae(d)||!X(d,"num"))continue;let u=eg(d,"numId");if(!u)continue;let m=ks(d),f=m?c.get(m):void 0;i.set(xs(d,f),u);}}let a=Ps(e,"abstractNum","abstractNumId"),s=Ps(e,"num","numId"),l=new Map;for(let c of o){let d=eg(c,"numId");if(!d)continue;let u=ks(c),m=u?r.get(u):void 0,f=xs(c,m),h=i.get(f);if(h!==void 0){n.numIdMap.set(d,h);continue}let b=u?l.get(u):void 0;if(b===void 0&&m&&u){let g=a();if(g===null)return null;b=g,l.set(u,b),n.abstractsToImport.push(he(m,pa,"abstractNumId",b));}let R=s();if(R===null)return null;n.numIdMap.set(d,R);let O=he(c,pa,"numId",R);if(b!==void 0){let g=O.children.map(p=>X(p,"abstractNumId")?he(p,pa,"val",b):p);O={...O,children:g};}n.numsToImport.push(O),i.set(f,R);}return n}var Nt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",nd=`${Nt}/hyperlink`,bs=`${Nt}/image`,Wn=`${Nt}/numbering`,so=`${Nt}/styles`,Ss="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Rs="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Jt(t,e,n,r){for(let o of Pe(t,e)){if(o.type!==n||o.targetMode==="External")continue;let i=E(o.ownerPart,o.rawTarget);if(i.ok){let a=t.parts.get(i.partName);if(a)return a}}return t.parts.get(r)??null}function rd(t,e){let n=0;return Ce([t],r=>{let o=e(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Kn(t,e,n,r){if(n.length===0)return t;let o=Va(e,"paste"),i=n.map(c=>jg(c,o)),a=Sk(e,i),s=r??a.root.children.length,l=ab(a,a.root.id,s,i,{deferValidation:true});return l.ok?Ne(t,l.part):null}function Is(t,e){if(e.size===0)return [...t];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"||X(o,"pict")||X(o,"object")){let a=false;return Ce([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===Nt&&e.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===Nt)?.value;if(a!==void 0&&e.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(t)}var od=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),Ns={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function ad(t,e){let n=ke(t);if(n==="unknown")return null;let r=H(e);return (Object.hasOwn(Ns,r)?Ns[r]:r)!==n||od.has(n)&&!xe(t,n)?null:n}function lo(t,e,n){for(let y of e.parts.values())if(Gt([y.root]))return {ok:false,reason:"unsupported-content"};let r=e.parts.get(e.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!t.parts.has(n))return {ok:false,reason:"no-target-part"};let o=r.root.kind==="document"?r.root.children.find(y=>y.kind==="body"):null;if(!o||!ae(o))return {ok:false,reason:"no-fragment-document"};let i=hl$1(o.children.filter(y=>y.kind==="paragraph"||y.kind==="table"||y.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a=t,s=Os(Jt(e,e.mainDocumentPart,Wn,"/word/numbering.xml"),Jt(a,a.mainDocumentPart,Wn,"/word/numbering.xml"));if(!s)return {ok:false,reason:"merge-refused"};let{numIdMap:l,numsToImport:c,abstractsToImport:d}=s,u=Gn(Jt(e,e.mainDocumentPart,so,"/word/styles.xml")),m=Jt(a,a.mainDocumentPart,so,"/word/styles.xml"),f$1=Gn(m),h=new Map,b=[],R=new Set(f$1.byId.keys()),O=new Set(f$1.names),g=new Map,p=new Map,P=new Map,M=(y,v)=>{let T=P.get(y);return T===void 0&&(T=qt(v),P.set(y,T)),T},F=y=>({...y,attributes:y.attributes.filter(v=>!(v.localName==="default"&&v.namespaceUri===pa))});for(let y of u.styles){let v=eg(y,"styleId");if(!v)continue;let T=f$1.byId.get(v),D=qt(It(y,{styleIds:h,numIds:l}));if(T&&M(v,T)===D){h.set(v,v);continue}if(!T){h.set(v,v),R.add(v),b.push(F(y));continue}let z=ps(`${v}Pasted`,R,g);R.add(z),h.set(v,z),b.push(F(he(y,pa,"styleId",z)));}let $=b.map(y=>{let v=y.children.find(K=>X(K,"name")),T=v?eg(v,"val"):void 0;if(!T||!O.has(T))return T&&O.add(T),y;let D=fs(T,O,p);O.add(D);let z=y.children.map(K=>X(K,"name")?he(K,pa,"val",D):K);return {...y,children:z}}),w=null,L=1,q=Mb()===void 0?null:Qb(Number.MAX_SAFE_INTEGER),U=()=>{if(w)return w;let y=new Map;for(let[v,T]of a.partBytes){let D=v.startsWith("/")?v:`/${v}`;if(!D.startsWith("/word/media/"))continue;y.set(f(T),D);let z=/\/image(\d+)\./.exec(D);z&&(L=Math.max(L,Number(z[1])+1));}return w=y,y},J=new Map,ee=y=>{let v=J.get(y);if(!v){v=new Map;for(let T of Pe(a,y)){if(T.targetMode==="External"||T.type!==bs)continue;let D=E(T.ownerPart,T.rawTarget);D.ok&&v.set(D.partName,T.id);}J.set(y,v);}return v},B=(y,v)=>{let T=y.lastIndexOf("."),D=T===-1?"":y.slice(T+1);return /^[A-Za-z0-9]{1,8}$/.test(D)?D.toLowerCase():v==="image/jpeg"?"jpeg":v==="image/gif"?"gif":"png"},re=(y,v,T)=>{let D=new Map,z=new Set,K=ee(v),ie=[],Ne=new Set,pe=[],Me=[],rt=new Map,ze=[],Ge=e.relationships.get(y)??[];for(let se of Ge){if(!T.has(se.id))continue;if(se.targetMode==="External"){if(se.type===nd){let ot=Ug(a,se.rawTarget,v);ot?(a=ot.pkg,D.set(se.id,ot.relationshipId)):z.add(se.id);}else z.add(se.id);continue}let me=E(se.ownerPart,se.rawTarget);if(!me.ok){z.add(se.id);continue}let We=e.partBytes.get(me.partName)??e.partBytes.get(me.partName.replace(/^\//,"")),Dt=(Qe$1(e,me.partName)??"").toLowerCase();if(!We||!Dt.startsWith("image/")){z.add(se.id);continue}let x=ad(We,Dt);if(x===null){z.add(se.id);continue}let H=x,j=U(),Y=f(We),G=j.get(Y);if(!G){let ot=B(me.partName,H),Xo=on=>a.partBytes.has(on)||a.partBytes.has(on.slice(1))||a.parts.has(on)||Ne.has(on),xt;if(q)do xt=`/word/media/image${q.next().value}.${ot}`;while(Xo(xt));else {for(xt=`/word/media/image${L}.${ot}`;Xo(xt);)L+=1,xt=`/word/media/image${L}.${ot}`;L+=1;}G=xt,ie.push({partName:G,bytes:We,contentType:H}),Ne.add(G),j.set(Y,G);}let ne=G.startsWith("/word/")?G.slice(6):G,Ke=K.get(G);if(Ke!==void 0){D.set(se.id,Ke);continue}let Xe=rt.get(G);Xe===void 0&&(Xe=pe.length,rt.set(G,Xe),pe.push(ne),Me.push(G)),ze.push({recordId:se.id,index:Xe});}if(ie.length>0&&(a=Be$1(a,ie)),pe.length>0){let se=Te(Ve$1(a,v),v,pe.map(me=>[bs,me]));if(se.ok){a=se.pkg,se.ids.forEach((me,We)=>{K.set(Me[We],me);});for(let me of ze)D.set(me.recordId,se.ids[me.index]);}else for(let me of ze)z.add(me.recordId);}return {relIdMap:D,dropRelIds:z}},ue=re(e.mainDocumentPart,n,qr(i));i=Is(i,ue.dropRelIds);let le=new Map,A=new Map,_=[],V=(y,v)=>ae(y)&&y.namespaceUri===pa&&y.localName===v,te={},oe=$n(i,(y,v)=>{let T=te[y];if(T===void 0){T=new Map,te[y]=T;let D=qh(e,y);if(D&&ae(D.root))for(let z of D.root.children){if(!V(z,y))continue;let K=eg(z,"id");if(K===void 0)continue;let ie=Ie(K);T.has(ie)||T.set(ie,z);}}return T.get(v)??null});for(let y of ["footnote","endnote"]){let v=y==="footnote"?le:A,T=oe[y];if(T.size===0)continue;let D=qh(e,y);if(!D||!ae(D.root))continue;let z=ki(a,y);if(!z.ok||!z.package)return {ok:false,reason:"merge-refused"};a=z.package;let K=qh(a,y);if(!K)return {ok:false,reason:"merge-refused"};let ie=rd(K.root,pe=>V(pe,y)?eg(pe,"id"):void 0)+1,Ne=[];for(let pe of D.root.children){if(!V(pe,y))continue;let Me=eg(pe,"id"),rt=eg(pe,"type");if(rt==="separator"||rt==="continuationSeparator"||Me===void 0||!T.has(Ie(Me))||v.has(Ie(Me)))continue;let ze=String(ie++);v.set(Ie(Me),ze),Ne.push(he(pe,pa,"id",ze));}Ne.length>0&&_.push({kind:y,fragmentPartName:D.name,bodies:hl$1(Ne)});}let de=a.parts.get(n),S=[...i,..._.flatMap(y=>y.bodies)],k=[],E$1=new Set,N=false,W=false,Q=new Map;Ce(S,y=>{if(y.kind!=="textValue"){if(y.kind==="bookmarkStart"||y.kind==="bookmarkEnd"){let v=eg(y,"id");if(v!==void 0&&k.push(v),y.kind==="bookmarkStart"){let T=eg(y,"name");T&&E$1.add(T);}return}if(ao(y)){N=true;return}if(y.kind==="drawingDocPr"){W=true;return}if(y.kind==="contentControlProperties")for(let v of y.children){if(!X(v,"id"))continue;let T=eg(v,"val");if(T!==void 0&&!Q.has(T)){let D=0,z=`${T}:${Q.size}`;for(let K=0;K<z.length;K+=1)D=D*31+z.charCodeAt(K)>>>0;Q.set(T,String(D%2147483647||1));}}}});let ce=gs({pkg:a,ownerPart:de,notesParts:_.map(y=>qh(a,y.kind)).filter(y=>y!==null),travelling:S,fragmentBookmarkIds:k,hasRevision:N,hasDocPr:W});if(!ce)return {ok:false,reason:"merge-refused"};let Fe=ce.bookmarkIds,rn=ce.revisionIds,Oe=ce.docPrIds;if(E$1.size>0){let y=new Set;if(Ce([de.root],v=>{if(v.kind!=="textValue"&&v.kind==="bookmarkStart"){let T=eg(v,"name"),D=eg(v,"id");T&&D!==void 0&&E$1.has(T)&&y.add(D);}}),y.size>0){let v=D=>{if(D.kind==="textValue")return D;let z=[],K=false;for(let ie of D.children){if((ie.kind==="bookmarkStart"||ie.kind==="bookmarkEnd")&&y.has(eg(ie,"id")??"")){K=true;continue}let Ne=v(ie);Ne!==ie&&(K=true),z.push(Ne);}return K?{...D,children:z}:D},T=v(de.root);T!==de.root&&(Za(de.root,T),a=Ne(a,{...de,root:T}));}}let yt=y=>Jr(y,le,A);for(let y of _){y.bodies=y.bodies.map(yt);let v=qh(a,y.kind);if(!v)return {ok:false,reason:"merge-refused"};let T=re(y.fragmentPartName,v.name,qr(y.bodies)),D=Is(y.bodies,T.dropRelIds);D=[...oo(D,u,f$1)],D=D.map(K=>It(K,{styleIds:h,numIds:l,relIds:T.relIdMap,footnoteIds:le,endnoteIds:A,bookmarkIds:Fe,sdtIds:Q,revisionIds:rn,docPrIds:Oe}));let z=Kn(a,a.parts.get(v.name),D);if(!z)return {ok:false,reason:"merge-refused"};a=z;}if($.length>0){let y=$.map(T=>It(T,{styleIds:h,numIds:l}));if(!m){let T=Ma(`<w:styles xmlns:w="${pa}"></w:styles>`,{name:"/word/styles.xml",contentType:Rs});if(!T.ok)return {ok:false,reason:"merge-refused"};a=Xe(a,"/word/styles.xml",T.part.root,Rs);let D=We(Ve$1(a,a.mainDocumentPart),a.mainDocumentPart,so,"styles.xml");if(!D.ok)return {ok:false,reason:"merge-refused"};a=D.pkg,m=a.parts.get("/word/styles.xml")??null;}if(!m)return {ok:false,reason:"merge-refused"};let v=Kn(a,a.parts.get(m.name),y);if(!v)return {ok:false,reason:"merge-refused"};a=v,f$1=Gn(a.parts.get(m.name)??null);}if(d.length>0||c.length>0){let y=Jt(a,a.mainDocumentPart,Wn,"/word/numbering.xml");if(!y){let K=Ma(`<w:numbering xmlns:w="${pa}"></w:numbering>`,{name:"/word/numbering.xml",contentType:Ss});if(!K.ok)return {ok:false,reason:"merge-refused"};a=Xe(a,"/word/numbering.xml",K.part.root,Ss);let ie=We(Ve$1(a,a.mainDocumentPart),a.mainDocumentPart,Wn,"numbering.xml");if(!ie.ok)return {ok:false,reason:"merge-refused"};a=ie.pkg,y=a.parts.get("/word/numbering.xml")??null;}if(!y)return {ok:false,reason:"merge-refused"};let v=a.parts.get(y.name),T=v.root.children.findIndex(K=>X(K,"num")),D=d.map(K=>It(K,{styleIds:h,numIds:l})),z=Kn(a,v,D,T===-1?void 0:T);if(!z)return {ok:false,reason:"merge-refused"};if(a=z,z=Kn(a,a.parts.get(y.name),c),!z)return {ok:false,reason:"merge-refused"};a=z;}let nt=[...oo(i,u,f$1)].map(yt).map(y=>It(y,{styleIds:h,numIds:l,relIds:ue.relIdMap,footnoteIds:le,endnoteIds:A,bookmarkIds:Fe,sdtIds:Q,revisionIds:rn,docPrIds:Oe}));return {ok:true,pkg:a,blocks:nt}}var vs=16*1024*1024;function id(t){let e=t.parts.get(t.mainDocumentPart);if(!e||e.root.kind!=="document")return false;let n=e.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>Pk)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>Rk))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,Qk))return false;for(let[i,a]of t.parts)if(i!==t.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,Qk*4))return false;return true}function co(t,e,n){if(n.fragmentBytes.byteLength>vs)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=Je$1(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!id(o))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:a,story:s}=i;if(a.compositionActive||t.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=t.currentPackage(),c=a.checkpoint();a.graftPackage(()=>t.currentPackage());let d=0,u="";return Ra(t,()=>{let m=a.transact(h=>{for(let g of n.priorOps??[])if(!h.apply(g))return;let b=null,R=h.applyPackage(g=>(b=lo(g,o,s.partName),b.ok?b.pkg:g)),O=b;if(!O||!O.ok){u=`fragment-merge:${O?O.reason:"no-merge"}`,h.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}R&&(d=O.blocks.length,h.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:O.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return u.length>0?{ok:false,reason:"invalidArgs",detail:u}:m.ok?m.change?{ok:true,change:t.promoteStoryTransactionToPackageUnit(l,a,c),blockCount:d}:{ok:true,change:null,blockCount:d}:{ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}}},m=>Sa(m))}function Es(){let t=null;return (e,n,r)=>{let o=t;if(t=null,!uj(n)||!("paragraphId"in r)||!wj(e,r.paragraphId))return r;if(r.op==="insertText"&&!r.revision&&r.inside===void 0&&o&&o.partName===e.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=Xa(e,r.paragraphId);if(i?.kind!=="paragraph")return r;let a=Dk(e,Ck(r));if(a.unprotected.length)return r;let s=rg(i);for(let l of a.touches){let c=s.spanOf(l.control);c&&c.start<=r.start&&c.end>=r.end&&(t={partName:e.name,paragraphId:r.paragraphId,offset:r.start,controlId:l.control.id});}return r}}function mo(t,e){for(let[n,r]of e.parts){let o=t.parts.get(n);!o||o.root===r.root||o.root.id!==r.root.id||_a(o.root,r.root);}return e}var Ts=new WeakSet;function sd(t){return Ts.add(t),t}function ws(t){return Ts.has(t)}function Qt(t){return {...t,applyPackage:e=>t.applyPackage(sd(e))}}var ld=new Set(["insertText","insertTab","insertHardBreak","insertPageBreak","insertPageField","insertComplexField","insertEquation","insertDrawing","deleteText","setParagraphMarkRevision"]),Cs=new Set(["insertDrawing"]);function cd(t){if(!(t===null||t.start!==t.end))return t}var vt={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function dd(t){return Object.freeze({parts:new Map([[t.name,t]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[t.name.toLowerCase(),t.contentType]])},mainDocumentPart:t.name})}var ft=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];pushCount=0;subscribers=new Set;historyLimit;settingsPartOverride;contentLockPolicy;storyRef=null;composition=null;constructor(e,n,r={}){let o="root"in e,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?dd(e):e,this.storyPartName=i??(o?e.name:e.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart,this.contentLockPolicy=pj(a.contentLockPolicy);}setStoryRef(e){this.storyRef=e;}get part(){let e=this.current.parts.get(this.storyPartName);if(!e)throw new Error(`story part missing: ${this.storyPartName}`);return e}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get historyPushCount(){return this.pushCount}get compositionActive(){return this.composition!==null}graftPackage(e){this.current=e(this.current);}replacePart(e){let n=this.current.parts.get(e.name);e!==n&&(this.current=Ne(this.current,e),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(e){this.current=e.pkg,this.rev=e.revision,this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack),this.composition=e.composition?{entry:{...e.composition.entry},committed:e.composition.committed}:null;}restoreHistoryStacks(e){this.undoStack.length=0,this.undoStack.push(...e.undoStack),this.redoStack.length=0,this.redoStack.push(...e.redoStack);}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}transact(e,n={}){return Lb(n.actorId,()=>sf(n.fieldResults,()=>this.commitTransaction(e,n)))}commitTransaction(e,n){let r=n.origin??g.mutationHuman,o=n.recordsHistory??(r!==g.projection&&r!==g.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,c=null,d=0,u=new Set,m=new Set,f=new Set,h=new Set,b=new Set,R=[],O=n.minimumImpact??"text-local",g$1=null,p=false,P=null,M=null,F=new Map,$=new Map,w=A=>{let _=$.get(A.name);_||(_={mint:null,written:new Set},$.set(A.name,_));let V=_;return {mint:()=>(V.mint??=Ch(A))(),wrote:te=>{V.written.add(te);},wroteUnder:te=>V.written.has(te)}},L=()=>{for(let A of $.values())A.mint=null;},q=(A,_)=>{let V=dk$1.get(A.op);if(V===void 0)return F.clear(),null;let te=`${_.name}\0${V}`,oe=F.get(te);oe||(oe={id:null},F.set(te,oe));let de=oe;return ()=>de.id??=w(_).mint()},U=(A,_)=>{let V=ld.has(A.op);return !V&&dk$1.get(A.op)!==void 0?null:((!V||Cs.has(A.op))&&L(),V?w(_):null)},J=Es(),ee=null,B=(A,_)=>{if(c)return false;let V=l.parts.get(A);if(!V)return c={reason:"unknown-part",detail:A},false;_=J(V,this.settingsPartOverride?.()??fh(l),_);let te=tj(this.settingsPartOverride?.()??fh(l),_)??Ek(V,this.settingsPartOverride?.()??fh(l),_,ee?.partName===A&&"paragraphId"in _&&ee.paragraphId===_.paragraphId?ee.fieldNodeId:void 0);if(te)return c={reason:te},false;let oe=q(_,V),de=U(_,V),S=this.settingsPartOverride?.()??fh(l),k=uj(S)&&"paragraphId"in _&&wj(V,_.paragraphId)?yj(V,_,ee?.partName===A&&ee.paragraphId===_.paragraphId?ee.fieldNodeId:void 0):null;ee=k&&"paragraphId"in _?{partName:A,paragraphId:_.paragraphId,fieldNodeId:k.fieldNodeId}:null;let E={deferValidation:true,...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{},...oe?{revisionIds:oe}:{},...de?{trackedRevisionIds:de}:{}},N=k?Ml$1(V,_,k,E):Rl$1(V,_,E);if(!N.ok)return c={reason:N.reason,...N.detail?{detail:N.detail}:{}},false;if(Cs.has(_.op)&&L(),l=Ne(l,N.part),N.part===V&&N.effect.dirty.length===0&&N.effect.created.length===0&&N.effect.deleted.length===0&&N.effect.split===void 0&&(N.effect.splits===void 0||N.effect.splits.length===0)&&N.effect.join===void 0&&N.effect.caret===void 0)return true;u.add(A),d+=1;for(let Q of N.effect.dirty)m.add(Q);for(let Q of N.effect.created)f.add(Q);for(let Q of N.effect.deleted)h.add(Q);for(let Q of N.effect.dependencyKeys)b.add(Q);N.effect.split&&R.push({split:N.effect.split});for(let Q of N.effect.splits??[])R.push({split:Q});return N.effect.join&&R.push({join:N.effect.join}),vt[N.effect.impact]>vt[O]&&(O=N.effect.impact),N.effect.caret&&(M={paragraphId:N.effect.caret.paragraphId,start:0,end:0}),true};if(e({apply:A=>B(this.storyPartName,A),applyTo:(A,_)=>B(A,_),applyPackage:A=>{if(c)return false;let _=this.settingsPartOverride?.()??fh(l),V=ws(A)?sj(_,{op:"comment"}):tj(_);if(V)return c={reason:V},false;F.clear(),L();let te;try{te=A(l);}catch(oe){if(!kj(oe))throw oe;return c={reason:oe.reason,detail:oe.message},false}if(te===l)return true;for(let[oe,de]of te.parts)l.parts.get(oe)!==de&&u.add(oe);return l=te,d+=1,vt["flow-structural"]>vt[O]&&(O="flow-structural"),true},selectionBefore:A=>{g$1=A;},selectionAfter:A=>{p=true,P=A;}}),c){let A=c;return {ok:false,reason:A.reason,...A.detail?{detail:A.detail}:{}}}if(d===0)return {ok:true,change:null};let re=p?P:M,ue=p?cd(P):M??void 0;for(let A of u){let _=a.parts.get(A),V=l.parts.get(A);if(V===void 0)continue;let te=_?Ka(_,V):Ka(V,V);if(!te.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(te.issues)}}let le=Ye(l);if(!le.ok)return {ok:false,reason:"package-invariant",detail:JSON.stringify(le.issues)};if(o)if(this.composition)Ul$1(n.historyGroup,"split","composition"),this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:re}};else {let A=n.historyGroup,_=this.undoStack[this.undoStack.length-1];A!==void 0&&_!==void 0&&_.group===A?this.undoStack[this.undoStack.length-1]={..._,selectionAfter:re??_.selectionAfter}:this.pushUndo({pkg:a,revision:s,selectionBefore:g$1,selectionAfter:re,group:A}),Ul$1(A,_?.group===A?"extended":"started"),this.redoStack.length=0;}return this.current=l,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&vt[n.minimumImpact]>vt[O]&&(O=n.minimumImpact),{ok:true,change:this.publish(r,s,{dirty:m,created:f,deleted:h,dependencyKeys:b,splitJoin:R,impact:O,caret:ue},n.story??this.storyRef??void 0,n.actorId,n.operationId)}}beginComposition(e=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:e,selectionAfter:null},committed:false});}endComposition(){let e=this.composition;this.composition=null,!(!e||!e.committed)&&(this.pushUndo(e.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}closeHistoryGroup(){let e=this.undoStack[this.undoStack.length-1];e===void 0||e.group===void 0||(this.undoStack[this.undoStack.length-1]={...e,group:void 0});}undo(){let e=this.undoStack.pop();if(!e)return null;this.closeHistoryGroup();let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=mo(this.current,e.pkg),this.rev+=1,this.publish(g.mutationUndo,n,null,this.storyRef??void 0)}redo(){let e=this.redoStack.pop();if(!e)return null;this.closeHistoryGroup();let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}),this.current=mo(this.current,e.pkg),this.rev+=1,this.publish(g.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}discardNewestUndoEntry(){let e=this.undoStack.pop();return e?{selectionBefore:e.selectionBefore,selectionAfter:e.selectionAfter}:null}pushUndo(e){this.pushCount+=1,this.undoStack.push(e),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(e,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:e,...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}:{}};return sf("atomic",()=>{for(let l of this.subscribers)l(s);}),s}};function uo(t,e,n,r){if(!t)return null;if(t.kind==="package")return (r==="undo"?t.selectionBefore:t.selectionAfter)??null;let o=t.partName===e.part.name?e:n.get(t.partName);return (r==="undo"?o?.selectionForUndo():o?.selectionForRedo())??null}function Ms(t){let e=null,n;return {context:{selectionBefore(r){e=r,t.selectionBefore(r);},selectionAfter(r){n=r,t.selectionAfter(r);}},snapshot(r){return {selectionBefore:e,selectionAfter:n===void 0?r??null:n}}}}function po(t,e){return [...t.values()].map(n=>n.part).filter(n=>e.parts.has(n.name))}function As(t,e){return po(t,e).map(n=>n.name).sort().join(",")}function Ds(t,e,n){if(t.relationships!==e.relationships||t.contentTypes!==e.contentTypes||t.partBytes!==e.partBytes||t.externalTargets!==e.externalTargets||t.mainDocumentPart!==e.mainDocumentPart)return true;if(t.parts===e.parts)return false;if(t.parts.size!==e.parts.size)return true;for(let[r,o]of e.parts)if(r!==n&&t.parts.get(r)!==o)return true;return false}var _s="/word/numbering.xml";function Et(t,e){return t===void 0?void 0:{group:t,before:e}}function fo(t){return t.kind==="package"&&t.before.parts.get(_s)!==t.after.parts.get(_s)?{...t,restoreNumbering:true}:t}var Xn=class{open=null;close(){this.open=null;}admit(e,n,r,o,i){let a=this.open;if(n===void 0)return this.open=null,fo(e);if(a===null||a.group!==n.group||r.at(-1)!==a.pointer){let m=fo(e);return this.open={group:n.group,before:n.before,pointer:m},Ul$1(n.group,"started"),m}r.pop();let s=e.kind==="story"?o(e.partName):null,l=a.pointer.kind==="story"?o(a.pointer.partName):null,c=a.pointer.kind==="package"?a.pointer.selectionAfter??null:null,d={kind:"package",before:a.before,after:i(),selectionBefore:a.pointer.kind==="package"?a.pointer.selectionBefore??null:l?.selectionBefore??null,selectionAfter:(e.kind==="package"?e.selectionAfter:s?.selectionAfter)??c},u=fo(d);return this.open={...a,pointer:u},Ul$1(n.group,"extended"),u}};var qn="http://schemas.openxmlformats.org/wordprocessingml/2006/main",md="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Tt(t,e){for(let n of t.children)if(n.kind!=="textValue"&&n.namespaceUri===qn&&n.localName===e)return n;return null}function Yn(t,e){return t.attributes.find(n=>n.namespaceUri===qn&&n.localName===e)?.value}function ud(t){let e=Yn(t,"val");return e===void 0||e==="1"||e==="true"||e==="on"}function Ls(t,e){return t.kind==="textValue"?Object.freeze({...t,id:e()}):Object.freeze({...t,id:e(),children:t.children.map(n=>Ls(n,e))})}function pd(t){let e=Ma(`<w:styles xmlns:w="${qn}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:t.name,contentType:md});if(!e.ok)return null;let n=Tt(e.part.root,"style"),r=n?Tt(n,"pPr"):null;return r?Ls(r,Va(t)):null}var Fs=["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 fd(t,e){let n=Fs.indexOf(e),r=0;return t.forEach((o,i)=>{if(o.kind==="textValue")return;let a=Fs.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function Hs(t,e){let n=fd$1(t);if(!n)return null;let r=null;for(let c of n.root.children)if(c.kind!=="textValue"&&c.namespaceUri===qn&&c.localName==="style"&&Yn(c,"type")==="paragraph"&&Yn(c,"styleId")===e){r=c;break}if(!r)return null;let o=Tt(r,"name");if(o&&Yn(o,"val")?.trim().toLowerCase()!=="list paragraph"&&e!=="ListParagraph")return null;let i=pd(n);if(!i)return null;let a=Tt(i,"contextualSpacing");if(!a)return null;let s=Tt(r,"pPr"),l;if(s){let c=Tt(s,"contextualSpacing");if(c&&ud(c))return t;l=c?bb(n,c.id,a):ab(n,s.id,fd(s.children,"contextualSpacing"),[a]);}else {let c=r.children.findIndex(d=>d.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(d.localName));l=ab(n,r.id,c===-1?r.children.length:c,[i]);}return l.ok?Object.freeze({...t,parts:new Map([...t.parts,[n.name,l.part]])}):null}var js="http://schemas.openxmlformats.org/package/2006/relationships",Vs="application/vnd.openxmlformats-package.relationships+xml",yd="http://schemas.openxmlformats.org/package/2006/content-types",Us="/[Content_Types].xml",gt="/word/numbering.xml",$s="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",Zt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",xd=`<Override PartName="${gt}" ContentType="${Zt}"/>`;function Jn(t){return `${t.ownerPart}\0${t.id}`}function zs(t,e,n){let r=new Set(e.externalTargets.filter(s=>s.type===Ed$1).map(Jn)),o=n.externalTargets.filter(s=>s.type===Ed$1&&!r.has(Jn(s)));if(o.length===0)return t;let i=new Set(t.map(Jn)),a=o.filter(s=>!i.has(Jn(s)));return a.length===0?t:Object.freeze([...t,...a])}function Gs(t,e,n){let r=t.filter(o=>o.ownerPart===n||e.has(o.ownerPart));return r.length===t.length?t:Object.freeze(r)}function Ws(t,e,n=[],r=false){if(t===e)return t;let o=kd(t,e,r);return o=Od(o,e,n),o}function Ks(t,e){let n=new Set;for(let o of t.externalTargets)o.type===Ed$1&&o.ownerPart!==t.mainDocumentPart&&(t.parts.has(o.ownerPart)||e.has(o.ownerPart)||n.add(o.ownerPart));for(let o of t.parts.keys()){let i=Id(o);!i||i===t.mainDocumentPart||t.parts.has(i)||e.has(i)||t.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return t;let r=t;for(let o of n)r=Nd(r,o);return r}function kd(t,e,n){let r=e.parts.get(gt);if(!r)return t;let o=t.parts.get(gt),i=n&&o?Pd(o,r):r,a=Ne(t,i),s=(e.relationships.get(e.mainDocumentPart)??[]).find(c=>c.type===$s),l=a.relationships.get(a.mainDocumentPart)??[];if(s&&!l.some(c=>c.type===$s)&&!l.some(c=>c.id===s.id)){let c=Sd(a,{...s,ownerPart:a.mainDocumentPart});c&&(a=c);}if(a.contentTypes.overrides.get(C(gt))!==Zt){let c=vd(a);c&&(a=c);}return a}function Pd(t,e){let n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",r=l=>{if(l.kind==="textValue"||l.namespaceUri!==n)return null;let c=l.localName==="abstractNum"?"abstractNumId":l.localName==="num"?"numId":l.localName==="numPicBullet"?"numPicBulletId":null;if(!c)return null;let d=l.attributes.find(u=>u.namespaceUri===n&&u.localName===c)?.value;return d===void 0?null:`${l.localName}:${d}`},o=new Set(t.root.children.map(r).filter(Boolean)),i=Va(t),a=["numPicBullet","abstractNum","num","numIdMacAtCleanup"],s=t;for(let l of e.root.children){let c=r(l);if(!c||o.has(c)||l.kind==="textValue")continue;let d=a.indexOf(l.localName),u=s.root.children.findIndex(f=>f.kind!=="textValue"&&f.namespaceUri===n&&a.indexOf(f.localName)>d),m=ab(s,s.root.id,u<0?s.root.children.length:u,[go(l,i)]);m.ok&&(s=m.part,o.add(c));}return s}function Od(t,e,n){let r=n.filter(i=>i.type===Ed$1);if(r.length===0)return t;let o=t;for(let i of r){let a=bd(t,e,i.ownerPart);if(!a||o.externalTargets.some(c=>c.ownerPart===a&&c.id===i.id)||new Set((o.relationships.get(a)??[]).map(c=>c.id)).has(i.id))continue;let l=Rd(o,{ownerPart:a,id:i.id,type:Ed$1,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function bd(t,e,n){return n===e.mainDocumentPart?t.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function Sd(t,e){let n=t.mainDocumentPart,r=ho(n),o=t.parts.get(r),i=Ma(`<Relationships xmlns="${js}"><Relationship Id="${Y(e.id,"relationship id")}" Type="${Y(e.type,"relationship type")}" Target="${Y(e.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:Vs});if(!i.ok)return null;let a=t.relationships.get(n)??[];if(a.some(c=>c.id===e.id))return null;let s={...e,ownerPart:n,order:a.reduce((c,d)=>Math.max(c,d.order),-1)+1},l=new Map([...t.relationships,[n,[...a,s]]]);return o?Xs(t,o,i.part.root.children[0],l):Object.freeze({...t,parts:new Map([...t.parts,[r,i.part]]),relationships:l})}function Rd(t,e,n=t.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=ho(r),i=t.parts.get(o),a=Ma(`<Relationships xmlns="${js}"><Relationship Id="${Y(e.id,"relationship id")}" Type="${Ed$1}" Target="${Y(e.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:Vs});if(!a.ok)return null;let s=[...t.externalTargets,e];if(!i)return Object.freeze({...t,parts:new Map([...t.parts,[o,a.part]]),externalTargets:s});let l=Xs(t,i,a.part.root.children[0],t.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Xs(t,e,n,r){if(!n)return null;let o=Va(e),i=ab(e,e.root.id,e.root.children.length,[go(n,o)]);return i.ok?Object.freeze({...t,parts:new Map([...t.parts,[e.name,i.part]]),relationships:r}):null}function go(t,e){return t.kind==="textValue"?{...t,id:e()}:{...t,id:e(),children:t.children.map(n=>go(n,e))}}function ho(t){let e=t.lastIndexOf("/");return `${t.slice(0,e)}/_rels/${t.slice(e+1)}.rels`}function Id(t){let e=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(t);if(!e)return null;let n=e[1],r=e[2];return n===""||r===""?null:`${n}/${r}`}function Nd(t,e){let n=ho(e),r=new Map(t.parts);r.delete(n);let o=new Map(t.partBytes);o.delete(n);let i=new Map(t.relationships);i.delete(e);let a=Object.freeze(t.externalTargets.filter(s=>s.ownerPart!==e));return Object.freeze({...t,parts:r,partBytes:o,relationships:i,externalTargets:a})}function vd(t){let e=t.contentTypes.overrides.get(C(gt));if(e===Zt)return t;if(e!==void 0)return null;let n=t.partBytes.get(Us);if(!n)return null;let r=strFromU8(n),o=Bs(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+xd+r.slice(i),s=Bs(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Ys("Override",{PartName:gt,ContentType:Zt})];return s.children.length!==l.length||s.children.some((c,d)=>c!==l[d])?null:Object.freeze({...t,partBytes:new Map([...t.partBytes,[Us,strToU8(a)]]),contentTypes:Object.freeze({defaults:t.contentTypes.defaults,overrides:new Map([...t.contentTypes.overrides,[C(gt),Zt]])})})}function Bs(t){let e=ea(t);if(!e.ok)return null;let n=e.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"]!==yd)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(Ys(s.name,s.attributes));return {rootName:r.name,children:a}}function Ys(t,e){let n=Object.entries(e).map(([r,o])=>`${r}=${o}`).sort();return [t,...n].join("")}var qs=4e3,Js=64;function Qs(t){return qh(t,"footnote")!==null||qh(t,"endnote")!==null}function Zs(t,e,n,r){if(!Qs(t))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=Xa(e,n.paragraphId);return !o||o.kind!=="paragraph"?true:pg(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function el(t,e,n,r){if(!Qs(t))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=Xa(e,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=qs||l>Js)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return pg(s).some(c=>c.node.kind==="noteReference");for(let c of s.children)if(a(c,l+1))return true;return false};return a(o,0)}function tl(t,e,n){if(n.count>=qs||e>Js)return true;if(n.count+=1,t.kind==="textValue")return false;if(t.kind==="commentRangeStart"||t.kind==="commentRangeEnd"||t.kind==="commentReference")return true;for(let r of t.children)if(tl(r,e+1,n))return true;return false}function nl(t,e,n,r){if(!t())return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=Xa(e,o);return !i||i.kind==="textValue"?true:tl(i,0,{count:0})}var yo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",xo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function rl(t,e){let r=(t.relationships.get(t.mainDocumentPart)??[]).find(o=>o.id===e);return r?r.type!==yo&&r.type!==xo?{ok:false,reason:"wrong-relationship-type",detail:r.type}:Ed(t,r):{ok:false,reason:"dangling-relationship",detail:e}}function Ed(t,e){let n=N(e);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:e.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=t.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}var ko=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),Po=new Set(["authorTable","deleteTableRow","deleteTableColumn","mergeTableCells","removeContentControl","removeRepeatingSectionItem"]);function ht(t,e){return e.compositionActive||t.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function ol(t,e){let n=Xa(t,e);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function al(t,e,n){let r=t.parts.get(e);if(!r)return null;let o=Xa(r,n);return !o||o.kind!=="drawing"?null:Ud$1(o,{ownerPartName:e,supportedMcRequires:Nd$1,limits:Md$1,resolveRelationship:Pd$1(t,e)})}function il(t,e,n){let r=O(t.relationships.get(e)??[],e,n);return r.mode==="internal"?r.partName:null}function wt(t,e,n,r){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=ht(t,o.store);if(i)return i;let{store:a,story:s}=o;return Ra(t,()=>Td(t,a,s,n,r),l=>Sa(l))}function Td(t,e,n,r,o){let i=n.partName,a=t.currentPackage(),s=e.checkpoint();e.graftPackage(()=>t.currentPackage());let l=null,c=false,d=false,u=e.transact(h=>{if(o?.commitGuard?.()===false){d=true;return}if(o?.expectedPackageRevision!==void 0&&t.packageRevision!==o.expectedPackageRevision){c=true;return}let b=r(h,i);if(b===null){h.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}l=b;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(d)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!u.ok)return {ok:false,reason:u.reason,...u.detail?{detail:u.detail}:{}};if(!u.change)return {ok:true,change:null};let m=u.change.created.find(h=>{let b=e.part;return Xa(b,h)?.kind==="drawing"});return m&&(l=m),{ok:true,change:t.promoteStoryTransactionToPackageUnit(a,e,s),...l?{drawingNodeId:l}:{}}}function sl(t,e,n){let r=t.parts.get(e);if(!r)return null;let o=ol(r,n);return o?Dl$1(o):null}function Oo(t,e,n,r){let o=false;return t.applyPackage(i=>{let a=i.parts.get(e);if(!a)return i;let s=Xa(a,n);if(!s||s.kind!=="drawing")return i;let l=ol(a,n);if(!l)return i;let c=El$1(l,r),d=wd(s,c),u=bb(a,s.id,d,{deferValidation:true});return u.ok?(o=true,Ne(i,u.part)):i}),o}function wd(t,e){return {...t,children:t.children.map(n=>n.id===e.id?e:n)}}async function ll(t,e,n){let r=De$1(n.widthPoints),o=De$1(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=t.resolveStory(e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=ht(t,i.store);if(a)return a;let s=i.story.partName,l=await ye(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let c=l.bytes,d=Ae(t.currentPackage(),s,{bytes:c,mime:n.mime});if(!d.ok)return {ok:false,reason:"invalidArgs",detail:d.reason==="invalid-image"?"invalid-image":d.reason};let u=d.partName,m=wt(t,e,(f,h)=>{let b=t.currentPackage(),R=Ae(b,h,{bytes:c,mime:n.mime});if(!R.ok)return null;b=R.pkg,u=R.partName;let O;if(n.hyperlink){let p=Ug(b,n.hyperlink,h);if(!p)return null;b=p.pkg,O=p.relationshipId;}if(!f.applyPackage(()=>b))return null;let g=Ee({docPrId:R.docPrId,relationshipId:R.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...O?{hyperlinkRelationshipId:O}:{}});return f.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:g,...n.revision?{revision:n.revision}:{}})?g.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return m.ok?m.change?{...m,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:m}async function bo(t,e,n,r,o,i,a){let s=t.resolveStory(e);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=ht(t,s.store);if(l)return l;let c=s.story.partName,d=await ye(i,r,o);if(!d.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=d.bytes,m=Ae(t.currentPackage(),c,{bytes:u,mime:o});return m.ok?wt(t,e,(f,h)=>{let b=t.currentPackage(),R=al(b,c,n),O=R?.picture?.embeddedRelationshipId??null,g=R?.picture?.linkedRelationshipId??null,p=O??g;if(!p)return null;let P=O!==null?il(b,c,O):null,M=b,F=Ae(M,h,{bytes:u,mime:o});return !F.ok||(M=F.pkg,!f.applyPackage(()=>M))||!f.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:F.relationshipId})?null:(f.applyPackage($=>Ge($,h,P,p)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:m.reason==="invalid-image"?"invalid-image":m.reason}}function cl(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=ht(t,r.store);if(o)return o;let i=r.story.partName,a=t.currentPackage(),s=a.parts.get(i),l=al(a,i,n)??(s?ul$1(s,n):null);if(!l)return {ok:false,reason:"unknown-drawing"};let c=l.picture?.embeddedRelationshipId??null,d=l.picture?.linkedRelationshipId??null,u=c??d,m=c!==null?il(a,i,c):null;return wt(t,e,(f,h)=>f.apply({op:"deleteDrawing",drawingNodeId:n})?(f.applyPackage(b=>Ge(b,h,m,u)),n):null)}function Cd(t,e){let n=null,r=i=>{let a=false,s=false,l=(c,d)=>{if(a||c.kind==="textValue")return;if(c.id===e){a=true,s=d;return}let u=d||c.kind==="revisionDelete"||c.kind==="revisionMoveFrom";for(let m of c.children)l(m,u);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=rg(i).spanOf(e);if(a!==null&&a.end>a.start){let s=Xa(t,e);if(!s||s.kind!=="drawing"&&!Qd$1(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(t.root),n}function dl(t,e,n,r){let o=t.resolveStory(e);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=ht(t,o.store);if(i)return i;let a=t.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=Cd(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:wt(t,e,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 ml(t,e,n,r,o,i,a,s){let l=await He(o,r,i,void 0,a);return l.ok?bo(t,e,n,l.bytes,l.mime,a,{expectedPackageRevision:t.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function ul(t,e,n,r,o,i){let a=t.resolveStory(e);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=ht(t,a.store);return s||wt(t,e,(l,c)=>{let d=sl(t.currentPackage(),c,n),u=null;if(i!==null){let f=Ug(t.currentPackage(),i,c);if(!f||!l.applyPackage(()=>f.pkg))return null;u=f.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!Oo(l,c,n,u))return null}else if(i===null&&!Oo(l,c,n,null))return null;let m=false;return l.applyPackage(f=>{let h=Wg(f,c,d);return h===null?(m=true,f):h}),m?null:n})}function pl(t,e,n){let r=t.resolveStory(e);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=ht(t,r.store);return o||wt(t,e,(i,a)=>{let s=sl(t.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let d=Ug(t.currentPackage(),n.hyperlink,a);if(!d||!i.applyPackage(()=>d.pkg))return null;l=d.relationshipId;}for(let d of n.ops)if(!i.apply(d))return null;if(!Oo(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let c=false;return i.applyPackage(d=>{let u=Wg(d,a,s);return u===null?(c=true,d):u}),c?null:n.drawingNodeId})}function Md(t,e){if(t===e)return true;if(t.byteLength!==e.byteLength)return false;for(let n=0;n<t.byteLength;n+=1)if(t[n]!==e[n])return false;return true}function fl(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t)if(e.get(n)!==r)return false;return true}function Ad(t,e){return t===e||t.ownerPart===e.ownerPart&&t.id===e.id&&t.type===e.type&&t.rawTarget===e.rawTarget&&t.targetMode===e.targetMode&&t.order===e.order}function Dd(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let o=e.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!Ad(i,o[a])))return false}return true}function _d(t,e){return t===e?true:t.length!==e.length?false:t.every((n,r)=>{let o=e[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 Fd(t,e){if(t===e)return true;if(t.size!==e.size)return false;for(let[n,r]of t){let o=e.get(n);if(!o||!Md(r,o))return false}return true}function Ld(t,e){return t.contentTypes===e.contentTypes||fl(t.contentTypes.defaults,e.contentTypes.defaults)&&fl(t.contentTypes.overrides,e.contentTypes.overrides)}var Qn=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),Ct=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function gl(t){for(let[e,n]of t)if(!Ha(e,n)||!Ia(n.root,e.root).idsPreserved)return Ct;return Qn}function Hd(t,e){if(t===e)return Qn;if(t.mainDocumentPart!==e.mainDocumentPart||t.parts.size!==e.parts.size||!Fd(t.partBytes,e.partBytes)||!Dd(t.relationships,e.relationships)||!_d(t.externalTargets,e.externalTargets)||!Ld(t,e))return Ct;let n=[];for(let[a,s]of t.parts){let l=e.parts.get(a);if(!l)return Ct;s!==l&&n.push([s,l]);}if(n.length===0)return Qn;let[r,o]=n[0];if(n.length>1||r.name!==t.mainDocumentPart)return gl(n);let i=Ia(o.root,r.root);return i.undecided?gl(n):i.equal&&i.idsPreserved?Qn:i.equal?i.renamedOutsideParagraphs||i.renamedParagraphIds.length===0?Ct:{equal:false,dirty:i.renamedParagraphIds,dependencyKeys:[l.story],impact:"text-local"}:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?Ct:{equal:false,dirty:i.paragraphIds,dependencyKeys:[l.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function So(t){return {ok:false,reason:"package-invariant",detail:t}}function Ud(t,e){if(!t.parts.get(t.mainDocumentPart))return So("no-main-document");for(let[r,o]of t.parts){let i=e?.parts.get(r);if(i===o)continue;let a=i?Ka(i,o):Ja(o);if(!a.ok)return So(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=Ye(t);return n.ok?null:So(n.issues[0]?.code??"package-invariant")}function hl(t,e,n){let r=t.currentPackage(),o=Hd(e,r);if(o.equal)return {ok:true,change:null};let i=Ud(e,r);if(i)return i;let a=t.bodyStore().part.name,s=o.impact!=="global"&&e.mainDocumentPart===a;return Ra(t,()=>{let l=t.packageRevision;return t.installAuthoritativePackageSnapshot(e),{ok:true,change:t.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 $d(t,e,n,r){let o=[...e],i=new Set;for(let a of o)t.parts.has(a)&&i.add(a);for(let a of n)yl(a,o,i);for(let a of r)yl(a,o,i);return i}function Bd(t,e,n,r,o){let i=new Set(t);i.add(e),i.add(n);for(let a of r)xl(a,i);for(let a of o)xl(a,i);return i}function yl(t,e,n){if(t.kind==="story"){n.add(t.partName);return}for(let r of e)(t.before.parts.has(r)||t.after.parts.has(r))&&n.add(r);}function xl(t,e){if(t.kind==="story"){e.add(t.partName);return}for(let n of t.before.parts.keys())e.add(n);for(let n of t.after.parts.keys())e.add(n);}function kl(t){let{stories:e,rIdToPartName:n,undoOrder:r,redoOrder:o}=t,i=$d(t.pkg,e.keys(),r,o);for(let[l]of [...e])if(!i.has(l)){e.delete(l);for(let[c,d]of [...n])d===l&&n.delete(c);}let a=Bd(i,t.pkg.mainDocumentPart,t.bodyPartName,r,o),s=Ks(t.pkg,a);return {pkg:s,shellHyperlinks:Gs(t.shellHyperlinks,a,s.mainDocumentPart)}}function Pl(t,e,n,r,o,i){return {change:"model-change",fromRevision:Math.max(0,e-1),toRevision:e,commitId:`pkg-commit-${t}`,origin:n,dirty:[],created:[...i],deleted:[],splitJoin:[],dependencyKeys:[],impact:r,story:o}}var Ol=64,en=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];historyGroups=new Xn;subscribers=new Set;historyLimit;contentLockPolicy;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;storyStoreOptions(){return {historyLimit:this.historyLimit,settingsPart:()=>fh(this.pkg),...this.contentLockPolicy?{contentLockPolicy:this.contentLockPolicy}:{}}}constructor(e,n,r={}){this.pkg=Ne(e,n),this.historyLimit=r.historyLimit??200,this.contentLockPolicy=pj(r.contentLockPolicy),this.maxEditableStoryParts=r.maxEditableStoryParts??Ol,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??ji$1,this.body=new ft(this.pkg,n.name,this.storyStoreOptions()),this.body.setStoryRef({kind:"body",partName:n.name}),Vl$1(this,{current:()=>this.undoOrder.at(-1)??null,split:()=>{this.closeHistoryGroups(),this.redoOrder.length=0;}});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let e=this.currentPackageMemo;if(e&&e.pkg===this.pkg&&e.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(e.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===e.storyParts.length)return e.result}let n=Ne(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=Ne(n,o.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}resolveStory(e){return e.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:e.kind==="notesPart"?e.noteKind!=="footnote"&&e.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(e.noteKind)}:this.openNotesPartStore(e.noteKind):e.kind!=="headerFooter"||typeof e.rId!="string"||e.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(e.kind)}:this.openHeaderFooterStore(e.rId)}partFor(e){let n=this.resolveStory(e);return n.ok?n.store.part:null}revisionFor(e){let n=this.resolveStory(e);return n.ok?n.store.revision:null}transact(e,n,r={}){return Ra(this,()=>this.commitStoryTransaction(e,n,r),Sa,r.historyGroup)}commitStoryTransaction(e,n,r={}){let o=this.resolveStory(e);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.historyPushCount,c=i.compositionActive,d=i.checkpoint(),u=false,m=new Set,f=false,h,b=new Set,R=false,O,g=false,p;i.graftPackage(()=>this.currentPackage());let P=i.transact($=>{p=Ms($),n({...$,applyTo:(w,L)=>{let q=$.applyTo(w,L);return q&&w!==a.partName&&(g=true),q},applyPackage:w=>$.applyPackage(L=>{let q=w(L);return q!==L&&!g&&(g=Ds(L,q,a.partName)),q}),apply:w=>(w.op==="setListNumbering"&&w.numId!==null&&(R=true),w.op==="setParagraphProperties"&&(O??=w.properties.find(L=>L.localName==="pStyle")?.attributes?.val),u||(w.op==="deleteText"&&Zs(this.pkg,i.part,w,m)||w.op==="deleteBlock"&&el(this.pkg,i.part,w,m)||ko.has(w.op)||Po.has(w.op))&&(u=true),f||(w.op==="deleteText"||w.op==="deleteBlock"?f=nl(()=>h??=si(this.pkg),i.part,w,b):(ko.has(w.op)||Po.has(w.op))&&(f=true)),$.apply(w)),...p.context});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!P.ok)return {ok:false,reason:P.reason,...P.detail?{detail:P.detail}:{}};this.syncPackageFromStore(i);let M=false;if(P.change&&g&&(this.installPackageSnapshotInternal(i.package,false),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),M=true),R&&O){let $=Hs(this.pkg,O);$&&this.replacePackageShell($);}let F=false;if(P.change&&u){let $=this.currentPackage(),w=this.cascadeNoteReferences(s,$);if(w===null)return i.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};w!==$&&(this.installPackageSnapshotInternal(w),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),F=true);}if(P.change&&f){let $=this.currentPackage(),w=wi$1(s,$,{storyPartName:a.partName});if(w===null)return i.restoreCheckpoint(d),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};w!==$&&(this.installPackageSnapshotInternal(w),c?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(d),F=true);}if(P.change){this.packageRev+=1;let $=F||M;if(!c&&r.recordsHistory!==false&&(i.historyPushCount>l||$))if($)this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage(),...p?.snapshot(P.change.caret)},Et(r.historyGroup,s));else {let L=Et(r.historyGroup,s);this.pushUndoPointer({kind:"story",partName:a.partName,story:a},L);}let w=$?this.publishSynthetic(P.change.origin,"global",a,P.change.created):P.change;return $||this.publish(w),{ok:true,change:w}}return {ok:true,change:P.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(e,n=null){let r=this.resolveStory(e);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(e),!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 e=this.compositionSession;if(this.compositionSession=null,!e){this.body.endComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return;let r=n.historyPushCount;if(n.endComposition(),e.packageWideEffects){n.restoreHistoryStacks(e.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:e.beforePackage,after:this.currentPackage()});return}if(n.historyPushCount>r){let o=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);o&&this.pushUndoPointer({kind:"story",partName:e.partName,story:o});}this.syncPackageFromStore(n);}cancelComposition(){let e=this.compositionSession;if(this.compositionSession=null,!e){this.body.cancelComposition();return}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(e.packageWideEffects){n&&n.restoreCheckpoint(e.storyCheckpoint),this.installPackageSnapshotInternal(e.beforePackage),this.packageRev+=1;let r=e.partName===this.body.part.name?{kind:"body",partName:e.partName}:this.storyRefForPart(e.partName);this.publishSynthetic(g.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(e,n={}){let r=()=>this.commitLifecycleOp(e,n.historyGroup);return Lb(n.actorId,()=>Ra(this,r,Sa,n.historyGroup))}commitLifecycleOp(e,n){let r=this.currentPackage(),o=sj(fh(r),e);if(o)return {ok:false,reason:o};if(hi(e)){let c=ii(r,e);if(!c.ok)return {ok:false,reason:c.reason,...c.detail?{detail:c.detail}:{}};if(c.package===r)return {ok:true,change:null};this.installPackageSnapshotInternal(c.package);let d=Et(n,r);this.pushUndoPointer({kind:"package",before:r,after:c.package},d),this.packageRev+=1;let u={kind:"body",partName:this.body.part.name},m=this.publishSynthetic(g.mutationHuman,c.impact,u,c.createdPartName?[c.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:m}}if(!_g(e))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let i=$g(r,e);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};this.installPackageSnapshotInternal(i.package);let a=Et(n,r);this.pushUndoPointer({kind:"package",before:r,after:i.package},a),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(g.mutationHuman,i.impact,s,i.createdPartName?[i.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}undo(){let e=this.undoOrder.pop();if(!e)return null;if(this.closeHistoryGroups(),e.kind==="package"){this.installPackageSnapshotInternal(e.before,true,e.restoreNumbering),this.redoOrder.push(e),this.packageRev+=1;let o=this.publishSynthetic(g.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let e=this.redoOrder.pop();if(!e)return null;if(this.closeHistoryGroups(),e.kind==="package"){this.installPackageSnapshotInternal(e.after,true,e.restoreNumbering),this.undoOrder.push(e),this.packageRev+=1;let o=this.publishSynthetic(g.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=e.partName===this.body.part.name?this.body:this.stories.get(e.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(e),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){return uo(this.undoOrder.at(-1),this.body,this.stories,"undo")}selectionForRedo(){return uo(this.redoOrder.at(-1),this.body,this.stories,"redo")}openStoryParts(){return po(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return As(this.stories,this.pkg)}insertImage(e,n){return ll(this,e,n)}applyFragmentPaste(e,n){return co(this,e,n)}replaceImage(e,n,r,o,i,a){return bo(this,e,n,r,o,i,a)}deleteImage(e,n){return cl(this,e,n)}deleteImageTracked(e,n,r){return dl(this,e,n,r)}embedExternalImage(e,n,r,o,i,a,s){return ml(this,e,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(e,n,r,o,i){return ul(this,e,n,r,o,i)}applyImageProperties(e,n){return pl(this,e,n)}promoteStoryTransactionToPackageUnit(e,n,r,o){this.installPackageSnapshotInternal(n.package,false),n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:e,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(g.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(e){return e?(this.packageRev+=1,this.publish(e),e):null}adoptPackageUnit(e){this.adoptGroupedPackageUnit(e,void 0);}adoptGroupedPackageUnit(e,n){let r=this.currentPackage();e!==r&&this.pushUndoPointer({kind:"package",before:e,after:r},Et(n,e));}installPackageSnapshot(e){this.installPackageSnapshotInternal(e);}installAuthoritativePackageSnapshot(e){this.installPackageSnapshotInternal(e,false);}publishRemotePackage(e,n){return hl(this,e,n)}replacePackageShell(e){this.shellHyperlinks=zs(this.shellHyperlinks,this.pkg,e);let n=e;n=Ne(n,this.body.part);for(let r of this.stories.values())e.parts.has(r.part.name)&&(n=Ne(n,r.part));this.pkg=n;}installPackageSnapshotInternal(e,n=true,r=false){let o=n?Ws(e,this.pkg,this.shellHyperlinks,r):e,i=o.parts.get(o.mainDocumentPart);if(!i)return;this.body.replacePart(i);for(let[s,l]of this.stories){let c=o.parts.get(s);c&&l.replacePart(c);}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=N(s);l.mode!=="Internal"||!l.target.ok||this.stories.has(l.target.partName)&&o.parts.has(l.target.partName)&&this.rIdToPartName.set(s.id,l.target.partName);}this.pkg=o,this.pkg=Ne(this.pkg,this.body.part);for(let s of this.stories.values())this.pkg.parts.has(s.part.name)&&(this.pkg=Ne(this.pkg,s.part));}openNotesPartStore(e){let n=qh(this.currentPackage(),e);if(!n)return {ok:false,reason:"missing-part",detail:e};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:e},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=Ib(n),i=new ft(o,this.storyStoreOptions()),a={kind:"notesPart",partName:o.name,noteKind:e};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=Ne(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(e){let n=this.rIdToPartName.get(e);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:e},store:l}}let r=rl(this.currentPackage(),e);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(e,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:e},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=Ib(r.part),a=new ft(i,this.storyStoreOptions()),s={kind:"headerFooter",partName:i.name,rId:e};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(e,i.name),i!==r.part&&(this.pkg=Ne(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(e){if(e===this.body.part.name)return {kind:"body",partName:e};for(let[r,o]of this.rIdToPartName)if(o===e)return {kind:"headerFooter",partName:e,rId:r};let n=this.currentPackage().parts.get(e);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:e,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:e,noteKind:"endnote"}:null}syncPackageFromStore(e){this.pkg=Ne(this.pkg,e.part);}closeHistoryGroups(){Sl$1(this.body,this.stories,null),this.historyGroups.close();}pushUndoPointer(e,n){e=this.historyGroups.admit(e,n,this.undoOrder,r=>(r===this.body.part.name?this.body:this.stories.get(r))?.discardNewestUndoEntry()??null,()=>this.currentPackage()),Sl$1(this.body,this.stories,e),this.undoOrder.push(e),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let e=kl({pkg:this.pkg,stories:this.stories,rIdToPartName:this.rIdToPartName,bodyPartName:this.body.part.name,shellHyperlinks:this.shellHyperlinks,undoOrder:this.undoOrder,redoOrder:this.redoOrder});this.pkg=e.pkg,this.shellHyperlinks=e.shellHyperlinks;}publish(e){this.lastChange=e;for(let n of this.subscribers)n(e);}publishSynthetic(e,n,r,o){this.commitCounter+=1;let i=Pl(this.commitCounter,this.packageRev,e,n,r,o);return this.publish(i),i}};var jd=256,Vd=65535,bl=64;function Zn(t,e){return t.length>e}function Sl(t){return typeof t!="string"||t.trim().length===0?"invalid-author":Zn(t,jd)?"resource-limit":X$1(t)?null:"invalid-author"}function Rl(t){return typeof t!="string"||t.length===0?"invalid-text":Zn(t,Vd)?"resource-limit":X$1(t)?null:"invalid-text"}function Ro(t){if(typeof t!="string")return {ok:false,rejection:"invalid-date"};let e=t.trim();if(Zn(e,bl))return {ok:false,rejection:"resource-limit"};if(!X$1(e))return {ok:false,rejection:"invalid-date"};let n=hg(e);return n===null?{ok:false,rejection:"invalid-date"}:Zn(n,bl)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function rh(t){if(t===void 0)return null;let e=Ro(t);return e.ok?null:e.rejection}function Io(t){switch(t){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 zd(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function No(t,e){if(!t){let a=Mb(e);return a?Ob(new Set,a,Jb):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=zd(a,pa,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=Jb&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(t.root);let i=Mb(e);return i?Ob(r,i,Jb):String(n+1)}function Il(t,e){if(t.kind==="textValue")return t;let n=e.get(t.id);if(n!==void 0)return n;let r=false,o=[];for(let i of t.children){let a=Il(i,e);a!==i&&(r=true),o.push(a);}return r?{...t,children:o}:t}function Kd(t,e,n){let r=Il(t.root,e);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:t.root.id,nodeId:t.root.id}]};let o=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:ua}]};return bb(t,t.root.id,o,{deferValidation:true})}function Nl(t,e,n){let r=new Map;for(let i of e){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=t;for(let[i,a]of r){let s=o.parts.get(i);if(!s)return null;let l=Eb(s.root),c=l??"w14",d=new Map;for(let m of a.values())d.set(m.paragraph.id,n(m.paragraph,m.paraId,c));let u=Kd(s,d,l===null?c:null);if(!u.ok)return null;o=Ne(o,u.part);}return o}function vl(t,e,n){let r=t.root.children.map(o=>o.kind==="textValue"?o:e.get(o.id)??o);return $a(t,t.root.id,[...r,...n],{deferValidation:true})}var wl="/word/comments.xml",Cl="/word/commentsExtended.xml",Co="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Mo="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Xd=[Mo,"application/vnd.ms-word.commentsExtended+xml"],Ml="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Ao="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",et="http://schemas.microsoft.com/office/word/2012/wordml";function nn(t,e,n){for(let r of t.attributes)if(r.localName===n&&r.namespaceUri===e)return r.value}function Mt(t,e){return {kind:"genericExtension",namespaceUri:pa,localName:t,prefix:"w",value:e}}function Ve(t,e,n,r,o,i,a,s=[]){return {id:t,kind:e,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function Al(t,e,n,r,o){let i=e===t.mainDocumentPart?[e]:[e,t.mainDocumentPart];for(let a of i)for(let s of Pe(t,a)){if(s.type!==n)continue;let l=E(a,s.rawTarget);if(!l.ok)continue;if(!t.parts.has(l.partName))return l.partName;let c=Qe$1(t,l.partName);if(c!==null&&(typeof r=="string"?c===r:r.includes(c)))return l.partName}return o}function vo(t,e,n){let r=t.mainDocumentPart;for(let i of Pe(t,r)){if(i.type!==e)continue;let a=E(r,i.rawTarget);if(a.ok&&a.partName===n)return t}let o=Ve$1(t,r);return We(o,r,e,Ji$1(r,n)).pkg}function Do(t,e){return Al(t,e,Ml,Co,wl)}function Dl(t,e){let n=ce(t,e),r=de(t,e,n).extended;return r!==null?r:Al(t,e,Ao,Xd,Cl)}function El(t){let e=new Set;for(let n of t.parts.values())for(let r of Db(n.root))e.add(r);return e}function Yd(t,e){if(!t)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,pa,"id")===e){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=nn(a,ua,"paraId");s!==void 0&&zb(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(t.root),n}function qd(t,e){if(!t)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&nn(o,pa,"id")===e){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(t.root),n}function _l(t){let e=Eb(t.root);if(e!==null)return {part:t,prefix:e};let n={...t.root,namespaceBindings:[...t.root.namespaceBindings,{prefix:"w14",namespaceUri:ua}]},r=bb(t,t.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(Za(t.root,n),{part:{...t,root:n},prefix:"w14"})}function Fl(t,e,n){return Ve(t.id,"paragraph",t.namespaceUri,t.prefix??"w",t.localName,[...t.attributes.filter(r=>!(r.namespaceUri===ua&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:ua,localName:"paraId",prefix:n,value:e}],t.children,t.namespaceBindings)}function Jd(t,e,n,r){let o=t.parts.get(e);if(!o)return t;let i=_l(o),a=Xa(i.part,n);if(!a||a.kind!=="paragraph")return Ne(t,i.part);let s=bb(i.part,a.id,Fl(a,r,i.prefix),{deferValidation:true});return Ne(t,s.ok?s.part:i.part)}function Qd(t,e,n,r){let o=`${wl}#comment-${t}`,i=n.text!==n.text.trim(),a=Ve(`${o}.t`,"text",pa,"w","t",i?[{kind:"xmlSpace",namespaceUri:qa,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=Ve(`${o}.rPr`,"runProperties",pa,"w","rPr",[],[Ve(`${o}.rStyle`,"generic",pa,"w","rStyle",[Mt("val","CommentReference")],[])]),l=Ve(`${o}.r`,"run",pa,"w","r",[],[s,a]),c=Ve(`${o}.pPr`,"paragraphProperties",pa,"w","pPr",[],[Ve(`${o}.pStyle`,"generic",pa,"w","pStyle",[Mt("val","CommentText")],[])]),d=Ve(`${o}.p`,"paragraph",pa,"w","p",[{kind:"genericExtension",namespaceUri:ua,localName:"paraId",prefix:r,value:e}],[c,l]);return Ve(o,"comment",pa,"w","comment",[Mt("id",t),Mt("author",n.author),...n.initials===void 0?[]:[Mt("initials",n.initials)],...n.date===void 0?[]:[Mt("date",n.date)]],[d])}function Eo(t,e){let n=Ma(e,{name:t,contentType:"application/xml"});return n.ok?n.part.root:null}function _o(t,e){for(let O of [Sl(e.author),Rl(e.text)])if(O)return {ok:false,reason:Io(O)};let n;if(e.date!==void 0){let O=Ro(e.date);if(!O.ok)return {ok:false,reason:Io(O.rejection)};n=O.value;}let r={...e,...n===void 0?{}:{date:n}},o=t.package,i=t.part.name,a=Do(o,i),s=Dl(o,i),l=o.parts.get(a),c=No(l,r.actorId),d=Cb(`${a}#${c}`,El(o)),u=e.replyToCommentId===void 0?null:Yd(l,e.replyToCommentId),m=e.replyToCommentId!==void 0&&u===null?qd(l,e.replyToCommentId):null;if(e.replyToCommentId!==void 0&&u===null&&!m)return {ok:false,reason:"unknown-revision"};let f=m?Cb(`${a}#parent-${e.replyToCommentId}`,new Set([...El(o),d])):null,h=u??f,b=e.anchor.endParagraphId??e.anchor.paragraphId,R=t.transact(O=>{let g=Qt(O);g.applyPackage(p=>{let P=p.parts.has(a)?p:(()=>{let M=Eo(a,`<w:comments xmlns:w="${pa}"/>`);return M?Xe(p,a,M,Co):null})();return P===null?p:vo(P,Ml,a)}),m&&f&&g.applyPackage(p=>Jd(p,a,m.id,f)),g.applyPackage(p=>{let P=p.parts.get(a);if(!P)return p;let M=_l(P),F=ab(M.part,M.part.root.id,M.part.root.children.length,[Qd(c,d,r,M.prefix)],{deferValidation:true});return F.ok?Ne(p,F.part):p}),h!==null&&(g.applyPackage(p=>{let P=p.parts.has(s)?p:(()=>{let M=Eo(s,`<w15:commentsEx xmlns:w15="${et}"/>`);return M?Xe(p,s,M,Mo):null})();return P===null?p:vo(P,Ao,s)}),g.applyPackage(p=>{let P=p.parts.get(s);if(!P)return p;let F=[...Zd(P).has(h.toUpperCase())?[]:[wo(`${s}#ex-${h}`,h,void 0,false)],wo(`${s}#ex-${d}`,d,h,false)],$=ab(P,P.root.id,P.root.children.length,F,{deferValidation:true});return $.ok?Ne(p,$.part):p})),g.applyTo(i,{op:"insertCommentMarker",paragraphId:b,offset:e.anchor.end,commentId:c,marker:"reference"}),g.applyTo(i,{op:"insertCommentMarker",paragraphId:b,offset:e.anchor.end,commentId:c,marker:"end"}),g.applyTo(i,{op:"insertCommentMarker",paragraphId:e.anchor.paragraphId,offset:e.anchor.start,commentId:c,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return R.ok?{ok:true,commentId:c,change:R.change}:{ok:false,reason:R.reason}}function To(t){for(let e=t.children.length-1;e>=0;e-=1){let n=t.children[e];if(n.kind==="paragraph")return n}return null}function Tl(t){let e=To(t);if(!e)return null;let n=nn(e,ua,"paraId");return n!==void 0&&zb(n)?n.toUpperCase():null}function Zd(t){let e=new Map;if(!t)return e;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===et&&r.localName==="commentEx"){let o=nn(r,et,"paraId");o!==void 0&&zb(o)&&e.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(t.root),e}function tn(t,e){return {kind:"genericExtension",namespaceUri:et,localName:t,prefix:"w15",value:e}}function em(t,e){return {id:t.id,kind:"generic",namespaceUri:t.namespaceUri,localName:t.localName,...t.prefix===void 0?{}:{prefix:t.prefix},namespaceBindings:t.namespaceBindings,attributes:e,children:t.children}}function tm(t,e,n){let r=[],o=false,i=false;for(let a of t.attributes){if(a.namespaceUri===et&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===et&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&e!==void 0&&r.push(tn("paraIdParent",e)),o||r.push(tn("done",n?"1":"0")),em(t,r)}function wo(t,e,n,r){return {id:t,kind:"generic",namespaceUri:et,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[tn("paraId",e),...n===void 0?[]:[tn("paraIdParent",n)],tn("done",r?"1":"0")],children:[]}}function Fo(t,e,n){return nm(t,e,n,be())}function nm(t,e,n,r){let o=t.package,i=t.part.name;if(ce(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=li(o,e,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=ee(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let c=l.used,d=new Map,u=[];for(let b of s.ids){let R=s.records.get(b);if(!R)return {ok:false,reason:"unknown-comment"};if(!To(R.node))return {ok:false,reason:"unknown-comment"};let g=Tl(R.node),p=g??Cb(`${R.partName}#done-${b}`,c);g===null&&c.add(p),d.set(b,p);}for(let b of s.ids){let R=s.records.get(b),O=To(R.node),g=d.get(b),p=Tl(R.node),P=s.parentCommentIdByChildId.get(b),M=s.parentParaIdByCommentId.get(b)??(P===void 0?void 0:d.get(P)),F=s.commentExByParaId.get(g);u.push({paraId:g,stampParagraph:p===null?O:null,commentsPartName:R.partName,parentParaId:M,existing:F?.node,existingParentParaId:F?.parentParaId,existingDone:F?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(b=>b.existingDone===n))return {ok:true,changed:false,change:null};let m=s.extendedPartName??Cl,f=s.extendedPartName===null,h=t.transact(b=>{Qt(b).applyPackage(O=>{let g=Nl(O,u,Fl);if(g===null)return O;let p=g;if(!p.parts.has(m)){let w=Eo(m,`<w15:commentsEx xmlns:w15="${et}"/>`);if(!w)return O;let L=Xe(p,m,w,Mo);p=f?vo(L,Ao,m):L;}let P=p.parts.get(m);if(!P)return O;let M=new Map,F=[];for(let w of u){let L=w.existingParentParaId??w.parentParaId;w.existing?M.set(w.existing.id,tm(w.existing,L,n)):F.push(wo(`${m}#done-${w.paraId}`,w.paraId,L,n));}let $=vl(P,M,F);return $.ok?Ne(p,$.part):O});});return h.ok?{ok:true,changed:true,change:h.change}:{ok:false,reason:h.reason}}function rm(t,e){let n=Do(t,e);return t.parts.has(n)&&Qe$1(t,n)===Co}function om(t,e){return Do(t,e)}function am(t,e){return Dl(t,e)}var Ll={kind:"body"};function im(t,e,n=Ll,r){let o=n.kind==="body"?null:t.resolveStory(n),i=o?.ok?o.store:t.bodyStore(),a=t.currentPackage(),s=i.checkpoint();return i.graftPackage(()=>t.currentPackage()),Ra(t,()=>{let l=_o(i,e);return l.ok&&(i.restoreHistoryStacks(s),t.replacePackageShell(i.package),t.adoptGroupedPackageUnit(a,r),t.publishStoryWrite(l.change)),l},l=>Sa(l),r)}function sm(t,e,n,r){let o=t.bodyStore(),i=t.currentPackage(),a=sj(fh(i),{op:"setCommentResolved"});if(a)return {ok:false,reason:a};let s=o.checkpoint();return o.graftPackage(()=>t.currentPackage()),Ra(t,()=>{let l=Fo(o,e,n);return !l.ok||!l.changed||(o.restoreHistoryStacks(s),t.replacePackageShell(o.package),t.adoptGroupedPackageUnit(i,r),t.publishStoryWrite(l.change)),l},l=>l.ok&&l.changed,r)}function lm(t,e,n=Ll,r,o){if(e.length===0||sj(fh(t.currentPackage()),{op:"deleteComments"}))return false;let i=n.kind==="body"?t.bodyStore().part:t.partFor(n);if(!i)return false;let a={storyPartName:i.name,...r===void 0?{}:{noteId:r}},s=t.bodyStore(),l=t.currentPackage(),c=s.checkpoint();return s.graftPackage(()=>t.currentPackage()),Ra(t,()=>{let d=false,u=false,m=s.transact(f=>{Qt(f).applyPackage(b=>{let R=b;for(let O of e){let g=O.parentCommentId===void 0?ui(R,O.commentId,a):vi(R,O.commentId,O.parentCommentId,a);if(g===null)return d=true,b;u||=g!==R,R=g;}return R});});return d||!m.ok||!u?false:(s.restoreHistoryStacks(c),t.installPackageSnapshot(s.package),t.adoptGroupedPackageUnit(l,o),t.publishStoryWrite(m.change),true)},d=>d,o)}var Ul=256*1024,$l=4096;function cm(t,e){for(let n=Ya(t.part,e);n;n=Ya(t.part,n.id)){if(n.kind==="paragraph")return false;if(n.kind.startsWith("revision"))return true}return false}function Lo(t,e,n){let r=e.payload,o=t.part.name,i=n??o;if(r){if(r.data.length>Ul)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>$l)return {ok:false,reason:"payload-too-large",detail:"label"}}if(e.revision&&(e.replaceControlId!==void 0||e.replaceUntil!==void 0))return {ok:false,reason:"unsupported",detail:"tracked custom node wrap or rewrite"};let a=e.revision?{revision:e.revision}:{};if(e.replaceControlId!==void 0&&cm(t,e.replaceControlId))return {ok:false,reason:"unsupported",detail:"custom node inside a pending revision"};let s=new Set(dc$1(t.part.root).map(f=>f.node.id)),l=e.replaceControlId===void 0?[]:Bl(t,o,e.replaceControlId),c=null,d,u=t.transact(f=>{if(e.replaceControlId!==void 0){f.apply({op:"removeContentControl",controlId:e.replaceControlId,keepContent:false});for(let R of l)f.applyPackage(O=>Ri(O,R.partName,R.nodeId));}let h=e.replaceUntil;if(h!==void 0&&h<=e.offset){c="invalid-range",d="replaceUntil must be past offset";return}if(h!==void 0&&f.apply({op:"deleteText",paragraphId:e.paragraphId,start:e.offset,end:h}),!r){f.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock},...a});return}let b=null;f.applyPackage(R=>{let O=Mi$1(R,i,r.namespaceUri,r.rootLocalName);if(!O.part)return c="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,R;if(b=Wi$1(O.part,r.rootLocalName,r.nodeId),!b)return c="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,R;let g=Qi$1(O.pkg,O.part.partName,{id:r.nodeId,label:r.label,data:r.data});return Pi(g,O.part.partName,r.nodeId)?g:(c="store-not-authored",d="the payload node could not be written into the store",R)}),!(c!==null||!b)&&f.apply({op:"insertInlineContentControl",paragraphId:e.paragraphId,offset:e.offset,tag:e.tag,text:e.text,...e.alias===void 0?{}:{alias:e.alias},...e.lock===void 0?{}:{lock:e.lock},dataBinding:b,...a});});if(c!==null)return {ok:false,reason:c,...d===void 0?{}:{detail:d}};if(!u.ok)return {ok:false,reason:u.reason,...u.detail===void 0?{}:{detail:u.detail}};let m=dm(t,s);return {ok:true,change:u.change,...m===void 0?{}:{nodeId:m}}}function dm(t,e){for(let n of dc$1(t.part.root))if(!e.has(n.node.id))return n.node.id}function Bl(t,e,n){let r=dc$1(t.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of Ki$1(t.package,e)){let a=Zi$1(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Ho(t,e){let n=t.part.name,r=Bl(t,n,e),o=t.transact(i=>{i.apply({op:"removeContentControl",controlId:e,keepContent:false});for(let a of r)i.applyPackage(s=>Ri(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 mm(t,e,n){if(!t.parts.has(e)||n.length===0)return {ok:true,pkg:t,removed:[]};let r=t,o=[];for(let i of n){let a=Li$1(r,e,i);if(!a)continue;let s=Yi$1(r,a.itemId),l=Si(r,a.partName,s);if(l.pkg===r&&Oi(r,a.partName).some(c=>!s.has(c.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 Hl=new WeakMap;function um(t,e){let n=Hl.get(t);n||(n=new Map,Hl.set(t,n));let r=n.get(e);if(r)return r;let o=Ki$1(t,e).map(i=>({itemId:i.itemId,nodes:new Map(Oi(t,i.partName).map(a=>[a.id,a]))}));return n.set(e,o),o}function pm(t,e,n=e){let r=new Map,o=t.parts.get(e);if(!o)return r;let i=um(t,n);if(i.length===0)return r;for(let a of dc$1(o.root))for(let s of i){let l=Zi$1(a.node,s.itemId);if(l===null)continue;let c=s.nodes.get(l);if(c){r.set(a.node.id,{nodeId:l,label:c.label,data:c.data});break}}return r}function fm(t,e,n){let r=new Map,o=Li$1(t,e,n);if(!o)return r;for(let i of Oi(t,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var jl={kind:"body"};function Vl(t,e,n,r){let o=e.kind==="body"?null:t.resolveStory(e),i=o?.ok?o.store:t.bodyStore(),a=t.currentPackage(),s=i.checkpoint();return i.graftPackage(()=>t.currentPackage()),Ra(t,()=>{let l=n(i);return l.ok&&(i.restoreHistoryStacks(s),t.replacePackageShell(i.package),t.adoptGroupedPackageUnit(a,r),t.publishStoryWrite(l.change)),l},l=>Sa(l),r)}function gm(t,e,n=jl,r){return Vl(t,n,o=>Lo(o,e,t.bodyStore().part.name),r)}function hm(t,e,n=jl){return Vl(t,n,r=>Ho(r,e))}var ym=256,xm=2e3,zl=/[\p{L}\p{N}_]/u;function Uo(t){let e=t.toLowerCase();if(e.length===t.length)return e;let n="";for(let r=0;r<t.length;r+=1){let o=t[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function Gl(t,e,n){let r=e>0?t[e-1]:void 0,o=n<t.length?t[n]:void 0;return !(r!==void 0&&zl.test(r)||o!==void 0&&zl.test(o))}function Wl(t){return typeof t=="string"&&t.length>0&&t.length<=256}function km(t,e,n,r={}){let o={matches:[],truncated:false};if(!Wl(e)||t.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?e:Uo(e),l=i?t:Uo(t),c=Math.max(0,r.from??0),d=Math.min(t.length,r.to??t.length),u=[],m=l.indexOf(s,c);for(;m>=0;){let f=m+s.length;if(f>d)return {matches:u,truncated:false};if(!a||Gl(t,m,f)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:m,length:s.length});}m=l.indexOf(s,f);}return {matches:u,truncated:false}}var Pm=new Set(["plainText","richText","date","dropDownList","comboBox","docPartList"]),Om=96;function $o(t,e){return t.kind!=="textValue"&&t.namespaceUri===pa&&t.localName===e}function bm(t){return t.kind==="textValue"&&t.value.trim()===""}function Sm(t){let e=[],n=(r,o,i)=>{if(r.kind==="textValue"||i>Om)return;if(bg(r)){let s=dg(r),l=bc$1(r);if(s&&l&&s.children.every(bm)&&Pm.has(l.type)){e.push({control:r,content:s,kind:l.type,docPart:l.placeholderDocPart,inline:o});return}}let a=o||r.kind==="paragraph"||$o(r,"p");for(let s of r.children)n(s,a,i+1);};return n(t,false,0),e}function Rm(t){return Fk(t,"rPr",{kind:"runProperties",children:[Fk(t,"rStyle",{attributes:[["val","PlaceholderText"]]})]})}function Im(t){let e=t.find(r=>r.kind==="paragraph"||$o(r,"p"));if(!e||e.kind==="textValue")return null;let n=e.children.filter(r=>r.kind!=="paragraphProperties"&&!$o(r,"pPr"));return n.length>0?n:null}function Bo(t,e){let n=Sm(e.root);if(n.length===0)return e;let r=null,o=c=>{if(c!==void 0)return r??=Qg(t),r.find(d=>d.name===c)},i=Va(e,"paste"),a=new Set(Db(e.root)),s={value:0},l=e;for(let[c,d]of n.entries()){let u=o(d.docPart),m=Fb(e,d.control),f=null;if(u){let g=u.blocks.map((p,P)=>Hb(jg(p,i),a,Nb(`${d.control.id}:placeholder:${c}:${P}`),s,m));f=d.inline?Im(g):g;}if(!f){let g=Gk(i,zk(d.kind),Rm(i));f=d.inline?[g]:[Hb(Fk(i,"p",{kind:"paragraph",children:[g]}),a,Nb(`${d.control.id}:placeholder:${c}`),s,m)];}let h=Hk(cg(d.control),{showingPlaceholder:true},i),b={...d.content,children:f},R=d.control.children.map(g=>g.id===d.content.id?b:g.kind!=="textValue"&&g.localName==="sdtPr"?h:g),O=$a(l,d.control.id,R);O.ok&&(l=O.part);}return l}function Kl(t,e,n){let r=e.filter(a=>a.node.localName==="tblGridChange"&&n.has(a.node.id));if(!r.length)return new Set;let o=new Map;for(let a of e){if(!["trPrChange","tcPrChange","tblPrExChange"].includes(a.node.localName))continue;let s=a.parent;for(;s&&s.kind!=="table";)s=Ya(t,s.id);if(!s)continue;let l=o.get(s.id)??[];l.push(a.node.id),o.set(s.id,l);}let i=new Set;for(let a of r){let s=a.parent&&Ya(t,a.parent.id),l=s&&o.get(s.id);l?.some(c=>n.has(c))&&l.some(c=>!n.has(c))&&i.add(a.node.id);}return i}function Nm(t,e,n,r,o){let i=r??t.root,a=i.kind==="textValue"?t:{...t,root:i},s=sk(a),l=n===void 0?[...Aj(a,lk(a))]:[],c=l.length?[{op:"acceptAllRevisions",siteNodeIds:l,...r?{scopeRootId:r.id}:{}}]:[];if(n?.length===0||s.length===0)return {ops:c,result:{resolved:[],skipped:[...new Set(n??[])].map(S=>({key:S,reason:"unknown-revision"})),remaining:s.length}};let d=new Set(n??s.map(Fj)),u=new Map(s.map(S=>[Fj(S),S])),m=new Set;for(let S of d){let k=u.get(S);if(k)for(let E of Ej(k))m.add(E);}let f=lk(a),h=Cj(i,f,m,e);for(let S of h.selected)m.add(S);for(let S of s){let k=Ej(S);k.length&&k.every(E=>m.has(E))&&d.add(Fj(S));}let b=ok(i,f),R=new Map(f.map((S,k)=>[S.node.id,k])),O=f.map((S,k)=>k),g=S=>{for(;O[S]!==S;)O[S]=O[O[S]],S=O[S];return S},p=(S,k)=>{O[g(k)]=g(S);};for(let S of h.dependencies){let k=S.flatMap(E=>R.has(E)?[R.get(E)]:[]);for(let E of k)p(k[0],E);}let P=new Map;for(let S of s){let k=Ej(S).flatMap(E=>{let N=R.get(E);return N===void 0?[]:[N]});for(let E of k)p(k[0],E);}let M=f.filter(S=>m.has(S.node.id)),F=new Set(fk(t,M,e).keys()),$=new Map;for(let[S,k]of f.entries()){if(e==="reject"&&k.propertyChange&&k.parent&&m.has(k.node.id))for(let N of k.parent.children)ck(k.node.localName,N)||P.set(N.id,S);let E=e==="accept"?k.node.localName==="del"||k.node.localName==="moveFrom":k.node.localName==="ins"||k.node.localName==="moveTo";if(k.paragraphMark&&k.parent&&E&&!b.has(k.node.id)&&m.has(k.node.id)){let N=Ya(t,k.parent.id),W=N&&Ya(t,N.id),Q=W&&Ya(t,W.id);if(N&&W&&Q){let ce=$.get(Q.id);ce||(ce=jk(Q.children,F),$.set(Q.id,ce)),ce.has(W.id)&&P.set(N.id,S);}}if(m.has(k.node.id)&&gk(t,k,e)){let N=gk(t,k,e);N&&!k.refused&&P.set(N.id,S);}}for(let[S,k]of hk(t,M,e)){let E=Xa(t,S),N=R.get(k[0]);if(!(E?.kind!=="tableCell"||N===void 0))for(let W of E.children)W.localName==="tcPr"&&P.set(W.id,N);}let w=$j(a,[...R.keys(),...P.keys()]),L=(S,k)=>{if(!w.has(S.id))return;let E=R.get(S.id),N=P.get(S.id);E!==void 0&&N!==void 0&&p(N,E);let W=E??N;W!==void 0&&k!==void 0&&p(k,W);let Q=W??k;if(S.kind!=="textValue")for(let ce of S.children)L(ce,Q);};L(i);for(let S of nk(i).values()){let k=S.wrappers.flatMap(E=>{let N=R.get(E.id);return N===void 0?[]:[N]});for(let E of k)p(k[0],E);}for(let S of f.some(k=>k.node.localName==="cellMerge")?ik(a):[]){let k=S.flatMap(E=>{let N=R.get(E);return N===void 0?[]:[N]});for(let E of k)p(k[0],E);}let q=new Map;for(let[S,k]of f.entries()){let E=g(S),N=q.get(E)??[];N.push(k),q.set(E,N);}let U=new Map,J=new Map;for(let[S,k]of q){let E=k.find(W=>W.refused),N=e==="reject"&&k.some(W=>W.propertyChange&&ek(W.node)===null);E||N?(U.set(S,"unsupported-revision"),J.set(S,E?.refusal??"unrecorded-properties")):k.some(W=>!m.has(W.node.id))&&U.set(S,"incomplete-group");}for(let S of s)if(S.readOnly)for(let k of Ej(S)){let E=R.get(k);E!==void 0&&(U.set(g(E),"unsupported-revision"),J.has(g(E))||J.set(g(E),"read-only"));}let ee=f.filter((S,k)=>m.has(S.node.id)&&!U.has(g(k))),B=false,re=fk(t,ee,e);for(let[S,k]of re){if(P.has(S))continue;let E=R.get(k[0]);E!==void 0&&(P.set(S,E),B=true);}if(B){L(i);for(let[S,k]of [...U]){let E=g(S);if(U.get(E)!=="unsupported-revision"){U.set(E,k);let N=J.get(S);N&&J.set(E,N);}}}let ue=[],le=[],A=new Set,_=new Set(bk(t,f,e));for(let S of _){let k=Ya(t,S);for(;k;){if(re.has(k.id)){_.delete(S);break}k=Ya(t,k.id);}}for(let S of d){let k=u.get(S);if(!k){le.push({key:S,reason:"unknown-revision"});continue}let E={key:S,author:k.author,partName:t.name,revisionKind:k.revisionKind,...k.formattingKind?{formattingKind:k.formattingKind}:{}},N=Ej(k),W,Q;for(let ce of N){let Fe=R.get(ce);if(W=Fe===void 0?"incomplete-group":U.get(g(Fe)),Q=Fe===void 0?void 0:J.get(g(Fe)),W)break}if(N.length||(W="unsupported-revision",Q="no-sites"),W)le.push({key:S,reason:W,revision:E,...W==="unsupported-revision"&&Q?{detail:Q}:{}});else {N.some(ce=>_.has(ce))?le.push({key:S,reason:"retained-structure",revision:E}):ue.push(E);for(let ce of N)_.has(ce)||A.add(ce);}}let V=Kl(t,f,A),te=new Set;for(let S of s){let k=Ej(S);if(S.formattingKind!=="tblGridChange"&&k.length>1)for(let E of k)V.has(E)&&te.add(E);}let oe=[...A].filter(S=>!h.implicit.has(S)&&!te.has(S)),de=s.length-ue.length;if(de>0&&oe.length&&o?.countRemaining!==false){let S={...t,root:{...t.root}},k=pk(S,e,void 0,{siteNodeIds:oe,...r?{scopeRootId:r.id}:{}});if(k.ok&&k.part){let E=r?Xa(k.part,r.id):k.part.root;de=E&&E.kind!=="textValue"?sk({...k.part,root:E}).length:0;}}return {ops:A.size?[...c,{op:e==="accept"?"acceptAllRevisions":"rejectAllRevisions",siteNodeIds:oe,...r?{scopeRootId:r.id}:{}}]:c,result:{resolved:ue,skipped:le,remaining:de}}}var Kx="Times New Roman",Xx="SimSun",jo="Hans",Yl=Object.freeze({minor:new Map([["Hans","SimSun"],["Hant","PMingLiU"],["Jpan","MS Mincho"],["Hang","Batang"]]),major:new Map([["Hans","SimHei"],["Hant","MingLiU"],["Jpan","MS Gothic"],["Hang","Dotum"]])}),ql=Object.freeze({minor:new Map([["Hans","DengXian"],["Hant","PMingLiU"],["Jpan","Yu Mincho"],["Hang","Malgun Gothic"]]),major:new Map([["Hans","DengXian Light"],["Hant","PMingLiU"],["Jpan","Yu Gothic Light"],["Hang","Malgun Gothic"]])}),Jl=new Set(["simsun","nsimsun","simsun-extb","simhei","kaiti","kaiti_gb2312","fangsong","fangsong_gb2312","microsoft yahei","microsoft yahei ui","microsoft yahei light","microsoft jhenghei","microsoft jhenghei ui","microsoft jhenghei light","mingliu","pmingliu","mingliu_hkscs","mingliu-extb","pmingliu-extb","dfkai-sb","dengxian","dengxian light","lisu","youyuan","stsong","stzhongsong","stfangsong","stkaiti","stheiti","stxihei","stxingkai","stliti","sthupo","stxinwei","pingfang sc","pingfang tc","pingfang hk","songti sc","songti tc","heiti sc","heiti tc","kaiti sc","kaiti tc","\u5B8B\u4F53","\u65B0\u5B8B\u4F53","\u9ED1\u4F53","\u6977\u4F53","\u4EFF\u5B8B","\u5FAE\u8F6F\u96C5\u9ED1","\u5FAE\u8EDF\u6B63\u9ED1\u9AD4","\u7B49\u7EBF","\u7D30\u660E\u9AD4","\u65B0\u7D30\u660E\u9AD4","\u6A19\u6977\u9AD4","\u534E\u6587\u6977\u4F53","\u534E\u6587\u5B8B\u4F53","\u534E\u6587\u9ED1\u4F53","\u534E\u6587\u4EFF\u5B8B","\u534E\u6587\u4E2D\u5B8B","\u534E\u6587\u7EC6\u9ED1"]),Ql=new Set(["arial","arial black","arial narrow","aptos","aptos display","book antiqua","calibri","calibri light","cambria","candara","century gothic","consolas","constantia","corbel","courier new","garamond","georgia","helvetica","helvetica neue","palatino linotype","segoe ui","tahoma","times new roman","trebuchet ms","verdana"]),Zl=new Set(["ms mincho","ms gothic","ms pmincho","ms pgothic","ms ui gothic","meiryo","meiryo ui","yu mincho","yu gothic","yu gothic ui","yu gothic light","yu gothic medium","hiragino mincho pron","hiragino kaku gothic pron","hiragino sans","\uFF4D\uFF53 \u660E\u671D","\uFF4D\uFF53 \u30B4\u30B7\u30C3\u30AF","\u30E1\u30A4\u30EA\u30AA","\u6E38\u660E\u671D","\u6E38\u30B4\u30B7\u30C3\u30AF","malgun gothic","batang","batangche","gulim","gulimche","dotum","dotumche","gungsuh","gungsuhche","apple sd gothic neo","\uB9D1\uC740 \uACE0\uB515","\uBC14\uD0D5","\uAD74\uB9BC","\uB3CB\uC6C0","\uAD81\uC11C"]),vm=new Set(["86","88"]),Em=new Set(["80","81","86","88"]);function Yx(t,e){let n=t?.trim().toLowerCase();return !n||n.startsWith("@")?false:Jl.has(n)?true:Ql.has(n)||Zl.has(n)?false:e?.includes(n)??false}function qx(t,e){let n=t?.trim().toLowerCase();return !n||n.startsWith("@")?false:Jl.has(n)||Zl.has(n)?true:Ql.has(n)?false:e?.includes(n)??false}function Xl(t){return t.kind!=="textValue"}function ec(t){return nc(t,vm)}function tc(t){return nc(t,Em)}function nc(t,e){if(!t)return [];let n=[];for(let r of t.children){if(!Xl(r)||r.localName!=="font")continue;let o=r.attributes.find(i=>i.localName==="name")?.value;if(!(!o||o.length>128)){for(let i of r.children){if(!Xl(i)||i.localName!=="charset")continue;let a=i.attributes.find(s=>s.localName==="val")?.value;a&&e.has(a.toLowerCase())&&n.push(o.trim().toLowerCase());}if(n.length>=256)break}}return Object.freeze(n)}function zo(t){return t.kind!=="textValue"}function er(t,e){for(let n of t.children)if(zo(n)&&n.localName===e)return n;return null}function Tm(t,e){let n=[t];for(;n.length>0;){let r=n.pop();if(zo(r)){if(r.localName===e)return r;for(let o=r.children.length-1;o>=0;o-=1)n.push(r.children[o]);}}return null}var sc=/^[\p{L}\p{N}\p{M} \-.+_,;]{1,64}$/u;function At(t,e,n){let r=er(t,e),i=(r?er(r,n):null)?.attributes.find(a=>a.localName==="typeface")?.value;return i!==void 0&&sc.test(i)?i:null}var rc=new WeakMap;function wm(t){let e=t?rc.get(t):void 0;if(e)return e;let n=t?Tm(t,"fontScheme"):null;if(!n)return Vo;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"),..._m(n)});return t&&rc.set(t,r),r}var oc=new WeakMap,Vo=Object.freeze({major:null,minor:null,majorEastAsia:null,minorEastAsia:null}),Cm=new WeakMap,ac=new WeakMap;function Go(t,e=null,n=null){let r=Mm(t,e);if(!n)return r;let o=ec(n),i=tc(n);if(i.length===0)return r;let a=ac.get(n);a||ac.set(n,a=new WeakMap);let s=a.get(r);if(s)return s;let l=Object.freeze({...r,...o.length>0?{chineseFontTableFaces:o}:{},eastAsianFontTableFaces:i});return a.set(r,l),l}function Mm(t,e){let n=t?wm(t):Vo,r=e?er(e,"themeFontLang"):null,o=Cm;r&&e&&(o=oc.get(e)??new WeakMap,oc.set(e,o));let i=o.get(n);if(i)return i;let a=R=>r?.attributes.find(O=>O.localName===R)?.value,s=ic(a("val")),l=ic(a("bidi")),c=a("eastAsia"),d=Wo(c),u=(R,O,g)=>O&&(R?n.majorSupplemental:n.minorSupplemental)?.[O]||g||null,m=n===Vo?ql:Yl,f=d??jo,h=(R,O)=>(d?u(R,d,O):O||u(R,jo,null))||(R?m.major:m.minor).get(f)||null,b=Object.freeze({major:u(true,s,n.major),minor:u(false,s,n.minor),majorEastAsia:h(true,n.majorEastAsia),minorEastAsia:h(false,n.minorEastAsia),majorBidi:u(true,l,n.majorBidi),minorBidi:u(false,l,n.minorBidi),...c===void 0?{majorSupplemental:n.majorSupplemental,minorSupplemental:n.minorSupplemental}:{}});return o.set(n,b),b}var Am=new Map([["minorAscii",t=>t.minor],["minorHAnsi",t=>t.minor],["majorAscii",t=>t.major],["majorHAnsi",t=>t.major],["minorEastAsia",t=>t.minorEastAsia??null],["majorEastAsia",t=>t.majorEastAsia??null],["minorBidi",t=>t.minorBidi??null],["majorBidi",t=>t.majorBidi??null]]);function Zx(t,e,n){if(t===void 0)return null;let r=Am.get(t)?.(e)??null;if(r!==null)return r;let o=Wo(n);return o?(t==="majorEastAsia"?e.majorSupplemental:t==="minorEastAsia"?e.minorSupplemental:void 0)?.[o]??null:null}function Wo(t){if(!t||t.length>85)return null;let e=t.toLowerCase().split("-");return e[0]==="ja"?"Jpan":e[0]==="ko"?"Hang":e[0]!=="zh"?null:e.includes("hant")?"Hant":e.includes("hans")?"Hans":e.some(n=>["tw","hk","mo"].includes(n))?"Hant":"Hans"}var Dm=new Map([["ar","Arab"],["fa","Arab"],["ur","Arab"],["ps","Arab"],["he","Hebr"],["yi","Hebr"],["dv","Thaa"],["syr","Syrc"]]);function ic(t){if(!t||t.length>85)return null;let e=t.toLowerCase().split("-");return e[1]&&/^[a-z]{4}$/.test(e[1])?e[1][0].toUpperCase()+e[1].slice(1):Wo(t)??Dm.get(e[0])??null}function _m(t){let e={};for(let[n,r]of [["majorFont","majorSupplemental"],["minorFont","minorSupplemental"]]){let o=Object.create(null);for(let i of er(t,n)?.children??[]){if(!zo(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&&sc.test(s)&&(o[a]=s);}Object.keys(o).length&&(e[r]=Object.freeze(o));}return e}var tt=Object.freeze({styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",numbering:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",settings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",fontTable:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",coreProperties:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",extendedProperties:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"});function Ko(t,e,n,r){let o=(t.relationships.get(e)??[]).find(i=>i.type===n);if(o){let i=N(o);if(i.mode==="Internal"&&i.target.ok){let a=t.parts.get(i.target.partName);if(a)return a}}return t.parts.get(r)}function dk(t){let e=Je$1(t);if(!e.ok)return {ok:false,reason:e.reason,...e.detail?{detail:e.detail}:{}};let n=e.package.parts.get(e.package.mainDocumentPart);if(!n)return {ok:false,reason:"no-main-document-tree",detail:e.package.mainDocumentPart};let r=new en(e.package,Bo(e.package,Ib(n)));return {ok:true,view:Fm(r)}}function Fm(t){let e=()=>t.currentPackage(),n=()=>t.bodyStore().part,r=(c,d)=>Ko(e(),e().mainDocumentPart,c,d)?.root??null,o=Object.freeze(Go(null)),i=null,a=Bi$1,s=null;return Object.freeze({part:n,currentPackage:e,packageRevision:()=>t.packageRevision,stylesRoot:()=>r(tt.styles,"/word/styles.xml"),numberingRoot:()=>r(tt.numbering,"/word/numbering.xml"),settingsRoot:()=>r(tt.settings,"/word/settings.xml"),documentThemeFonts(){let c=e();return i!==c&&(o=Object.freeze(Go(r(tt.theme,"/word/theme/theme1.xml"),r(tt.settings,"/word/settings.xml"),r(tt.fontTable,"/word/fontTable.xml"))),i=c),o},documentProperties(){let c=e();if(s!==c){let d=Ko(c,"/",tt.coreProperties,"/docProps/core.xml"),u=Ko(c,"/",tt.extendedProperties,"/docProps/app.xml");a=Ci$1(d?.root??null,u?.root??null),s=c;}return a},headerFooterPartsBySection:()=>nf(e()),headerFooterResolutionBySection:()=>mf(e()),relationshipTarget:c=>Vg(e(),n().name,c)})}
|
|
2
|
+
export{im as $,Vr as A,Fm as Aa,bc as B,Di as C,Rc as D,Gt as E,Ln as F,Hn as G,Ui as H,Lu as I,Fi as J,Wc as K,lo as L,vs as M,co as N,ft as O,Ol as P,en as Q,Sl as R,Rl as S,Ro as T,rh as U,No as V,_o as W,Fo as X,rm as Y,om as Z,am as _,lc as a,sm as aa,Ei as b,lm as ba,Cn as c,Ul as ca,mt as d,$l as da,Mn as e,Lo as ea,An as f,Ho as fa,ge as g,mm as ga,uc as h,pm as ha,ut as i,fm as ia,Vt as j,gm as ja,Dn as k,hm as ka,zt as l,ym as la,_n as m,xm as ma,_r as n,Uo as na,Fr as o,Gl as oa,Lr as p,Wl as pa,hc as q,km as qa,yc as r,Bo as ra,Ur as s,Nm as sa,wi as t,Kx as ta,xc as u,Xx as ua,Hr as v,Yx as va,kc as w,qx as wa,$r as x,Go as xa,Br as y,Zx as ya,jr as z,dk as za};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {yb,Xa,bb,Ne,Le,Pa,Oa,Tk,pa,Ib,Ab,zb,Qa,qa}from'./chunk-GWM3AKUD.js';var W=new Set(["document","hdr","ftr","footnotes","endnotes"]),$=24,J=512,U=yb($);function V(r){let n=r.root;return n.namespaceUri===pa&&W.has(n.localName)}function Y(r){let n=[],e=t=>{if(t.kind!=="textValue"){t.namespaceUri===pa&&t.localName==="p"&&n.push(t);for(let a of t.children)e(a);}};return e(r.root),n}function H(r){let n=Ib(r);let e=[],t=new Set;for(let a of Y(n)){let i=Ab(a);if(!i||!zb(i))continue;let o=i.toUpperCase();if(t.has(o))continue;t.add(o);let s=Tk(n,a.id);s!==null&&e.push(Object.freeze({paragraphId:o,nodeId:a.id,text:s}));}return Object.freeze(e)}function q(r){let n=U.get(r.root);if(n)return n;let e=Ib(r);let t=new Map,a=new Set,i=o=>{if(o.kind!=="textValue"){if(o.namespaceUri===pa&&o.localName==="p"){let s=Ab(o);if(s&&zb(s)){let c=s.toUpperCase();a.has(c)||(a.add(c),o.kind==="paragraph"&&t.set(c,o.id));}}for(let s of o.children)i(s);}};return i(e.root),U.set(r.root,t),t}function _(r,n){if(r.length!==n.length)return false;for(let e=0;e<r.length;e+=1)if(r[e].root!==n[e])return false;return true}function B(r){let n=new Map,e=null,t=(i,o,s)=>{for(n.delete(i),n.set(i,{partName:o.name,root:o.root,nodeId:s});n.size>J;){let c=n.keys().next();if(c.done)break;n.delete(c.value);}},a=(i,o)=>{let s=n.get(i);if(!s)return null;let c=o.find(d=>d.name===s.partName);if(!c)return null;if(c.root===s.root)return {part:c,nodeId:s.nodeId};let l=Xa(c,s.nodeId);if(!l||l.kind!=="paragraph")return null;let p=Ab(l);return !p||p.toUpperCase()!==i?null:(t(i,c,s.nodeId),{part:c,nodeId:s.nodeId})};return i=>{let o=r(),s=a(i,o);if(s)return s;if(e&&e.ids.has(i)&&_(o,e.roots))return null;for(let c of o){let l=q(c).get(i);if(l!==void 0)return t(i,c,l),{part:c,nodeId:l}}return (!e||!_(o,e.roots))&&(e={roots:o.map(c=>c.root),ids:new Set}),e.ids.size<J&&e.ids.add(i),null}}function L(r,n){return Qa(r,n)}var F=Object.freeze({kind:"body"}),Q=1e6;function O(r,n){if(n<=0||n>=r.length)return false;let e=r.charCodeAt(n-1),t=r.charCodeAt(n);return e>=55296&&e<=56319&&t>=56320&&t<=57343}function K(r,n,e){if(n===e)return [];let t=0,a=Math.min(n.length,e.length);for(;t<a&&n.charCodeAt(t)===e.charCodeAt(t);)t+=1;for(;t>0&&(O(n,t)||O(e,t));)t-=1;let i=0;for(;i<n.length-t&&i<e.length-t&&n.charCodeAt(n.length-i-1)===e.charCodeAt(e.length-i-1);)i+=1;for(;i>0&&(O(n,n.length-i)||O(e,e.length-i));)i-=1;let o=n.length-t-i,s=e.slice(t,e.length-i),c=[];return o>0&&c.push({op:"deleteText",paragraphId:r,start:t,end:t+o}),s.length>0&&c.push({op:"insertText",paragraphId:r,offset:t,text:s}),Object.freeze(c)}function tt(r){let n=t=>!!t&&t.kind!=="textValue"&&t.namespaceUri===pa&&t.localName==="t"&&t.attributes.every(a=>a.namespaceUri===qa&&a.localName==="space")&&t.children.every(a=>a.kind==="textValue"),e=[];for(let t of r){let a=e.at(-1);if(!n(a)||!n(t)){e.push(t);continue}let i=a.children.map(o=>o.kind==="textValue"?o.value:"").join("")+t.children.map(o=>o.kind==="textValue"?o.value:"").join("");e[e.length-1]={...a,attributes:/^\s|\s$/.test(i)?[{kind:"xmlSpace",namespaceUri:qa,localName:"space",prefix:"xml",value:"preserve"}]:[],children:[{id:a.children[0]?.id??`${a.id}/text`,kind:"textValue",value:i}]};}return e}function G(r){if(r.kind==="textValue")return r;let n=false,e=r.children.map(t=>{let a=G(t);return a!==t&&(n=true),a});if(r.namespaceUri===pa&&r.localName==="r"){let t=tt(e);(t.length!==e.length||t.some((a,i)=>a!==e[i]))&&(e=[...t],n=true);}return n?{...r,children:e}:r}function et(r,n,e){let t=r.parts.get(n);if(!t)return r;let a=false,i=new Set;for(let o of e)(o.op==="insertText"||o.op==="deleteText")&&!o.revision&&i.add(o.paragraphId);for(let o of i){let s=Xa(t,o);if(!s||s.kind==="textValue")continue;let c=G(s);if(c===s)continue;let l=bb(t,o,c,{deferValidation:true});l.ok&&(t=l.part,a=true);}return a?Ne(r,t):r}function rt(r,n){let e=n.documentId.trim();if(e.length===0||e.length>256)throw new TypeError("documentId must contain 1 to 256 characters");let t=()=>H(r.bodyStore().part),a,i=()=>{let l=r.bodyStore().part,p=r.currentPackage();if(a?.pkg===p&&a.body===l)return a.parts;let d=[l];for(let g of p.parts.values())g===l||!V(g)||d.push(g);return a={pkg:p,body:l,parts:Object.freeze(d)},a.parts},o=B(i),s=(l,p)=>{if(l.length===0)return {ok:true,changed:false};let d=t(),g=new Set,P=[];for(let u of l){if(typeof u.text!="string"||u.text.length>Q)return {ok:false,reason:"collaboration-text-limit"};if(typeof u.paragraphId!="string"||u.paragraphId.length===0||u.paragraphId.length>256)return {ok:false,reason:"unknown-paragraph-id"};let m=u.paragraphId.toUpperCase();if(g.has(m))return {ok:false,reason:"duplicate-paragraph-id"};g.add(m);let N=d.filter(X=>X.paragraphId===m);if(N.length!==1)return {ok:false,reason:"unknown-paragraph-id"};let M=N[0];P.push(...K(M.nodeId,M.text,u.text));}if(P.length===0)return {ok:true,changed:false};let x=r.transact(F,u=>{for(let m of P)u.apply(m);u.applyPackage(m=>et(m,m.mainDocumentPart,P));},{origin:p.origin,actorId:p.actorId,operationId:p.operationId,recordsHistory:false});return x.ok?{ok:true,changed:x.change!==null}:{ok:false,reason:x.detail??x.reason}},c={documentId:e,interactive:n.interactive===true,paragraphs:t,paragraphByNodeId(l){return t().find(p=>p.nodeId===l)??null},paragraphTextOf(l){for(let p of i()){let d=Tk(p,l);if(d!==null)return d}return null},paragraphByStableId(l){let p=l.toUpperCase(),d=o(p);if(!d)return null;let g=Tk(d.part,d.nodeId);return g===null?null:Object.freeze({paragraphId:p,nodeId:d.nodeId,text:g})},applyParagraphText(l,p,d){return s([{paragraphId:l,text:p}],d)},applyParagraphTexts:s,applyRemotePackage(l,p){let d=r.publishRemotePackage(l,p);return d.ok?{ok:true,changed:d.change!==null}:{ok:false,reason:d.detail??d.reason}},revision:()=>r.packageRevision,subscribe:l=>r.subscribe(l),observePrimitiveJournal:l=>L(r,l),hasPendingJournals:()=>Oa(r),flushPendingJournals:()=>{Pa(r);},save:()=>Le(r.currentPackage()),binaryPart(l){let p=r.currentPackage();return p.partBytes.get(l)??p.partBytes.get(l.startsWith("/")?l.slice(1):`/${l}`)??null}};return Object.freeze(c)}function nt(r,n,e){if(n===e||r>n.length)return Math.min(r,e.length);let t=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t+=1;let a=0;for(;a<n.length-t&&a<e.length-t&&n[n.length-1-a]===e[e.length-1-a];)a+=1;if(r<=t)return Math.min(r,e.length);if(r>n.length-a)return Math.min(e.length,r+e.length-n.length);let i=at(n,e,t,a),o=i.offsets.get(r);return o===void 0&&(o=(i.table?st(i.table,r,n,e,t):null)??pt(r,n,e,t,a)??t,i.offsets.set(r,o)),o}var f=[],ot=16;function at(r,n,e,t){let a=f.findIndex(o=>o.before===r&&o.after===n);if(a>=0){let[o]=f.splice(a,1);return f.push(o),o}let i={before:r,after:n,table:lt(r,n,e,t),offsets:new Map};return f.length>=ot&&f.shift(),f.push(i),i}var it=1<<18;function lt(r,n,e,t){let a=r.length-t-e,i=n.length-t-e;if(a*i>it)return null;let o=i+1,s=new Uint32Array((a+1)*o);for(let c=a-1;c>=0;c-=1)for(let l=i-1;l>=0;l-=1)s[c*o+l]=r[e+c]===n[e+l]?s[(c+1)*o+l+1]+1:Math.max(s[(c+1)*o+l],s[c*o+l+1]);return {lengths:s,width:o,columns:i}}function st(r,n,e,t,a){let{lengths:i,width:o,columns:s}=r,c=n-a,l=0,p=0;for(;l<c;)p<s&&e[a+l]===t[a+p]?(l+=1,p+=1):p>=s||i[(l+1)*o+p]>=i[l*o+p+1]?l+=1:p+=1;return a+p}var ct=[32,16,8,4];function pt(r,n,e,t,a){let i=e.slice(t,e.length-a),o=s=>{let c=i.indexOf(s);return c>=0&&i.indexOf(s,c+1)<0?c:null};for(let s of ct){let c=n.slice(Math.max(t,r-s),r);if(c.length===s){let p=o(c);if(p!==null)return t+p+c.length}let l=n.slice(r,Math.min(n.length-a,r+s));if(l.length===s){let p=o(l);if(p!==null)return t+p}}return null}export{et as a,rt as b,nt as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {Ej}from'./chunk-GWM3AKUD.js';function I(o){let n=[],t=[],a=new Map;for(let r of o){if(r.kind!=="revision")continue;let s=Ej(r);for(let e of s)n.push(e);let p=new Set(r.ranges.map(e=>e.start.paragraphId)),u=r.revisionKind==="format"&&r.formattingKind==="pPrChange";if(p.size>1&&!u)for(let e of p)t.push(e);for(let e of r.ranges){let g=a.get(e.start.paragraphId)??[];for(let l of s)g.push(l);a.set(e.start.paragraphId,g);}}let i=new Map;for(let[r,s]of a)i.set(r,[...new Set(s)].sort().join("\0"));return {sites:n,paragraphs:i,spanning:t}}function w(o){return o.flatMap(n=>n.kind==="revision"?n.ranges.map(t=>t.start.paragraphId):[])}var c=new WeakMap,h=1,m={};function f(o){let n=o??m,t=c.get(n);return t===void 0&&(t=h++,c.set(n,t)),t}function b(o,n){return `${f(o)}:${f(n)}`}export{I as a,w as b,b as c};
|