@docx-editor.dev/pro 2.35.0-canary.20261104032723.sha-43c2012 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -14
- package/dist/chunk-B4OWKZIG.js +7 -0
- package/dist/chunk-OYR3V4F4.cjs +1 -0
- package/dist/chunk-VJOGWUUQ.cjs +7 -0
- package/dist/chunk-XC2ILGOO.js +1 -0
- package/dist/collaboration/hocuspocus.d.cts +3 -3
- package/dist/collaboration/hocuspocus.d.ts +3 -3
- package/dist/collaboration/index.d.cts +3 -3
- package/dist/collaboration/index.d.ts +3 -3
- package/dist/collaboration/webrtc.d.cts +3 -3
- package/dist/collaboration/webrtc.d.ts +3 -3
- package/dist/compare-worker.cjs +1 -0
- package/dist/compare-worker.d.cts +7 -0
- package/dist/compare-worker.d.ts +7 -0
- package/dist/compare-worker.js +1 -0
- package/dist/{define-custom-node-DE1KjR1r.d.ts → define-custom-node-BRNdxxZL.d.ts} +17 -0
- package/dist/{define-custom-node-CISpZvVB.d.cts → define-custom-node-CvRKwTqE.d.cts} +17 -0
- package/dist/{document-session-DZK2tAr4.d.cts → document-session-C6Zli8mp.d.cts} +2 -2
- package/dist/{document-session-B6v5LZIK.d.ts → document-session-CRhyVeWE.d.ts} +2 -2
- package/dist/{document-session-options-CxR0F5xT.d.cts → document-session-options-CuEO7l9P.d.cts} +1 -1
- package/dist/{document-session-options-CdOH-TNn.d.ts → document-session-options-hwq_FdnS.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +90 -7
- package/dist/index.d.ts +90 -7
- package/dist/index.js +1 -1
- package/dist/react/hocuspocus.d.cts +2 -2
- package/dist/react/hocuspocus.d.ts +2 -2
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +5 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +1 -1
- package/dist/react/webrtc.d.cts +2 -2
- package/dist/react/webrtc.d.ts +2 -2
- package/dist/{types-DvGpDOcZ.d.cts → types-gCdUeE3e.d.cts} +1 -1
- package/dist/{types-DvGpDOcZ.d.ts → types-gCdUeE3e.d.ts} +1 -1
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +17 -0
- package/dist/vue/index.d.ts +17 -0
- package/dist/vue/index.js +1 -1
- package/docs/accept-reject-without-scrolling.md +31 -48
- package/docs/comment-on-found-text.md +47 -23
- package/docs/custom-review-cards.md +50 -34
- package/docs/highlight-ranges.md +26 -6
- package/docs/index.md +21 -21
- package/docs/propose-rewrite.md +87 -138
- package/docs/tracked-replacement.md +41 -20
- package/package.json +7 -4
- package/dist/chunk-L6ZMFFBX.cjs +0 -1
- package/dist/chunk-VQOLBCW6.js +0 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Add advanced drawing rendering, review, collaboration, and custom content to the
|
|
|
23
23
|
- [Comments](https://www.docx-editor.dev/docs/2.x/pro/comments): Threads anchored to a range, with replies.
|
|
24
24
|
- [Collaboration](https://www.docx-editor.dev/docs/2.x/pro/collaboration): Provider-neutral sessions with WebRTC and Hocuspocus helpers.
|
|
25
25
|
- [Custom nodes](https://www.docx-editor.dev/docs/2.x/pro/custom-nodes): Inline node types stored as content controls.
|
|
26
|
-
- [Advanced drawing rendering](https://www.docx-editor.dev/docs/2.x/pro/drawing): Charts,
|
|
26
|
+
- [Advanced drawing rendering](https://www.docx-editor.dev/docs/2.x/pro/drawing): Charts, DrawingML diagram layout, shape effects, VML text paths, and EMF and WMF pictures.
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
npm install @docx-editor.dev/react @docx-editor.dev/core @docx-editor.dev/pro
|
|
@@ -133,31 +133,26 @@ Every value reaching `fromDocx` came out of a `.docx`, so treat `attrs` and `tex
|
|
|
133
133
|
|
|
134
134
|
## Which API for which job
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| Build a review UI in the browser | The React or Vue adapter hooks, plus the review hooks and `DocxEditorReview` from `@docx-editor.dev/pro/react` or `@docx-editor.dev/pro/vue`. |
|
|
139
|
-
| Edit in a headless, server, or agent pipeline | The editing API in `@docx-editor.dev/editor-api`, which follows the Office.js object model. |
|
|
136
|
+
Use the React or Vue adapter hooks, the review hooks, and `DocxEditorReview` from `@docx-editor.dev/pro/react` or `@docx-editor.dev/pro/vue` to build browser review controls. Use the editing API in `@docx-editor.dev/editor-api` for document automation. It follows the Office.js object model and runs in browser and server hosts.
|
|
140
137
|
|
|
141
|
-
| Task | Browser
|
|
138
|
+
| Task | Browser controls (React or Vue) | Document automation |
|
|
142
139
|
| --- | --- | --- |
|
|
143
140
|
| [Comment on found text](https://www.docx-editor.dev/docs/2.x/recipes/comment-on-found-text) | `editor.findMatches`, `editor.selectMatch`, then `useReview().comment` | `body.search`, then `Range.insertComment` |
|
|
144
|
-
| Reply to a thread | `useReview().reply(item, text)` | `Comment.reply(text)` |
|
|
141
|
+
| [Reply to a thread](https://www.docx-editor.dev/docs/2.x/pro/comments) | `useReview().reply(item, text)` | `Comment.reply(text)` |
|
|
145
142
|
| [Record a tracked replacement](https://www.docx-editor.dev/docs/2.x/recipes/tracked-replacement) | Suggesting mode, then `editor.exec({ type: 'replaceMatch', match, text })` | `document.changeTrackingMode = 'TrackMineOnly'`, then `Range.insertText(text, 'Replace')` |
|
|
146
|
-
| [Propose an AI rewrite as tracked changes](https://www.docx-editor.dev/docs/2.x/recipes/propose-rewrite) |
|
|
143
|
+
| [Propose an AI rewrite as tracked changes](https://www.docx-editor.dev/docs/2.x/recipes/propose-rewrite) | `prepareRewrite` through `DocxEditor.createBrowser` | `prepareRewrite` from `@docx-editor.dev/editor-api/agent` |
|
|
147
144
|
| [Accept or reject a change](https://www.docx-editor.dev/docs/2.x/recipes/accept-reject-without-scrolling) | `useReview().accept(item)` or `useReview().reject(item)` | `Revision.accept()` or `Revision.reject()` |
|
|
148
|
-
| [Open
|
|
145
|
+
| [Open a change without scrolling](https://www.docx-editor.dev/docs/2.x/recipes/accept-reject-without-scrolling) | `useReview().setActive(key, { reveal: false })` | Not applicable: no viewport |
|
|
149
146
|
| [Highlight ranges](https://www.docx-editor.dev/docs/2.x/recipes/highlight-ranges) | `useHighlights(name, source, options)` | Not applicable |
|
|
150
|
-
| [Custom review rail cards](https://www.docx-editor.dev/docs/2.x/recipes/custom-review-cards) | `DocxEditorReview` with `preset` set to `false`, `
|
|
147
|
+
| [Custom review rail cards](https://www.docx-editor.dev/docs/2.x/recipes/custom-review-cards) | `DocxEditorReview` with `preset` set to `false`, `useStackedReviewPositions`, and `useReviewRailMetrics` | Not applicable |
|
|
151
148
|
| Comment-on-selection button | `DocxEditorReview.AddComment` as a direct child of `DocxEditorReview`, or `useEditorCommand('review.addComment')` | Not applicable |
|
|
152
|
-
| Page setup and paragraph dialogs
|
|
153
|
-
|
|
154
|
-
The review hooks need `reviewModule()` from `@docx-editor.dev/pro` in the editor's modules, and an editor `author` for comments and tracked changes. The editing API takes its author from the `author` option of `DocxEditor.createServer`, imported from `@docx-editor.dev/editor-api`, or of `DocxEditor.createBrowser`, imported from `@docx-editor.dev/editor-api/browser`.
|
|
149
|
+
| [Page setup and paragraph dialogs](https://www.docx-editor.dev/docs/2.x/customization/dialogs) | `DocxEditor.PageSetupDialog` or `DocxEditor.ParagraphDialog` | `Section.pageSetup`, and `Paragraph` properties such as `alignment` |
|
|
155
150
|
|
|
156
151
|
This package ships the task recipes in [`docs/index.md`](./docs/index.md). They are also on the site: [Task recipes](https://www.docx-editor.dev/docs/2.x/recipes).
|
|
157
152
|
|
|
158
153
|
## Render charts and advanced drawings
|
|
159
154
|
|
|
160
|
-
Register `drawingModule()` to render charts,
|
|
155
|
+
Register `drawingModule()` to render charts, DrawingML diagrams saved without their drawing, shape effects, VML text paths, and EMF and WMF pictures. If you already register `reviewModule()`, you don't need it.
|
|
161
156
|
|
|
162
157
|
```ts
|
|
163
158
|
import { drawingModule } from '@docx-editor.dev/pro/drawing';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {readOoxmlPackage,collectSectionPropertyNodes,revisionItemsOf,ooxmlTreesEqual,applyTreeOp,resolveHeaderFooterResolutionBySection,relationshipsOf,serializeOoxmlPart,readOoxmlPart,withPart,withContentTypeOverride,relsPartNameFor,writeOoxmlPackage,commentsPartNameForStory,resolveNotesPart,settingsPartOf,numberingRootOf,stylesPartOf,resolveRelationship,resolveInternalTarget,sha256Bytes,withBinaryPart,resolveContentTypeOf,digestPart}from'@docx-editor.dev/core/store';function M(e,...t){for(let n of t)for(let r of n)e.push(r);return e}var Ne="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Lr={pgSz:{w:"12240",h:"15840",orient:"portrait"},pgMar:{top:"1440",right:"1440",bottom:"1440",left:"1440",header:"720",footer:"720",gutter:"0"},cols:{num:"1",space:"720",equalWidth:"1",sep:"0"},vAlign:{val:"top"},type:{val:"nextPage"},textDirection:{val:"lrTb"},pgNumType:{fmt:"decimal",start:"0"},lnNumType:{countBy:"0",restart:"newPage"},docGrid:{type:"default"},paperSrc:{first:"0",other:"0"}},It=new Set(["titlePg","bidi","rtlGutter","formProt","noEndnote"]),At={pgSz:new Set(["code"]),docGrid:new Set(["linePitch","charSpace"])},Ye=e=>e.namespaceUri===Ne?e.localName:null;function _t(e,t,n){let r=new Map(e.filter(l=>l.namespaceUri===Ne).map(l=>[l.localName,l])),o=e.map(l=>({name:l.namespaceUri===Ne?l.localName:"",xml:n.serialize(l)})),s=(l,a)=>o.push({name:l,xml:a});for(let l of t){if(l.namespaceUri!==Ne)return null;let a=l.localName,c=Lr[a],d=r.get(a);if(!d){if(It.has(a)){s(a,`<w:${a} w:val="0"/>`);continue}if(l.attributes.length===0&&l.children.length===0)continue;if(!c||l.children.length>0)return null;let p=a==="docGrid"?' w:type="default"':"";for(let m of l.attributes){let x=Ye(m);if(x!==null&&At[a]?.has(x)||a==="docGrid"&&x==="type")continue;let h=x===null?void 0:c[x];if(h===void 0)return null;p+=` w:${x}="${h}"`;}s(a,`<w:${a}${p}/>`);continue}let u=new Set(d.attributes.map(p=>Ye(p))),f="";for(let p of l.attributes){let m=Ye(p);if(m!==null&&u.has(m))continue;if(It.has(a)&&m==="val"){f+=' w:val="1"';continue}if(m!==null&&At[a]?.has(m)&&!(a==="docGrid"&&u.has("type")))continue;let x=m===null||!c?void 0:c[m];if(x===void 0)return null;f+=` w:${m}="${x}"`;}if(f){let p=o.find(m=>m.name===a);p&&(p.xml=p.xml.replace(/^(<[^\s/>]+)/,`$1${f}`));}}let i=l=>{let a=Dt.indexOf(l);return a<0?Dt.length:a};return o.map((l,a)=>({...l,index:a})).sort((l,a)=>i(l.name)-i(a.name)||l.index-a.index).map(l=>l.xml).join("")}var Dt=["footnotePr","endnotePr","type","pgSz","pgMar","paperSrc","pgBorders","lnNumType","pgNumType","cols","formProt","vAlign","noEndnote","titlePg","textDirection","bidi","rtlGutter","docGrid","printerSettings"];var Ve=3e3;function fe(e,t,n=Ve){return Ft(e,t,n)??Ut(e,t)}function Ft(e,t,n=Ve){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r++;let o=e.length,s=t.length;for(;o>r&&s>r&&e[o-1]===t[s-1];)o--,s--;let i=Wr(e,t,r,o,r,s,n);if(!i)return null;let l=[];for(let a=0;a<r;a++)l.push({op:"eq",a,b:a});M(l,i);for(let a=0;o+a<e.length;a++)l.push({op:"eq",a:o+a,b:s+a});return l}function Wr(e,t,n,r,o,s,i){let l=r-n,a=s-o;if(l===0&&a===0)return [];if(l===0)return Array.from({length:a},(g,k)=>({op:"ins",b:o+k}));if(a===0)return Array.from({length:l},(g,k)=>({op:"del",a:n+k}));let c=l+a,d=c+1,u=new Int32Array(2*c+3),f=[],p=-1,m=Math.min(c,i);for(let g=0;g<=m;g++){f.push(u.slice(d-g,d+g+1));for(let k=-g;k<=g;k+=2){let w=k===-g||k!==g&&u[d+k-1]<u[d+k+1]?u[d+k+1]:u[d+k-1]+1,P=w-k;for(;w<l&&P<a&&e[n+w]===t[o+P];)w++,P++;if(u[d+k]=w,w>=l&&P>=a){p=g;break}}if(p>=0)break}if(p<0)return null;let x=[],h=l,y=a;for(let g=p;g>0;g--){let k=f[g],w=C=>k[C+g],P=h-y,R=P===-g||P!==g&&w(P-1)<w(P+1),E=R?P+1:P-1,A=w(E),N=A-E;for(;h>A&&y>N;)h--,y--,x.push({op:"eq",a:n+h,b:o+y});R?x.push({op:"ins",b:o+N}):x.push({op:"del",a:n+A}),h=A,y=N;}for(;h>0&&y>0;)h--,y--,x.push({op:"eq",a:n+h,b:o+y});return Oe(x.reverse())}function Oe(e){let t=[],n=[],r=[],o=()=>{M(t,r,n),n=[],r=[];};for(let s of e)s.op==="eq"?(o(),t.push(s)):s.op==="del"?n.push(s):r.push(s);return o(),t}function Ut(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,o=t.length;for(;r>n&&o>n&&e[r-1]===t[o-1];)r--,o--;let s=[];for(let i=0;i<n;i++)s.push({op:"eq",a:i,b:i});for(let i=n;i<r;i++)s.push({op:"del",a:i});for(let i=n;i<o;i++)s.push({op:"ins",b:i});for(let i=0;r+i<e.length;i++)s.push({op:"eq",a:r+i,b:o+i});return s}function Bt(e,t,n,r,o=Ve){let s=Ft(e,t,o);if(s)return s;let i=[],l=[];for(let u=0;u<e.length;u++)n(u)&&i.push(u);for(let u=0;u<t.length;u++)r(u)&&l.push(u);if(i.length===0||i.length!==l.length||i.some((u,f)=>e[u]!==t[l[f]]))return Ut(e,t);let a=[],c=0,d=0;for(let u=0;u<=i.length;u++){let f=u<i.length?i[u]:e.length,p=u<l.length?l[u]:t.length;for(let m of fe(e.slice(c,f),t.slice(d,p),o))m.op==="eq"?a.push({op:"eq",a:m.a+c,b:m.b+d}):m.op==="del"?a.push({op:"del",a:m.a+c}):a.push({op:"ins",b:m.b+d});u<i.length&&a.push({op:"eq",a:f,b:p}),c=f+1,d=p+1;}return a}var jr=/[\p{sc=Han}\u3000-\u303F\uFF01-\uFF0F\uFF1A-\uFF20]/u,Kr=/\p{sc=Hiragana}/u,zr=/[\p{sc=Katakana}\u30FC]/u,qr=/[\p{sc=Thai}\p{sc=Lao}\p{sc=Khmer}\p{sc=Myanmar}]/u,Hr=/[\p{L}\p{M}\p{N}_]/u,Xr=/\s/u,Gr=/['\u2019]/u;function Ze(e){return jr.test(e)?"han":Kr.test(e)?"hiragana":zr.test(e)?"katakana":qr.test(e)?"dictionary":Hr.test(e)?"word":Xr.test(e)?"space":"other"}var Ee;function Yr(e){let t=[],n=0;for(;n<e.length;){let o=e.codePointAt(n)>65535?2:1,s=Ze(e.slice(n,n+o)),i=n+o;if(s!=="other"&&s!=="space")for(;i<e.length;){let a=e.codePointAt(i)>65535?2:1,c=Ze(e.slice(i,i+a));if(c!==s&&!(c==="word"&&/\p{M}/u.test(e[i]))&&(s!=="word"||!Gr.test(e[i])||Ze(e[i+1]??"")!=="word"))break;i+=a;}s==="dictionary"?Vr(e,n,i,t):t.push([n,i]),n=i;}return t}function Vr(e,t,n,r){if(Ee===void 0&&(Ee=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"word"}):null),!Ee){r.push([t,n]);return}for(let o of Ee.segment(e.slice(t,n)))r.push([t+o.index,t+o.index+o.segment.length]);}var Zr="\xB6",ne="\xB6END",be=class{#e=new Map;#t=new WeakMap;#n=new WeakMap;#i=new WeakMap;#o=new WeakMap;controls(t){let n=this.#o.get(t.wrappers);if(n===void 0){let r=t.wrappers.filter(o=>ue(o.key)).map(o=>pe(o.key)).join("");n=r===""?"":this.#r(`C:${r}`),this.#o.set(t.wrappers,n);}return n}of(t){let n=this.#t.get(t.wrappers);n||(n=new Map,this.#t.set(t.wrappers,n));let r=n.get(t.fields);if(r===void 0){let o=[...t.wrappers.filter(s=>!ue(s.key)).map(s=>this.#s(this.#n,s,()=>s.key)),...(t.fields??[]).map(s=>this.#s(this.#i,s,()=>Qr(s)))];r=o.length===0?"":this.#r(o.join("")),n.set(t.fields,r);}return r}#s(t,n,r){let o=t.get(n);return o===void 0&&(o=this.#r(r()),t.set(n,o)),o}#r(t){let n=this.#e.get(t);return n===void 0&&(n=`S${this.#e.size}`,this.#e.set(t,n)),n}};function Lt(e,t,n,r){let o=e.atoms,s="";for(let i of o)s+=i.text;for(let[i,l]of Yr(s))n.push({kind:"text",key:Jr(o,i,l,r),unit:e,from:i,to:l});n.push({kind:"mark",key:t?ne:`${Zr}${e.sectPr?"S":""}`,unit:e});}function Jr(e,t,n,r){let o="",s="";for(let i=t;i<n;i++){let l=e[i],a=r.of(l);(i===t?a!=="":a!==s)&&(o+=`${a}`),s=a,o+=l.kind==="char"?l.text:`${l.key}`;}return o}var Qr=e=>`F:${e.instr.trim().replace(/\s+/g," ")}`;function Kt(e,t){let n=[],r=0;for(;r<e.length;){if(e[r].op!=="del"){n.push(e[r]),r++;continue}let o=r;for(;o<e.length&&e[o].op==="del";)o++;let s=e.slice(r,o);if(r=o,o<e.length&&e[o].op!=="eq"||s.some(d=>!jt(t[d.a]))){M(n,s);continue}let i=s[0].a,l=s[s.length-1].a,a=0;for(;a<n.length;){let d=n[n.length-1-a];if(d.op!=="eq"||d.a!==i-1-a)break;let u=t[d.a];if(!jt(u)||u.key!==t[l-a].key)break;a++;}if(a===0){M(n,s);continue}let c=n.splice(n.length-a,a);for(let d=i-a;d<=l-a;d++)n.push({op:"del",a:d});c.forEach((d,u)=>n.push({op:"eq",a:l-a+1+u,b:d.b}));}return n}var eo=.3,to=3,Wt=/[\p{L}\p{N}]/u;function zt(e,t,n){if(!n)return [...e];let r=0,o=0;for(let l of e){let a=l.op==="ins"?null:t[l.a];l.op!=="ins"&&(a.kind!=="text"||!Wt.test(a.key)||(r++,l.op==="eq"&&o++));}if(r===0||o/r>=eo)return [...e];let s=[],i=0;for(;i<e.length;){if(e[i].op!=="eq"){s.push(e[i]),i++;continue}let l=i,a=0;for(;l<e.length&&e[l].op==="eq";){let c=t[e[l].a];c.kind==="text"&&Wt.test(c.key)&&a++,l++;}for(let c of e.slice(i,l)){let d=t[c.a];a<to&&(d.kind==="text"||d.kind==="mark"&&d.key!==ne)?s.push({op:"del",a:c.a},{op:"ins",b:c.b}):s.push(c);}i=l;}return Oe(s)}function qt(e,t,n){let r=[],o=0;for(let s=0;s<e.length;s++){let i=e[s];if(i.op!=="eq"||t[i.a].kind!=="mark")continue;let l=e.slice(o,s),a=l.every(d=>d.op!=="eq"&&(d.op==="ins"?n[d.b]:t[d.a]).kind==="text"),c=l.some(d=>d.op==="ins")&&l.some(d=>d.op==="del");a&&c&&t[i.a].key!==ne?M(r,l.filter(d=>d.op==="ins"),[{op:"ins",b:i.b}],l.filter(d=>d.op==="del"),[{op:"del",a:i.a}]):M(r,l,[i]),o=s+1;}return M(r,e.slice(o)),r}var jt=e=>e.kind==="text"&&!e.key.includes(""),no=/^[^\p{L}\p{N}]+$/u;function Ht(e,t){let n=[],r=0;for(;r<e.length;){let o=e[r];if(o.op!=="eq"){n.push(o),r++;continue}let s=r;for(;s<e.length&&e[s].op==="eq";)s++;if(e.slice(r,s).every(l=>{let a=t[l.a];return a.kind==="text"&&no.test(a.key)})&&r>0&&s<e.length&&ro(e,r,s))for(let l of e.slice(r,s))n.push({op:"del",a:l.a},{op:"ins",b:l.b});else M(n,e.slice(r,s));r=s;}return Oe(n)}function ro(e,t,n){let r=false,o=false;for(let s=t-1;s>=0&&e[s].op!=="eq";s--)e[s].op==="ins"?r=true:o=true;for(let s=n;s<e.length&&e[s].op!=="eq";s++)e[s].op==="ins"?r=true:o=true;return r&&o}function oo(e,t,n,r){let o=`<w:${e}${r.attrs()}/>${n.markRPr}`;t.markRPr!==n.markRPr&&(o+=`<w:rPrChange${r.attrs()}><w:rPr>${t.markRPr}</w:rPr></w:rPrChange>`);let s=t.pPr.join(""),i=n.pPr.join(""),l=s===i?"":`<w:pPrChange${r.attrs()}><w:pPr>${s}</w:pPr></w:pPrChange>`;return `<w:pPr>${i}<w:rPr>${o}</w:rPr>${l}</w:pPr>`}var so=3,Je=new Map,io=/[\p{L}\p{N}]+/gu;function Xt(e,t){return e.kind!=="paragraph"||e===t||e.sectPr||e.atoms.some(r=>r.kind!=="char")?false:(e.atoms.map(r=>r.text).join("").match(io)?.length??0)>=so}function Gt(e,t,n,r){if(e.length<2)return Je;let o=new Map,s=new Map;e.forEach((l,a)=>{for(let c of l.base)Xt(c,t)&&o.set(c.key,o.has(c.key)?null:{unit:c,hunk:a});for(let c of l.revised)Xt(c,n)&&s.set(c.key,s.has(c.key)?null:{unit:c,hunk:a});});let i=new Map;for(let[l,a]of o){let c=s.get(l);if(!a||!c||a.hunk===c.hunk)continue;let d=`move${++r.state.moves}`;i.set(a.unit,{kind:"moveFrom",name:d,partner:c.unit}),i.set(c.unit,{kind:"moveTo",name:d,partner:a.unit});}return i}function Yt(e,t,n){let r=t.kind==="moveFrom",o=r?e:t.partner,s=r?t.partner:e,i=n.detectFormatChanges&&o.atoms.length===s.atoms.length&&(o.pPr.join("")!==s.pPr.join("")||o.markRPr!==s.markRPr||o.atoms.some((f,p)=>f.rPr!==s.atoms[p].rPr)),l=e.atoms.map((f,p)=>{if(!i)return {mark:t.kind,atom:f,baseRPr:f.rPr,markers:f.markers};let m=s.atoms[p].rPr;return {mark:t.kind,atom:r?{...f,rPr:m}:f,baseRPr:o.atoms[p].rPr,markers:f.markers}}),a=i?oo(t.kind,o,s,n):Re(t.kind,r?e:null,r?null:e,n),c=n.rangeAttrs(t.name),d=me(l,n),u=e.trailingMarkers.join("");return ge(a,`<w:${t.kind}RangeStart${c.attrs}/>${d}<w:${t.kind}RangeEnd w:id="${c.id}"/>${u}`)}var W="http://schemas.openxmlformats.org/officeDocument/2006/relationships",S=e=>e.kind!=="textValue",O=e=>S(e)?e.children.filter(S):[],$=(e,t)=>O(e).find(n=>n.localName===t);function b(e,t,n){if(S(e))return e.attributes.find(r=>r.localName===t&&(n===void 0||r.namespaceUri===n))?.value}var lo="http://schemas.openxmlformats.org/markup-compatibility/2006",co="http://www.w3.org/2001/XMLSchema-instance";function fo(e){let t=new Set,n=[e];for(;n.length>0;){let r=n.pop();for(let o of r.attributes)if(o.namespaceUri===lo||o.namespaceUri===""&&o.localName==="Requires"||o.namespaceUri===co&&o.localName==="type")for(let i of o.value.split(/\s+/)){let l=i.indexOf(":");i&&t.add(l<0?i:i.slice(0,l));}M(n,O(r));}return t}function Vt(e,t){if(!S(e)||t.length===0)return e;let n=fo(e);if(n.size===0)return e;let r=new Set(e.namespaceBindings.map(s=>s.prefix)),o=t.filter(s=>n.has(s.prefix)&&!r.has(s.prefix));return o.length===0?e:{...e,namespaceBindings:[...e.namespaceBindings,...o]}}function $e(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _(e){return $e(e).replace(/"/g,""")}var uo={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function re(e){return e.includes("&")?e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[A-Za-z]+);/g,(t,n)=>{if(n[0]!=="#")return uo[n]??t;let r=n[1]==="x"?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return r>=0&&r<=1114111?String.fromCodePoint(r):t}):e}var po=/(?<!\s)\s+xmlns(?::([A-Za-z_][\w.-]*))?="([^"]*)"/g,H=class{#e=new Map;serialize(t){let n=serializeOoxmlPart({id:"fragment",name:"/fragment.xml",contentType:"application/xml",root:t});return this.strip(n.replace(/^<\?xml[^>]*\?>\s*/,""))}strip(t){return t.replace(po,(n,r,o)=>{if(r===void 0)return n;let s=r,i=this.#e.get(s);return i===void 0?(this.#e.set(s,o),""):i===o?"":n})}uriOf(t){return this.#e.get(t)}declarations(){return [...this.#e].filter(([t])=>t!==""&&t!=="xml").sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>` xmlns:${t}="${_(n)}"`).join("")}};function oe(e){let t=/^<([^\s/>]+)([^>]*)\/>$/.exec(e);if(t)return {start:`<${t[1]}${t[2]}>`,end:`</${t[1]}>`};let n=/^<([^\s/>]+)[^>]*>/.exec(e);return n?{start:n[0],end:`</${n[1]}>`}:{start:e,end:""}}function se(e){if(/^<[^>]*\/>$/.test(e))return "";let t=/^<[^>]*>/.exec(e),n=/<\/[^>]+>$/.exec(e);return !t||!n?"":e.slice(t[0].length,e.length-n[0].length)}var Se=e=>new Set([e]);function V(e,t,n,r,o="",s=false){let i=`${e}Change`,l=n??t,a=n?r.revised:r.base,c=z($(l,e),a,Z[e]);if(c+=o,t&&n&&r.detectFormatChanges&&(s||ie(e,t,n,r))){let d=z($(t,e),r.base,Z[e]);c+=`<w:${i}${r.attrs()}><w:${e}>${d}</w:${e}></w:${i}>`;}return c?`<w:${e}>${c}</w:${e}>`:e==="tblPr"?"<w:tblPr/>":""}var Z={tblPr:Se("tblPrChange"),trPr:new Set(["trPrChange","ins","del"]),tcPr:new Set(["tcPrChange","cellIns","cellDel","cellMerge"]),tblPrEx:Se("tblPrExChange")};function ie(e,t,n,r){let o=z($(t,e),r.base,Z[e]),s=z($(n,e),r.revised,Z[e]);return Ce(o)!==Ce(s)}var Ce=e=>e.replace(/\sw:rsid\w*="[^"]*"/g,"");function mo(e,t,n){let r=t??e,o=t?n.revised:n.base,s=$(r,"tblGrid"),i=z(s,o,Se("tblGridChange"));if(e&&t&&n.detectFormatChanges){let l=z($(e,"tblGrid"),n.base,Se("tblGridChange"));l!==i&&(i+=`<w:tblGridChange${n.idOnly()}><w:tblGrid>${l}</w:tblGrid></w:tblGridChange>`);}return `<w:tblGrid>${i}</w:tblGrid>`}var Zt=e=>O(e).filter(t=>t.localName==="tr"),X=e=>O(e).filter(t=>t.localName==="tc"),go=new Set(["tblPr","tblGrid","tr"]),tt=new Set(["tblPrEx","trPr","tc"]);function Jt(e,t,n,r){let o=[],s=0;for(let i of e?O(e):[])i.localName===n?s++:t.has(i.localName)||o.push({at:s,xml:r.serialize(i)});return o}var Qt=(e,t)=>e.length===t.length&&e.every((n,r)=>n.at===t[r].at&&Ce(n.xml)===Ce(t[r].xml));function Me(e,t,n,r,o){let s=Jt(e,n,r,o.base);if(!t)return s;let i=Jt(t,n,r,o.revised);return (i.length>0&&(!e||!Qt(s,i))||s.length>0&&!Qt(s,i))&&o.state.untracked++,e?s:[]}function tn(e){let t=new Map;for(let n of e)t.set(n.at,(t.get(n.at)??"")+n.xml);return n=>t.get(n)??""}function he(e,t,n){let o=mo(e,t,n),s=`<w:tbl>${V("tblPr",e,t,n)}${o}`,i=!!e&&!!t&&(ie("tblPr",e,t,n)||o.includes("<w:tblGridChange")),l=e?Zt(e):[],a=t?Zt(t):[],c=Me(e,t,go,"tr",n),d=0,u=0,f=0,p=()=>{for(;f<c.length;){let x=c[f].at;if(!(!e||d===x)||!(!t||u===x)){if(e&&d>x||t&&u>x){n.state.untracked++,f++;continue}return}s+=c[f].xml,f++;}},m=(x,h,y)=>{p(),s+=x,h&&d++,y&&u++;};if(e)if(t){let x=[],h=[],y=()=>{let g=0;for(;g<x.length&&g<h.length&&X(x[g]).length===X(h[g]).length;)m(en(x[g],h[g],n,i),true,true),g++;for(let k of x.slice(g))m(Qe(k,n,i),true,false);for(let k of h.slice(g))m(et(k,n),false,true);x=[],h=[];};for(let g of fe(l.map(ve),a.map(ve)))if(g.op==="eq"){y();let k=l[g.a],w=a[g.b];X(k).length===X(w).length?m(en(k,w,n,i),true,true):(m(Qe(k,n,i),true,false),m(et(w,n),false,true));}else g.op==="del"?x.push(l[g.a]):h.push(a[g.b]);y();}else for(let x of l)m(Qe(x,n,i),true,false);else for(let x of a)m(et(x,n),false,true);return p(),f<c.length&&n.state.untracked++,`${s}</w:tbl>`}function Te(e,t){let n=$(e,"tblPrEx");return n?t.serialize(n):""}function ho(e,t,n){let r=$(t,"tblPrEx"),o=$(e,"tblPrEx");if(!n.detectFormatChanges||!ie("tblPrEx",e,t,n))return Te(t,n.revised);if(!o)return n.state.unrecordedProperties++,Te(t,n.revised);let s=z(o,n.base,Z.tblPrEx);return `<w:tblPrEx>${r?z(r,n.revised,Z.tblPrEx):""}<w:tblPrExChange${n.attrs()}><w:tblPrEx>${s}</w:tblPrEx></w:tblPrExChange></w:tblPrEx>`}function en(e,t,n,r){let o=X(e),s=X(t),i=r||ie("trPr",e,t,n)||ie("tblPrEx",e,t,n)||s.some((c,d)=>ie("tcPr",o[d],c,n)),l=tn(Me(e,t,tt,"tc",n)),a=`<w:tr>${ho(e,t,n)}${V("trPr",e,t,n)}`;return s.forEach((c,d)=>{let u=o[d];a+=`${l(d)}<w:tc>${V("tcPr",u,c,n,"",i)}${B(F(u,n.base),F(c,n.revised),n)}</w:tc>`;}),`${a}${l(s.length)}</w:tr>`}function Qe(e,t,n){let r=tn(Me(e,null,tt,"tc",t)),o=l=>{if(!n||!t.detectFormatChanges)return V("tcPr",l,null,t);let a=z($(l,"tcPr"),t.base,Z.tcPr);return `<w:tcPr>${a}<w:tcPrChange${t.attrs()}><w:tcPr>${a}</w:tcPr></w:tcPrChange></w:tcPr>`},s=`<w:tr>${Te(e,t.base)}${V("trPr",e,null,t,`<w:del${t.attrs()}/>`)}`,i=X(e);for(let[l,a]of i.entries())s+=`${r(l)}<w:tc>${o(a)}${B(F(a,t.base),[],t)}</w:tc>`;return `${s}${r(i.length)}</w:tr>`}function et(e,t){Me(null,e,tt,"tc",t);let n=`<w:tr>${Te(e,t.revised)}${V("trPr",null,e,t,`<w:ins${t.attrs()}/>`)}`;for(let r of X(e))n+=`<w:tc>${V("tcPr",null,r,t)}${B([],F(r,t.revised),t)}</w:tc>`;return `${n}</w:tr>`}function ye(e,t,n){let r=t??e,o=t?n.revised:n.base,i=((c,d)=>O(c).filter(u=>u.localName==="sdtPr"||u.localName==="sdtEndPr").map(u=>d.serialize(u)).join(""))(r,o),l=(c,d)=>{let u=c?$(c,"sdtContent"):void 0;return u?F(u,d):[]},a=B(l(e,n.base),l(t,n.revised),n);return `<w:sdt>${i}<w:sdtContent>${a}</w:sdtContent></w:sdt>`}function B(e,t,n,r=false){if(e.length===0&&t.length===0)return "";let o=nn(e),s=nn(t);if((o<e.length||s<t.length)&&e[o-1]?.kind==="paragraph"&&t[s-1]?.kind==="paragraph")return B(e.slice(0,o),t.slice(0,s),n,r)+B(e.slice(o),t.slice(s),n);let i=[],l=null;for(let f of fe(e.map(p=>p.key),t.map(p=>p.key)))f.op==="eq"?(l=null,i.push({kind:"pair",base:e[f.a],revised:t[f.b]})):(l||(l={base:[],revised:[]},i.push({kind:"hunk",...l})),f.op==="del"?l.base.push(e[f.a]):l.revised.push(t[f.b]));wo(i);let a=e[e.length-1],c=t[t.length-1],d=Gt(i.filter(f=>f.kind==="hunk"),a,c,n),u="";for(let f of i)if(f.kind==="pair")u+=an(f.base,f.revised,n,f.base===a&&f.revised===c);else {let p=a?.kind==="paragraph"&&c?.kind==="paragraph"&&f.base.includes(a)&&f.revised.includes(c),m=r&&(e.length===0||t.length===0);u+=ln(f.base,f.revised,p||m?a??null:null,p||m?c??null:null,n,d);}return u}var yo=/<[A-Za-z_][\w.-]*:fldData[\s/>]/;function ko(e,t,n){for(let r=0;r<e.to-e.from;r++){let o=n.controls(e.unit.atoms[e.from+r]),s=n.controls(t.unit.atoms[t.from+r]);if(o!==""&&s!==""&&o!==s)return true}return false}var xo=/^(?:customXml|altChunk|oMathPara|oMath)$/;function nn(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n.kind!=="opaque"||xo.test(n.node.localName))break;t--;}return t}function wo(e){let t=e[e.length-1],n=e[e.length-2];if(t?.kind!=="hunk"||n?.kind!=="pair"||n.base.kind!=="paragraph"||n.revised.kind!=="paragraph")return;let r=t.base[t.base.length-1],o=t.revised[t.revised.length-1];r?.kind==="paragraph"&&o?.kind==="paragraph"||e.splice(e.length-2,2,{kind:"hunk",base:[n.base,...t.base],revised:[n.revised,...t.revised]});}function an(e,t,n,r=false){return e.kind==="paragraph"&&t.kind==="paragraph"?ln([e],[t],r?e:null,r?t:null,n):e.kind==="table"&&t.kind==="table"?rn(e.node,t.node,n)??he(e.node,t.node,n):e.kind==="sdt"&&t.kind==="sdt"?rn(e.node,t.node,n)??ye(e.node,t.node,n):n.base.serialize(e.node)}var Po=/<(?:[\w.-]+:)?(?:footnoteReference|endnoteReference|commentReference|commentRangeStart)\b/;function rn(e,t,n){let r=n.base.raw(e);if(Po.test(r))return null;let o=n.revised.raw(t);return n.base.keyOf(r)!==n.revised.keyOf(o)?null:n.base.remap(r)}function on(e,t,n,r){let o=[];for(let s of e){let i=n.get(s);i&&s.kind==="paragraph"?o.push({kind:"move",key:`${i.kind}:${i.name}`,unit:s,end:i}):s.kind==="paragraph"?Lt(s,s===t,o,r):o.push({kind:"block",key:s.key,unit:s});}return o}function ln(e,t,n,r,o,s=Je){let i=Ro(e,t,o);if(i.length===0)return nt(e,t,n,r,o,s);let l="",a=0,c=0;for(let[d,u]of i)l+=nt(e.slice(a,d),t.slice(c,u),n,r,o,s),l+=cn(e[d],t[u],o),a=d+1,c=u+1;return l+nt(e.slice(a),t.slice(c),n,r,o,s)}function nt(e,t,n,r,o,s){if(e.length===0&&t.length===0)return "";let i=new be,l=on(e,n,s,i),a=on(t,r,s,i),c=bo(Eo(qt(zt(Ht(Kt(Bt(l.map(h=>h.key),a.map(h=>h.key),h=>l[h].kind!=="text",h=>a[h].kind!=="text"),l),l),l,e.length>1||t.length>1),l,a),l,a),l,a),d="",u=[],f="",p=(h,y="both")=>{let g=y==="base"?No:Oo;u.length===0||y!=="both"&&f===""&&u.every(k=>g.has(k.mark))?d+=h:f+=h;},m=(h,y,g)=>{let k=(y&&h!=="ins"?y.trailingMarkers.join(""):"")+(g&&g!==y&&h!=="del"?g.trailingMarkers.join(""):"");d+=ge(Re(h,y,g,o),me(u,o)+k),u=[],d+=f,f="";},x=(h,y)=>{let g=h.unit.atoms;for(let k=h.from;k<h.to;k++)if(g[k].wrappers.some(w=>w.key.startsWith("fldSimple|")&&yo.test(w.start))){o.state.untracked++;break}for(let k=h.from;k<h.to;k++){let w=g[k];if(w.note&&y==="del"&&o.state.deletedNotes.push({kind:w.note.kind,base:w.note.id}),w.note&&y==="ins"){o.state.newNotes.push({kind:w.note.kind,revised:w.note.id});let P=Ie(w.note.kind,w.note.id);w={...w,xml:w.xml.replace(/\bw:id="[^"]*"/,`w:id="${P}"`)};}if(w.node){let P=rt(y==="del"?w:null,y==="ins"?w:null,o);w={...w,xml:P,delXml:P};}u.push({mark:y,atom:w,baseRPr:"",markers:w.markers});}};for(let h of c){if(h.op==="pair"){p(cn(h.base,h.revised,o));continue}if(h.op==="eq"){let k=l[h.a],w=a[h.b];if(k.kind==="text"&&w.kind==="text"&&ko(k,w,i))x(k,"del"),x(w,"ins");else if(k.kind==="text"&&w.kind==="text")for(let P=0;P<k.to-k.from;P++){let R=k.unit.atoms[k.from+P],E=w.unit.atoms[w.from+P];R.note&&E.note&&(o.state.notePairs.push({kind:E.note.kind,base:R.note.id,revised:E.note.id}),E={...E,xml:R.xml}),R.node&&E.node?E={...E,xml:rt(R,E,o)}:E.kind==="object"&&R.kind==="object"&&!E.note&&(E={...E,xml:R.xml,delXml:R.delXml}),u.push({mark:"eq",atom:E,baseRPr:R.rPr,markers:[...R.markers,...E.markers]});}else k.kind==="mark"&&w.kind==="mark"?m("eq",k.unit,w.unit):k.kind==="block"&&w.kind==="block"&&p(an(k.unit,w.unit,o));continue}let y=h.op==="del"?l[h.a]:a[h.b],g=h.op;y.kind==="text"?x(y,g):y.kind==="mark"?y.key===ne&&(l.length===0||a.length===0)?m("eq",y.unit,y.unit):m(g,g==="del"?y.unit:null,g==="ins"?y.unit:null):y.kind==="move"?p(Yt(y.unit,y.end,o),y.end.kind==="moveFrom"?"base":"revised"):p(g==="del"?Co(y.unit,o):To(y.unit,o),g==="del"?"base":"revised");}return u.length>0&&(d+=ge("",me(u,o)),o.state.untracked++),d+f}var No=new Set(["ins","moveTo"]),Oo=new Set(["del","moveFrom"]);function Eo(e,t,n){let r=[],o=0;for(;o<e.length;){if(e[o].op==="eq"){r.push(e[o]),o++;continue}let s=o;for(;s<e.length&&e[s].op!=="eq";)s++;let i=e.slice(o,s),l=i.filter(f=>f.op==="ins"),a=i.filter(f=>f.op==="del"),c=0,d=0,u=new Map;a.forEach((f,p)=>{let m=t[f.a];if(m.kind!=="block")return;let x=u.get(m.unit.kind)??{positions:[],next:0};x.positions.push(p),u.set(m.unit.kind,x);});for(let f=0;f<l.length;f++){let p=n[l[f].b];if(p.kind!=="block"||p.unit.kind==="opaque")continue;let m=u.get(p.unit.kind);if(!m)continue;for(;m.next<m.positions.length&&m.positions[m.next]<d;)m.next++;let x=m.positions[m.next]??-1;x<0||(M(r,l.slice(c,f),a.slice(d,x)),r.push({op:"pair",base:t[a[x].a].unit,revised:p.unit}),c=f+1,d=x+1);}M(r,l.slice(c),a.slice(d)),o=s;}return r}function bo(e,t,n){let r=[],o=0;for(;o<e.length;){let s=e[o];if(s.op!=="ins"&&s.op!=="del"){r.push(s),o++;continue}let i=o;for(;i<e.length&&(e[i].op==="ins"||e[i].op==="del");)i++;let l=e.slice(o,i),a=l.filter(f=>f.op==="del"),c=-1;a.forEach((f,p)=>{f.op==="del"&&t[f.a].kind==="block"&&(c=p);});let d=[...l].reverse().find(f=>f.op==="ins"),u=d!==void 0&&n[d.b].kind==="mark";if(c<0||!d||c===a.length-1&&u)M(r,l);else {let f=l.filter(p=>p.op==="ins");M(r,a.slice(0,c+1),f,a.slice(c+1));}o=i;}return r}function sn(e,t){if(e.kind!=="sdt")return null;let n=$(e.node,"sdtPr");return n?t.keyOf(t.raw(n)):""}function Ro(e,t,n){if(e.length+t.length<=2)return [];let r=new Map;t.forEach((i,l)=>{let a=sn(i,n.revised);if(a===null)return;let c=r.get(a)??{at:[],next:0};c.at.push(l),r.set(a,c);});let o=[];if(r.size===0)return o;let s=-1;for(let i=0;i<e.length;i++){let l=sn(e[i],n.base),a=l===null?void 0:r.get(l);if(!a)continue;for(;a.next<a.at.length&&a.at[a.next]<=s;)a.next++;let c=a.at[a.next];c!==void 0&&(a.next++,o.push([i,c]),s=c);}return o}function cn(e,t,n){return e.kind==="table"?he(e.node,t.node,n):ye(e.node,t.node,n)}var $o="http://schemas.openxmlformats.org/wordprocessingml/2006/main",So=new Set(["altChunk","customXml","r","hyperlink","fldSimple"]),dn=e=>e.node.namespaceUri!==$o||So.has(e.node.localName);function Co(e,t){return e.kind==="table"?he(e.node,null,t):e.kind==="sdt"?ye(e.node,null,t):(dn(e)&&t.state.untracked++,t.base.serialize(e.node))}function To(e,t){return e.kind==="table"?he(null,e.node,t):e.kind==="sdt"?ye(null,e.node,t):(dn(e)&&t.state.untracked++,"")}var vo=e=>`${D}TXBX:${e}\xA7`;function Ae(e){let t=[],n=r=>{if(S(r)){if(r.localName==="txbxContent"){t.push(r);return}for(let o of r.children)n(o);}};return n(e),t}function ot(e){let t=0,n=r=>S(r)?r.localName==="txbxContent"?{...r,children:[{id:`${r.id}:marker`,kind:"textValue",value:vo(t++)}]}:{...r,children:r.children.map(n)}:r;return n(e)}function rt(e,t,n){let r=t??e,o=t?n.revised:n.base,s=r.node,i=o.serialize(ot(s)),l=e?.node?Ae(e.node):[],a=t?.node?Ae(t.node):[],c=Math.max(l.length,a.length),d=[];for(let f=0;f<c;f++){let p=l[f],m=a[f];d.push(B(p?F(p,n.base):[],m?F(m,n.revised):[],n));}let u=new RegExp(`${D}TXBX:(\\d+)\xA7`,"g");return i.replace(u,(f,p)=>d[Number(p)]??f)}var Mo="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function q(e,t,n="val"){let r=new Set;for(let o of e.parts.values()){let s=[o.root];for(let i=s.pop();i;i=s.pop()){if(t.has(i.localName)&&i.namespaceUri===Mo){let l=b(i,n);l!==void 0&&r.add(l);}for(let l of O(i))s.push(l);}}return r}function G(e,t=1){let n=new Set;for(let o of e){n.add(o);let s=o.trim();/^[+-]?\d+$/.test(s)&&n.add(String(BigInt(s)));}let r=t;return ()=>{for(;n.has(String(r));)r++;return n.add(String(r)),String(r)}}var Uo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";function Y(e,t){switch(t){case "styles":{let n=stylesPartOf(e);return n&&(relationshipsOf(e,e.mainDocumentPart).some(o=>{if(o.type!==Uo)return false;let s=resolveRelationship(o);return s.mode==="Internal"&&s.target.ok&&s.target.partName===n.name})||n.name==="/word/styles.xml")?n:void 0}case "numbering":{let n=numberingRootOf(e);if(!n)return;for(let r of e.parts.values())if(r.root===n)return r;return}case "settings":return settingsPartOf(e)??void 0;case "footnotes":return resolveNotesPart(e,"footnote")??void 0;case "endnotes":return resolveNotesPart(e,"endnote")??void 0;case "comments":{let n=commentsPartNameForStory(e,e.mainDocumentPart);return n===null?void 0:e.parts.get(n)}}}var un=new WeakMap,De=e=>(e.startsWith("/")?e:`/${e}`).replace(/[A-Z]/g,t=>t.toLowerCase());function ae(e,t){let n=un.get(e);if(!n){let r=new Set;for(let o of e.parts.keys())r.add(De(o));for(let o of e.partBytes.keys())r.add(De(o));Bo(e,r),un.set(e,n=r);}return n.has(De(t))}function Bo(e,t){for(let n of e.relationships.values())for(let r of n){let o=resolveRelationship(r);o.mode==="Internal"&&o.target.ok&&t.add(De(o.target.partName));}}function le(e,t){let n=r=>ae(e,r);if(!n(t))return t;for(let r=2;;r++){let o=t.replace(/\.xml$/,`${r}.xml`);if(!n(o))return o}}var _e=e=>`application/vnd.openxmlformats-officedocument.wordprocessingml.${e}+xml`;var Wo="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Nn=new WeakMap;function On(e){return Nn.get(e)}var jo=/(<(?:[\w.-]+:)?numId\b[^>]*?\s(?:[\w.-]+:)?val=")([^"]*)(")/g;function Ue(e,t){return t.size===0||!e.includes("numId")?e:e.replace(jo,(n,r,o,s)=>{let i=t.get(o);return i===void 0?n:`${r}${i}${s}`})}var ce=(e,t)=>Y(e,t);function j(e){return serializeOoxmlPart({id:"fragment",name:"/fragment.xml",contentType:"application/xml",root:e}).replace(/^<\?xml[^>]*\?>\s*/,"")}function En(e,t,n){let r=/^<([^\s/>]+)([^>]*)\/>\s*$/.exec(e);if(r)return `<${r[1]}${r[2]}>${n}</${r[1]}>`;let o=t.length>0?new RegExp(`<(?:[\\w.-]+:)?(?:${t.join("|")})[\\s/>]`).exec(e):null,s=o?o.index:e.lastIndexOf("</");return e.slice(0,s)+n+e.slice(s)}var bn=(e,t,n)=>En(j(e.root),t,n),Ko=e=>e.replace(/<(?:[\w.-]+:)?numPicBullet\b[\s\S]*?<\/(?:[\w.-]+:)?numPicBullet>/g,"").replace(/<(?:[\w.-]+:)?lvlPicBulletId\b[^>]*\/>/g,""),mn=e=>Ko(e).replace(/<(?:[\w.-]+:)?(?:nsid|styleLink|numStyleLink)\b[^>]*\/>/g,"").replace(/\s[\w.-]+:durableId="[^"]*"/g,"");function Rn(e,t,n,r){return {partName:le(e,`/word/${r}.xml`),contentType:_e(r),xml:t,isNew:true,relType:`${Wo}/${r}`}}var $n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",gn=new Set(["numId"]),zo=new Set(["abstractNumId"]),qo=new Set(["pStyle","rStyle","tblStyle","basedOn","next","link","numStyleLink","styleLink"]);function Ho(e,t,n){let r=ce(t,"styles");if(!r)return null;let o=ce(e,"styles"),s=new Set(q(e,qo)),i=new Map;for(let c of o?O(o.root):[]){if(c.localName!=="style")continue;let d=b(c,"styleId");s.add(d),d!==void 0&&!i.has(d)&&i.set(d,c);}let l="",a=new Map;for(let c of O(r.root)){if(c.localName!=="style")continue;let d=b(c,"styleId"),u=d===void 0?void 0:i.get(d);if(u&&!a.has(u)){let m=Xo(u,c,n);m!==null&&a.set(u,m);continue}if(d===void 0||s.has(d))continue;s.add(d);let f=/^<[^>]*>/.exec(j(c))[0],p=j(c).replace(f,f.replace(/\s[\w.-]*:?default="[^"]*"/,""));l+=Ue(p,n);}return !l&&a.size===0?null:o?{partName:o.name,contentType:o.contentType,xml:a.size===0?bn(o,[],l):Zo(o,a,l),isNew:false}:Rn(e,`<w:styles xmlns:w="${$n}">${l}</w:styles>`,r,"styles")}function Xo(e,t,n){let r=j(e),o=Ue(j(t),n);if(kn(r)===kn(o))return null;let s=Go(/^<[^>]*?\/?>/.exec(r)[0],/^<[^>]*?\/?>/.exec(o)[0]);if(s===null)return o;let i=/^<([^\s/>]+)/.exec(r)[1];return `${s}${Vo(o)}</${i}>`}function Go(e,t){let n=new Map;for(let l of t.matchAll(yn))n.set(l[1]??"",l[2]);let r=new Map;for(let l of e.matchAll(yn))r.set(l[1]??"",l[2]);let o=/^<([^\s/>]+)/.exec(e)[1],s=[...e.matchAll(Yo)].map(l=>l[0]).filter(l=>!/^\s*xmlns(?::|=)/.test(l));for(let l of [o,...s.map(a=>a.trim())]){let a=/^([\w.-]+):/.exec(l)?.[1];if(a===void 0||a==="xml")continue;let c=n.get(a);if(c!==void 0&&r.has(a)&&c!==r.get(a))return null}let i="";for(let[l,a]of r)n.has(l)||(i+=hn(l,a));for(let[l,a]of n)i+=hn(l,a);return `<${o}${i}${s.join("")}>`}var hn=(e,t)=>e===""?` xmlns="${t}"`:` xmlns:${e}="${t}"`,Yo=/\s[\w.:-]+="[^"]*"/g,yn=/\sxmlns(?::([A-Za-z_][\w.-]*))?="([^"]*)"/g,kn=e=>e.replace(/\s[\w.-]+:rsid\w*="[^"]*"/g,"").replace(/<(?:[\w.-]+:)?rsid\b[^>]*\/>/g,"");function Vo(e){if(/^<[^>]*\/>$/.test(e))return "";let t=/^<[^>]*>/.exec(e)[0];return e.slice(t.length,e.lastIndexOf("</"))}function Zo(e,t,n){let r=e.root,o=j(r),s=/^<[^>]*?\/?>/.exec(o)[0].replace(/\/>$/,">"),i=/^<([^\s/>]+)/.exec(o)[1],l="";for(let a of O(r))l+=t.get(a)??j(a);return `${s}${l}${n}</${i}>`}function Jo(e){return O(e).filter(n=>n.localName!=="nsid"&&n.localName!=="tmpl"&&n.localName!=="styleLink"&&n.localName!=="numStyleLink").map(j).join("")}function st(e,t){let n=new Map,r=new Map;for(let s of O(e.root))if(s.localName==="abstractNum"){let i=b(s,"abstractNumId");i!==void 0&&n.set(i,s);}else if(s.localName==="num"){let i=b(s,"numId");i!==void 0&&r.set(i,s);}let o=new Map;for(let s of t?O(t.root):[]){if(s.localName!=="style")continue;let i=b(s,"styleId"),l=$(s,"pPr"),a=l&&$(l,"numPr"),c=a&&$(a,"numId"),d=c&&b(c,"val");i!==void 0&&d!==void 0&&o.set(i,d);}return {abstracts:n,nums:r,styleLists:o}}var xn=e=>b($(e,"abstractNumId")??e,"val"),Qo=4;function Fe(e,t){let n=xn(e);for(let r=0;n!==void 0&&r<Qo;r++){let o=t.abstracts.get(n),s=o&&$(o,"numStyleLink"),i=s&&b(s,"val"),l=i===void 0?void 0:t.styleLists.get(i),a=l===void 0?void 0:t.nums.get(l),c=a&&xn(a);if(c===void 0||c===n)return n;n=c;}return n}function wn(e){let t=new Map;return n=>{let r=Fe(n,e)??"",o=t.get(r);if(o===void 0){let i=e.abstracts.get(r);o=i?Jo(i):`missing:${r}`,t.set(r,o);}let s=O(n).filter(i=>i.localName!=="abstractNumId").map(j).join("");return `${o}${s}`}}function Pn(e){let t=new Map;for(let[n,r]of e.nums){let o=Fe(r,e);if(o===void 0)continue;let s=t.get(o)??[];s.push(n),t.set(o,s);}return t}function es(e,t){let n=new Map,r=ce(t,"numbering"),o=ce(e,"numbering");if(!r){for(let y of o?st(o,void 0).nums.keys():[])n.set(y,"0");return {map:n,output:null}}let s=o?st(o,ce(e,"styles")):{abstracts:new Map,nums:new Map,styleLists:new Map},i=st(r,ce(t,"styles")),l=wn(s),a=wn(i),c=Pn(s),d=new Map,u=new Set;for(let[y,g]of Pn(i)){let k,w=g.every(E=>{let A=s.nums.get(E);if(!A||l(A)!==a(i.nums.get(E)))return false;let N=Fe(A,s);return k??=N,N===k}),P=new Set(g),R=k!==void 0&&(c.get(k)??[]).every(E=>!i.nums.has(E)||P.has(E));if(!(!w||!R||k===void 0)){for(let E of g)u.add(E);d.set(y,k);}}let f=G([...s.abstracts.keys(),...q(e,zo)]),p=G([...s.nums.keys(),...i.nums.keys(),...q(e,gn),...q(t,gn)]),m="",x="";for(let[y,g]of i.nums){if(u.has(y))continue;let k=Fe(g,i),w=k===void 0?void 0:i.abstracts.get(k);if(!w||k===void 0){n.set(y,"0");continue}let P=d.get(k);P===void 0&&(P=f(),d.set(k,P),m+=mn(j(w).replace(/(\babstractNumId=")[^"]*"/,`$1${P}"`)));let R=p();x+=mn(j(g).replace(/(\bnumId=")[^"]*"/,`$1${R}"`).replace(/(<(?:[\w.-]+:)?abstractNumId\b[^>]*?\s(?:[\w.-]+:)?val=")[^"]*"/,`$1${P}"`)),n.set(y,R);}for(let y of s.nums.keys())!i.nums.has(y)&&!n.has(y)&&n.set(y,"0");if(!m&&!x)return {map:n,output:null};if(!o){let y=`<w:numbering xmlns:w="${$n}">${m}${x}</w:numbering>`;return {map:n,output:Rn(e,y,r,"numbering")}}let h=bn(o,["num","numIdMacAtCleanup"],m);return h=En(h,["numIdMacAtCleanup"],x),{map:n,output:{partName:o.name,contentType:o.contentType,xml:h,isNew:false}}}function Sn(e,t){let n=es(e,t);return Nn.set(t,n.map),[Ho(e,t,n.map),n.output].filter(r=>r!==null)}var We="\uFFFC",D=`\xA7${[...globalThis.crypto.getRandomValues(new Uint32Array(4))].map(e=>e.toString(16).padStart(8,"0")).join("")}`,rs=e=>`${D}CMT:${J(e)}\xA7`,J=e=>encodeURIComponent(e),K=e=>decodeURIComponent(e),Tn=/(\b([A-Za-z_][\w.-]*):(id|embed|link|pict|href|dm|lo|qs|cs|relid)=")([^"]+)"/g,os="urn:schemas-microsoft-com:office:office",ct=`${D}REL:`,dt=`${D}DOCPR:`,ss=/(<(?:[A-Za-z_][\w.-]*:)?docPr\b[^>]*?\sid=")([^"]*)"/g,ft=`${D}ZORDER:`,is=/(<(?:[A-Za-z_][\w.-]*:)?anchor\b[^>]*?\srelativeHeight=")([^"]*)"/g,as=new Set(["bookmarkStart","bookmarkEnd","commentRangeStart","commentRangeEnd","permStart","permEnd","moveFromRangeStart","moveFromRangeEnd","moveToRangeStart","moveToRangeEnd"]),Fn=new Set(["proofErr","lastRenderedPageBreak","noProof"]),ls=new Set(["hyperlink","sdt","fldSimple","smartTag","customXml","dir","bdo"]),Un={sdt:new Set(["sdtPr","sdtEndPr"]),smartTag:new Set(["smartTagPr"]),customXml:new Set(["customXmlPr"]),fldSimple:new Set(["fldData"])},ue=e=>e.startsWith("sdt|")||e.startsWith("smartTag|")||e.startsWith("customXml|");function pe(e){if(!e.startsWith("sdt|"))return e;let t=/<w:id w:val="([^"]*)"/.exec(e)?.[1];return t===void 0?e:`sdt#${t}`}var L=class{constructor(t,n,r,o){this.name=t;this.pkg=n;this.partName=r;this.scope=o;this.#e=new Map([...relationshipsOf(n,r).map(s=>[s.id,{type:s.type,target:s.rawTarget,external:s.targetMode==="External"}]),...n.externalTargets.filter(s=>s.ownerPart===r).map(s=>[s.id,{type:s.type,target:s.rawTarget,external:true}])]);}name;pkg;partName;scope;#e;#t=new Map;relKey(t){let n=this.#e.get(t);if(!n)return `missing:${t}`;if(n.external)return `${n.type}|${n.target}`;let r=this.#t.get(t);if(r===void 0){let o=Bn(this.partName,n.target),s={seen:new Set,visits:0,local:false};r=`${n.type}|${Ln(this.pkg,o,s)}`,this.#t.set(t,r);}return r}externalTarget(t){let n=this.#e.get(t);return n?.external?n.target:void 0}raw(t){let n=this.pkg.parts.get(this.partName)?.root,r=this.scope.serialize(Vt(t,n&&S(n)?n.namespaceBindings:[])),o=this.name==="revised"?On(this.pkg):void 0;return o?Ue(r,o):r}serialize(t){return this.remap(this.raw(t))}remap(t){if(this.name==="base")return t;let n=vn(t);return t.replace(Tn,(r,o,s,i,l)=>this.#n(s,i,n)?`${o}${ct}${J(this.partName)}|${J(re(l))}\xA7"`:r).replace(ss,(r,o,s)=>`${o}${dt}${J(re(s))}\xA7"`).replace(is,(r,o,s)=>`${o}${ft}${J(re(s))}\xA7"`)}keyOf(t){let n=vn(t);return ds(t).replace(Tn,(r,o,s,i,l)=>this.#n(s,i,n)?`${o}${this.relKey(re(l))}"`:r)}#n(t,n,r){return (r.get(t)??this.scope.uriOf(t))===(n==="relid"?os:W)}},it=/\s[\w.-]+:(?:paraId|textId|rsid\w*)="[^"]*"/g,cs=/\sxmlns:([\w.-]+)="[^"]*"/g;function ds(e){if(!it.test(e))return e;it.lastIndex=0;let t=e.replace(it,"");return t.replace(cs,(n,r)=>t.includes(`${r}:`,t.indexOf(n)+n.length)?n:"")}function vn(e){let t=new Map;if(!e.includes("xmlns:"))return t;for(let n of e.matchAll(/\sxmlns:([^\s=]+)="([^"]*)"/g))t.has(n[1])||t.set(n[1],n[2]);return t}function Bn(e,t){let n=resolveInternalTarget(e,t);return n.ok?n.partName:`invalid:${e}|${t}`}var Mn=new WeakMap,In=new TextEncoder,An=256,fs=0;function Ln(e,t,n){let r=Mn.get(e);r||Mn.set(e,r=new Map);let o=r.get(t);if(o!==void 0)return o;if(n.seen.has(t))return n.local=true,`cycle:${t}`;if(n.seen.size>=An||n.visits>=An)return n.local=true,`overflow:${++fs}`;n.seen.add(t);let s=e.parts.get(t),i=e.partBytes.get(t)??e.partBytes.get(t.slice(1))??(s?In.encode(serializeOoxmlPart(s)):void 0),l=i?sha256Bytes(i):`missing:${t}`,a=n.local;n.local=false;for(let c of relationshipsOf(e,t)){n.visits++;let d=c.targetMode==="External"?`external:${c.rawTarget}`:Ln(e,Bn(t,c.rawTarget),n);l+=`|${c.id}:${c.type}:${d}`;}return n.seen.delete(t),l=sha256Bytes(In.encode(l)),n.local||r.set(t,l),n.local||=a,l}function F(e,t){let n=[];for(let r of O(e))switch(r.localName){case "p":n.push(ms(r,t));break;case "tbl":n.push({kind:"table",side:t.name,node:r,key:`T:${us(r)}`});break;case "sdt":n.push({kind:"sdt",side:t.name,node:r,key:`S:${t.keyOf(t.raw(r))}`});break;case "sectPr":case "tcPr":break;default:n.push({kind:"opaque",side:t.name,node:r,key:`O:${t.keyOf(t.raw(r))}`});}return n}function us(e){let t=[];for(let n of O(e).filter(r=>r.localName==="tr"))t.push(ve(n));return t.join("")}function ve(e){return O(e).filter(t=>t.localName==="tc").map(t=>at(t)).join("")}function at(e){return S(e)?e.localName==="p"?`${e.children.map(at).join("")}\xB6`:e.localName==="instrText"?"":e.children.map(at).join(""):e.value}var Be="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ps(e,t,n){let r=b(e,"fldCharType",Be);r==="begin"&&(t.fieldStack.push({instr:""}),t.fields=[...t.fieldStack]),n(),r==="end"&&t.fieldStack.length>0&&(t.fieldStack.pop(),t.fields=t.fieldStack.length>0?[...t.fieldStack]:void 0);}function ms(e,t){let n=$(e,"pPr"),r=[],o="",s=null;for(let a of n?O(n):[])a.localName==="rPr"?o=se(t.serialize(Wn(a))):a.localName==="sectPr"?s=a:a.localName!=="pPrChange"&&r.push(t.serialize(a));let i={atoms:[],pending:[],fieldStack:[],fields:void 0};for(let a of e.children)S(a)&&a.localName!=="pPr"&<(a,t,[],i);let l=i.atoms.map(a=>a.kind==="char"?a.text:`${a.key}`).join("");return {kind:"paragraph",side:t.name,node:e,pPr:r,markRPr:o,sectPr:s,atoms:i.atoms,trailingMarkers:i.pending,key:`P:${l}`}}var gs=new Set(["ins","del","moveFrom","moveTo","rPrChange"]);function Wn(e){return {...e,children:e.children.filter(t=>!(S(t)&&gs.has(t.localName)))}}function lt(e,t,n,r){let o=e.localName;if(!Fn.has(o)){if(as.has(o)){t.name==="base"?r.pending.push(t.serialize(e)):(o==="commentRangeStart"||o==="commentRangeEnd")&&r.pending.push(jn(t.serialize(e)));return}if(o==="r"){ks(e,t,n,r);return}if(o==="ins"||o==="moveTo"){for(let s of O(e))lt(s,t,n,r);return}if(!(o==="del"||o==="moveFrom")){if(ls.has(o)){let s=hs(e,t),i=o==="sdt"?$(e,"sdtContent"):e,l=r.atoms.length;for(let a of i?O(i):[])Un[o]?.has(a.localName)||lt(a,t,[...n,s],r);r.atoms.length===l&&r.atoms.push({kind:"object",text:We,xml:"",delXml:"",key:"empty",rPr:"",wrappers:[...n,s],markers:ut(r),...r.fields?{fields:r.fields}:{}}),s.atomCount=r.atoms.length-l;return}Le(e,"",t,n,r,true);}}}function hs(e,t){let n=e.localName,r=Un[n],o=r?O(e).filter(p=>r.has(p.localName)):[],s=n==="sdt"?$(e,"sdtContent"):void 0,i={...e,children:[...o,...s?[{...s,children:[]}]:[]]},l=t.raw(i),a,c;if(n==="sdt"){let p=l.lastIndexOf("<w:sdtContent"),m=oe(l.slice(p,l.indexOf(">",p)+1));a=l.slice(0,p)+m.start,c=`${m.end}</w:sdt>`;}else (({start:a,end:c}=oe(l))),o.length>0&&(a+=se(l));let d=b(e,"id",W),u=`${n}|${d?t.relKey(d):""}|${t.keyOf(a)}`,f=ys(e,t,d);return {key:u,start:t.remap(a),end:c,...f===void 0?{}:{field:f}}}var Dn=e=>/["\\]/.test(e)?void 0:`"${e}"`;function ys(e,t,n){if(e.localName==="fldSimple"){if($(e,"fldData"))return;let s=b(e,"instr",Be);return s&&s.trim()!==""?s:void 0}if(e.localName!=="hyperlink")return;let r=["HYPERLINK"];if(n){let s=t.externalTarget(n),i=s===void 0?void 0:Dn(s);if(i===void 0)return;r.push(i);}for(let[s,i]of [["anchor","l"],["tooltip","o"],["tgtFrame","t"]]){let l=b(e,s,Be);if(l===void 0)continue;let a=Dn(l);if(a===void 0)return;r.push(`\\${i} ${a}`);}if(r.length===1)return;let o=b(e,"history",Be);return o!=="1"&&o!=="true"&&o!=="on"&&r.push("\\h"),` ${r.join(" ")} `}function ks(e,t,n,r){let o=$(e,"rPr"),s=o?se(t.serialize(Wn(o))):"";for(let i of O(e))switch(i.localName){case "rPr":break;case "t":case "delText":{let l=i.children.map(a=>a.kind==="textValue"?a.value:"").join("");for(let a=0;a<l.length;a++)r.atoms.push({kind:"char",text:l[a],xml:"",delXml:"",key:"",rPr:s,wrappers:n,markers:ut(r),...r.fields?{fields:r.fields}:{}});break}case "commentReference":{let l=`<w:r>${s?`<w:rPr>${s}</w:rPr>`:""}${t.serialize(i)}</w:r>`;r.pending.push(t.name==="base"?l:jn(l));break}case "fldChar":ps(i,r,()=>Le(i,s,t,n,r));break;case "instrText":{let l=r.fieldStack[r.fieldStack.length-1];l&&(l.instr+=i.children.map(a=>a.kind==="textValue"?a.value:"").join("")),Le(i,s,t,n,r);break}default:Fn.has(i.localName)||Le(i,s,t,n,r);}}function Le(e,t,n,r,o,s=false){let i=n.raw(e),l=n.remap(i),a=l.replace(/^<w:instrText\b/,"<w:delInstrText").replace(/<\/w:instrText>$/,"</w:delInstrText>"),c=Ae(e).length>0,d=e.localName==="footnoteReference"?"footnote":e.localName==="endnoteReference"?"endnote":void 0,u=d?b(e,"id"):void 0;o.atoms.push({kind:"object",text:We,xml:l,delXml:a,key:d?`noteRef:${d}:${e.attributes.filter(f=>f.localName!=="id").map(f=>`${f.namespaceUri??""}|${f.localName}=${f.value}`).sort().join(" ")}`:c?n.keyOf(n.raw(ot(e))):n.keyOf(i),rPr:t,wrappers:r,markers:ut(o),...d&&u!==void 0?{note:{kind:d,id:u}}:{},...c?{node:e}:{},...s?{outsideRun:true}:{},...o.fields?{fields:o.fields}:{}});}function jn(e){return e.replace(/\bw:id="([^"]*)"/,(t,n)=>`w:id="${rs(re(n))}"`)}var xs=Object.freeze([]);function ut(e){if(e.pending.length===0)return xs;let t=e.pending;return e.pending=[],t}var ws="http://schemas.openxmlformats.org/wordprocessingml/2006/main",je=class{nextId=1;count=0;untracked=0;furnitureIds=new Map;sectionReferences=new Map;baseSectionIndex=new WeakMap;unrecordedProperties=0;moves=0;notePairs=[];newNotes=[];deletedNotes=[]},Ie=(e,t)=>`${D}NOTE:${e}:${J(t)}\xA7`,Xn=new RegExp(`${D}NOTE:(footnote|endnote):([^\xA7"]+)\xA7`,"g"),Ke=class e{constructor(t,n,r,o,s,i){this.state=t;this.author=n;this.date=r;this.detectFormatChanges=o;this.base=s;this.revised=i;}state;author;date;detectFormatChanges;base;revised;withSides(t,n){return new e(this.state,this.author,this.date,this.detectFormatChanges,t,n)}get revisionCount(){return this.state.count}rangeAttrs(t){let n=this.state.nextId++,r=this.date===void 0?"":` w:date="${this.date}"`;return {id:n,attrs:` w:id="${n}" w:author="${_(this.author)}"${r} w:name="${t}"`}}idOnly(){return this.state.count++,` w:id="${this.state.nextId++}"`}attrs(){this.state.count++;let t=this.date===void 0?"":` w:date="${this.date}"`;return ` w:id="${this.state.nextId++}" w:author="${_(this.author)}"${t}`}},Ps=(e,t)=>e.length===t.length&&e.every((n,r)=>n.key===t[r].key);function Gn(e){let t=[],n=0;for(;n<e.length;){let r=e[n],o=r.atom.wrappers.findIndex(p=>p.field!==void 0);if(o<0||r.mark==="eq"){t.push(r),n++;continue}let s=r.atom.wrappers[o],i=n+1;for(;i<e.length&&e[i].atom.wrappers[o]===s;)i++;if(!((n===0||e[n-1].atom.wrappers[o]!==s)&&i-n===s.atomCount&&e.slice(n,i).every(p=>p.mark===r.mark))){M(t,e.slice(n,i)),n=i;continue}let a=r.atom.wrappers.slice(0,o),c=(p,m,x=[])=>({mark:r.mark,baseRPr:"",markers:x,atom:{kind:"object",text:We,xml:p,delXml:m,key:"",rPr:"",wrappers:a,markers:x}}),d=p=>{let m=`<w:fldChar w:fldCharType="${p}"/>`;return c(m,m)},u=$e(s.field),f=e.slice(n,i).map((p,m)=>({...p,markers:m===0?[]:p.markers,atom:{...p.atom,wrappers:[...a,...p.atom.wrappers.slice(o+1)]}}));M(t,[{...d("begin"),markers:r.markers},c(`<w:instrText xml:space="preserve">${u}</w:instrText>`,`<w:delInstrText xml:space="preserve">${u}</w:delInstrText>`),d("separate")],Gn(f),[d("end")]),n=i;}return t}var Kn=new Set(["del","moveFrom"]);function Ns(e){let t=new Map,n=r=>t.get(r)??r;for(let r=1;r<e.length;r++){let o=e[r-1],s=e[r],i=Kn.has(o.mark);if(i===Kn.has(s.mark))continue;let[l,a]=i?[o,s]:[s,o],c=Math.min(l.atom.wrappers.length,a.atom.wrappers.length);for(let d=0;d<c;d++){let u=n(l.atom.wrappers[d]),f=n(a.atom.wrappers[d]);if(!(u===f||u.key===f.key)){if(!ue(u.key)||pe(u.key)!==pe(f.key))break;t.set(u,f);}}}return t.size===0?e:e.map(r=>r.atom.wrappers.some(o=>t.has(o))?{...r,atom:{...r.atom,wrappers:r.atom.wrappers.map(n)}}:r)}function me(e,t){let n=Ns(e),r=n.some(d=>d.mark!=="eq")?Gn(n):n,o="",s=[],i="eq",l=()=>{i!=="eq"&&(o+=`</w:${i}>`),i="eq";},a=d=>{let u=0;for(;u<s.length&&u<d.length&&s[u].key===d[u].key;)u++;if(!(u===s.length&&u===d.length)){for(l();s.length>u;)o+=s.pop().end;for(let f=u;f<d.length;f++)s.push(d[f]),o+=d[f].start;}},c=0;for(;c<r.length;){let d=r[c],u=zn(d,t),f=c+1;for(;f<r.length;){let p=r[f];if(p.markers.length>0||p.mark!==d.mark||p.atom.rPr!==d.atom.rPr||p.atom.kind==="object"||d.atom.kind==="object"||!Ps(p.atom.wrappers,d.atom.wrappers)||zn(p,t)!==u||u&&p.baseRPr!==d.baseRPr)break;f++;}if(a(d.atom.wrappers),d.markers.length>0&&(l(),o+=d.markers.join("")),d.mark!==i&&(l(),d.mark!=="eq"&&(o+=`<w:${d.mark}${t.attrs()}>`),i=d.mark),d.atom.outsideRun){o+=d.atom.xml,c=f;continue}o+=Os(r.slice(c,f),u?d.baseRPr:null,d.mark==="del",t),c=f;}for(l();s.length>0;)o+=s.pop().end;return o}var zn=(e,t)=>(e.mark==="eq"||e.mark==="moveFrom"||e.mark==="moveTo")&&t.detectFormatChanges&&e.baseRPr!==e.atom.rPr;function Os(e,t,n,r){let o=e[0].atom.rPr;t!==null&&(o+=`<w:rPrChange${r.attrs()}><w:rPr>${t}</w:rPr></w:rPrChange>`);let s="",i="",l=()=>{if(i==="")return;let a=n?"w:delText":"w:t";s+=`<${a} xml:space="preserve">${$e(i)}</${a}>`,i="";};for(let{atom:a}of e)a.kind==="char"?i+=a.text:(l(),s+=n?a.delXml:a.xml);return l(),`<w:r>${o?`<w:rPr>${o}</w:rPr>`:""}${s}</w:r>`}var mt=e=>e.localName==="headerReference"||e.localName==="footerReference",pt=e=>e?O(e).filter(t=>!mt(t)&&t.localName!=="sectPrChange"):[];function qn(e,t){return pt(e).map(n=>t.serialize(n)).join("")}function ze(e,t,n,r="",o=false){let s=t??e;if(!s)return "";let i=t?n.revised:n.base,l=(e?O(e).filter(mt).map(f=>n.base.serialize(f)).join("")+(o?"":bs(e,n)):t&&!o?Es(t,n):"")+r,a=t||!o?qn(s,i):"",c="";if(n.detectFormatChanges&&(o||e&&t)){let f=e?qn(e,n.base):"";if(Hn(f)!==Hn(a)){let p=_t(pt(e),a?pt(s):[],n.base);p===null&&n.state.unrecordedProperties++,c=`<w:sectPrChange${n.attrs()}><w:sectPr>${p??f}</w:sectPr></w:sectPrChange>`;}}return `${i.raw({...s,children:[]}).replace(/\/>$/,">")}${l}${a}${c}</w:sectPr>`}function Es(e,t){let n="";for(let r of O(e).filter(mt)){let o=b(r,"type",ws)??"default",s=t.state.furnitureIds.get(b(r,"id",W)??"");if(s===void 0||!/^(default|first|even)$/.test(o)){t.state.unrecordedProperties++;continue}n+=`<w:${r.localName} xmlns:r="${W}" w:type="${o}" r:id="${_(s)}"/>`;}return n}function bs(e,t){let n=t.state,r=n.baseSectionIndex.get(e);if(r===void 0)return "";let o="";for(let{kind:s,type:i,id:l}of n.sectionReferences.get(r)??[])o+=`<w:${s}Reference xmlns:r="${W}" w:type="${i}" r:id="${_(l)}"/>`;return o}var Hn=e=>e.replace(/\sw:rsid\w*="[^"]*"/g,"");function Re(e,t,n,r){let o=e==="del"||e==="moveFrom"?t:n,s=o.markRPr;e!=="eq"?s=`<w:${e}${r.attrs()}/>${s}`:t&&r.detectFormatChanges&&t.markRPr!==o.markRPr&&(s+=`<w:rPrChange${r.attrs()}><w:rPr>${t.markRPr}</w:rPr></w:rPrChange>`);let i="";e==="eq"?i=ze(t?.sectPr??null,o.sectPr,r):o.sectPr&&(e==="ins"||e==="del")&&(i=ze(e==="del"?o.sectPr:null,e==="del"?null:o.sectPr,r));let l="";e==="eq"&&t&&r.detectFormatChanges&&t.pPr.join("")!==o.pPr.join("")&&(l=`<w:pPrChange${r.attrs()}><w:pPr>${t.pPr.join("")}</w:pPr></w:pPrChange>`);let a=`${o.pPr.join("")}${s?`<w:rPr>${s}</w:rPr>`:""}${i}${l}`;return a?`<w:pPr>${a}</w:pPr>`:""}function ge(e,t){return `<w:p>${e}${t}</w:p>`}function z(e,t,n){if(!e)return "";let r={...e,children:e.children.filter(o=>!(o.kind!=="textValue"&&n.has(o.localName)))};return se(t.serialize(r))}var Rs=new RegExp(`${dt}([^\xA7"]*)\xA7`,"g"),$s=new RegExp(`${ft}([^\xA7"]*)\xA7`,"g"),Ss=/<(?:[A-Za-z_][\w.-]*:)?docPr\b[^>]*?\sid="([^"]*)"/g,Cs=/<(?:[A-Za-z_][\w.-]*:)?anchor\b[^>]*?\srelativeHeight="([^"]*)"/g,Zn=4294967295,Yn=1024,qe=class{#e=new Set;#t=new Set;#n=1;constructor(t,n){for(let[r,o]of t.parts){if(n.has(r)||!o.root||!S(o.root))continue;let s=[o.root];for(let i=s.pop();i;i=s.pop()){let l=a=>i.attributes.find(c=>c.localName===a&&!c.namespaceUri)?.value;if(i.localName==="docPr"){let a=l("id");a!==void 0&&this.#e.add(a);}else if(i.localName==="anchor"){let a=l("relativeHeight");a!==void 0&&this.#t.add(a);}for(let a of i.children)S(a)&&s.push(a);}}}reserveWritten(t){for(let n of t.matchAll(Ss))this.#e.add(n[1]);for(let n of t.matchAll(Cs))this.#t.add(n[1]);}resolve(t){return t.replace(Rs,(n,r)=>{let o=K(r);if(Vn(o)&&!this.#e.has(o))return this.#e.add(o),_(o);for(;this.#e.has(String(this.#n));)this.#n++;let s=String(this.#n);return this.#e.add(s),s}).replace($s,(n,r)=>{let o=K(r);if(!Vn(o))return _(o);let s=Number(o);for(;this.#t.has(String(s))&&s+Yn<=Zn;)s+=Yn;let i=String(s);return this.#t.add(i),i})}},Vn=e=>/^\d{1,10}$/.test(e)&&Number(e)<=Zn;var _s="urn:schemas-microsoft-com:office:office";function Fs(e,t){let n=e.parts.get(t)?.root;if(!n||!S(n))return [];let r=[],o=[n];for(let s=o.pop();s;s=o.pop()){for(let i of s.attributes)(i.namespaceUri===W||i.namespaceUri===_s&&i.localName==="relid")&&r.push(i.value);for(let i of s.children)S(i)&&o.push(i);}return r}var Us=new RegExp(`${ct}([^\xA7"|]+)\\|([^\xA7"]+)\xA7`,"g"),Bs=new RegExp(`${D}NEW:([^\xA7"]+)\xA7`,"g"),Qn="http://schemas.openxmlformats.org/package/2006/relationships",er="application/vnd.openxmlformats-package.relationships+xml",tr="The original document declares no content type for relationship parts, which the compare result needs.";function nr(e,t){let n=withPart(e,t);return resolveContentTypeOf(n,t.name)===null?null:n}function rr(e,t,n){let r=relationshipsOf(e,t).find(s=>s.id===n);if(r)return {type:r.type,target:r.rawTarget,external:r.targetMode==="External"};let o=e.externalTargets.find(s=>s.ownerPart===t&&s.id===n);return o?{type:o.type,target:o.rawTarget,external:true}:null}function or(e,t){let n=resolveInternalTarget(e,t);return n.ok?n.partName:null}var Ls=8;function Ws(e,t){return e.parts.has(t)||e.partBytes.has(t)||e.partBytes.has(t.slice(1))}function js(e,t){let n=s=>(s?t.map(i=>i.replace("<Relationship ",`<${s}Relationship `)):t).join(""),r=/<\/((?:[\w.-]+:)?)Relationships>\s*$/;if(r.test(e))return e.replace(r,(s,i)=>`${n(i)}</${i}Relationships>`);let o=/<((?:[\w.-]+:)?)Relationships(\b[^>]*?)\s*\/>\s*$/;return o.test(e)?e.replace(o,(s,i,l)=>`<${i}Relationships${l}>${n(i)}</${i}Relationships>`):null}function ht(e,t){let n=e.slice(0,e.lastIndexOf("/")+1);return t.startsWith(n)?t.slice(n.length):t}var yt=class{constructor(t){this.base=t;}base;#e=new Map;#t=new Map;#n=1;add(t,n,r,o){let s=this.#t.get(t);s||(s=new Set([...relationshipsOf(this.base,t).map(a=>a.id),...this.base.externalTargets.filter(a=>a.ownerPart===t).map(a=>a.id),...Fs(this.base,t)]),this.#t.set(t,s));let i;do i=`rIdCmp${this.#n++}`;while(s.has(i));s.add(i);let l=this.#e.get(t)??[];return l.push(`<Relationship Id="${i}" Type="${_(n)}" Target="${_(r)}"${o?' TargetMode="External"':""}/>`),this.#e.set(t,l),i}entries(){return this.#e.entries()}};function ar(e,t,n){let r=e,o=new yt(e),s=e.mainDocumentPart,i=new Map;for(let p of n)p.isNew&&p.relType&&i.set(p.partName,o.add(s,p.relType,ht(s,p.partName),false));let l=new Map,a=1,c=(p,m)=>{let x=l.get(p);if(x)return x;let h=t.partBytes.get(p)??t.partBytes.get(p.slice(1));if(!h)return {failure:`The revised document refers to a missing part (${p}).`};if(m>Ls)return {failure:"The revised document nests related parts too deeply."};let y=/\.[A-Za-z0-9]+$/.exec(p)?.[0]??"",g;do g=`/word/media/compare${a++}${y}`;while(Ws(r,g)||ae(e,g));l.set(p,g),r=withBinaryPart(r,g,h,resolveContentTypeOf(t,p)??"application/octet-stream");let k=new Map;for(let N of relationshipsOf(t,p))k.set(N.id,{type:N.type,target:N.rawTarget,external:N.targetMode==="External"});for(let N of t.externalTargets)N.ownerPart!==p||k.has(N.id)||k.set(N.id,{type:N.type,target:N.rawTarget,external:true});let w=[...k].map(([N,C])=>({id:N,...C}));if(w.length===0)return g;let P="";for(let N of w){let C=N.target;if(!N.external){let I=or(p,N.target);if(I===null)return {failure:`The revised document has an invalid part name (${N.target}).`};let U=c(I,m+1);if(typeof U!="string")return U;C=ht(g,U);}P+=`<Relationship Id="${_(N.id)}" Type="${_(N.type)}" Target="${_(C)}"${N.external?' TargetMode="External"':""}/>`;}let R=relsPartNameFor(g),E=readOoxmlPart(`<Relationships xmlns="${Qn}">${P}</Relationships>`,{name:R,contentType:er});if(!E.ok)return {failure:`A relationship part is not valid XML (${E.reason}).`};let A=nr(r,E.part);return A?(r=A,g):{failure:tr}},d=new qe(e,new Set(n.map(p=>p.partName)));for(let p of n)d.reserveWritten(p.xml);for(let p of n){let m=new Map,x=null,h=d.resolve(p.xml.replace(Bs,(g,k)=>i.get(k)??""));if(h=h.replace(Us,(g,k,w)=>{let P=K(k),R=K(w),E=`${P}|${R}`,A=m.get(E);if(A)return A;let N=rr(t,P,R);if(!N)return rr(e,p.partName,R)&&(x=`The revised document refers to a missing relationship (${R}).`),_(R);let C=N.target;if(!N.external){let U=or(P,N.target),T=U===null?{failure:`The revised document has an invalid part name (${N.target}).`}:c(U,0);if(typeof T!="string")return x=T.failure,_(R);C=ht(p.partName,T);}let I=o.add(p.partName,N.type,C,N.external);return m.set(E,I),I}),x)return {ok:false,message:x};let y=readOoxmlPart(h,{name:p.partName,contentType:p.contentType});if(!y.ok)return {ok:false,message:`A compared story is not valid XML (${y.reason}).`};r=withPart(r,y.part),p.isNew&&(r=withContentTypeOverride(r,p.partName,p.contentType));}for(let[p,m]of o.entries()){let x=relsPartNameFor(p),h=r.parts.get(x),y=h?js(serializeOoxmlPart(h),m):`<Relationships xmlns="${Qn}">${m.join("")}</Relationships>`;if(y===null)return {ok:false,message:"A relationship part has no root to add relationships to."};let g=readOoxmlPart(y,{name:x,contentType:h?.contentType||er});if(!g.ok)return {ok:false,message:`A relationship part is not valid XML (${g.reason}).`};let k=nr(r,g.part);if(!k)return {ok:false,message:tr};r=k;}let u;try{u=writeOoxmlPackage(r);}catch(p){return {ok:false,message:`The compared package cannot be written (${p.message}).`}}let f=readOoxmlPackage(u);return f.ok?{ok:true,bytes:u,pkg:f.package}:{ok:false,message:`The compared package does not read back (${f.reason}).`}}var Pt="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function de(e,t,n,r){let o=oe(e.serialize({...t,children:[]})),s=n(true);return `${o.start.replace(/>$/,`${e.declarations()}>`)}${""}${s}${""}${o.end}`}function Q(e){let t=resolveHeaderFooterResolutionBySection(e),n=t[t.length-1];return n?xe(n):new Map}function xe(e){let t=new Map;for(let[n,r]of [["header",e.headers],["footer",e.footers]])for(let[o,s]of r)t.set(`${n}:${o}`,{kind:n,type:o,part:s.part,rId:s.rId});return t}function lr(e){let t=resolveHeaderFooterResolutionBySection(e),n=mr(e),r=new Set;for(let o of t.slice(0,-1))for(let s of xe(o).values()){if(n.has(s.part.name))continue;let i=serializeOoxmlPart(s.part).replace(/\sw:rsid\w*="[^"]*"/g,"");r.add(`${s.kind}:${s.type}:${i}`);}return r}var cr=new WeakMap;function Ot(e,t){let n=cr.get(e);if(n||cr.set(e,n=new WeakMap),n.has(t))return n.get(t);let r=zs(e,t);return n.set(t,r),r}function zs(e,t){let n=resolveHeaderFooterResolutionBySection(e),r=resolveHeaderFooterResolutionBySection(t);if(n.length!==r.length){let c=lr(e),d=lr(t);return c.size===d.size&&[...c].every(f=>d.has(f))?{pairs:[],added:[]}:null}let o=new Map,s=Q(e),i=Q(t);for(let[c,d]of s)o.set(d.part.name,i.get(c)?.part.name??"");let l=[],a=[];for(let c=0;c<n.length-1;c++){let d=xe(n[c]),u=xe(r[c]);for(let f of new Set([...d.keys(),...u.keys()])){let p=d.get(f),m=u.get(f);if(!p){a.push({index:c,ref:m});continue}let x=m?.part.name??"",h=o.get(p.part.name);if(h!==void 0){if(h!==x)return null;continue}o.set(p.part.name,x),l.push({base:p,revised:m});}}return {pairs:l,added:a}}function fr(e,t){let n=`/word/compare-${t.kind}-${t.type}.xml`;for(let r=2;ae(e,n);r++)n=`/word/compare-${t.kind}-${t.type}-${r}.xml`;return n}function Et(e,t){let n=new Map,r=new Map,o=Q(e),s=new Set;for(let[a,c]of Q(t)){let u=o.get(a)?.rId;if(!u){let f=fr(e,c);s.add(f),u=`${D}NEW:${f}\xA7`,r.has(c.part.name)||r.set(c.part.name,u);}n.has(c.part.name)||n.set(c.part.name,u);}let i=Ot(e,t);for(let{base:a,revised:c}of i?.pairs??[])c&&!n.has(c.part.name)&&n.set(c.part.name,a.rId);let l=[];for(let{index:a,ref:c}of i?.added??[]){if(r.has(c.part.name))continue;let d=`/word/compare-${c.kind}-${c.type}-s${a+1}`,u=`${d}.xml`;for(let p=2;ae(e,u)||s.has(u);p++)u=`${d}-${p}.xml`;s.add(u);let f=`${D}NEW:${u}\xA7`;r.set(c.part.name,f),n.has(c.part.name)||n.set(c.part.name,f),l.push({partName:u,ref:c});}return {ids:n,insertedIds:r,created:l}}function ur(e,t){let{insertedIds:n}=Et(e,t),r=new Map;for(let{index:o,ref:s}of Ot(e,t)?.added??[]){let i=r.get(o)??[];i.push({kind:s.kind,type:s.type,id:n.get(s.part.name)}),r.set(o,i);}return r}function pr(e,t){let n=Et(e,t).ids,r=new Map;for(let o of resolveHeaderFooterResolutionBySection(t))for(let s of xe(o).values()){let i=n.get(s.part.name);i!==void 0&&!r.has(s.rId)&&r.set(s.rId,i);}return r}function mr(e){return new Set([...Q(e).values()].map(t=>t.part.name))}function xt(e,t,n,r,o){let s=new H,i=new L("base",e,n?.part.name??e.mainDocumentPart,s),l=new L("revised",t,r?.part.name??t.mainDocumentPart,s),a=o.withSides(i,l),c=(n??r).part.root;return de(s,c,()=>B(n?F(n.part.root,i):[],r?F(r.part.root,l):[],a,!n||!r))}function gr(e,t,n){let r=Q(e),o=Q(t),s=[],i="";for(let a of new Set([...r.keys(),...o.keys()])){let c=r.get(a),d=o.get(a),u=xt(e,t,c,d,n);if(c)s.push({partName:c.part.name,contentType:c.part.contentType,xml:u,isNew:false});else {let f=d,p=fr(e,f);s.push({partName:p,contentType:f.part.contentType,xml:u,isNew:true,relType:`${Pt}/${f.kind}`}),i+=`<w:${f.kind}Reference xmlns:r="${W}" w:type="${f.type}" r:id="${D}NEW:${p}\xA7"/>`;}}let l=Ot(e,t);for(let{base:a,revised:c}of l?.pairs??[])s.push({partName:a.part.name,contentType:a.part.contentType,xml:xt(e,t,a,c,n),isNew:false});for(let{partName:a,ref:c}of Et(e,t).created)s.push({partName:a,contentType:c.part.contentType,xml:xt(e,t,void 0,c,n),isNew:true,relType:`${Pt}/${c.kind}`});return {outputs:s,extraRefs:i,unpaired:l===null}}var wt=new Set(["separator","continuationSeparator","continuationNotice"]);function hr(e){let t=new Set([e.mainDocumentPart,...mr(e)]);for(let n of ["footnote","endnote"]){let r=Nt(e,n);r&&t.add(r.name);}return [...t].flatMap(n=>e.parts.get(n)??[])}var Nt=(e,t)=>Y(e,`${t}s`);function dr(e,t){let n=new Map;for(let r of e?O(e.root):[]){if(r.localName!==t)continue;let o=b(r,"id");o!==void 0&&n.set(o,r);}return n}function yr(e,t,n,r){let o=r.state,s=new Map(o.notePairs.filter(P=>P.kind===n).map(P=>[P.base,P.revised])),i=new Set(o.deletedNotes.filter(P=>P.kind===n).map(P=>P.base)),l=o.newNotes.filter(P=>P.kind===n).map(P=>P.revised),a=Nt(e,n),c=Nt(t,n),d=new Map;if(s.size===0&&i.size===0&&l.length===0)return {output:null,ids:d};let u=a??c;if(!u)return {output:null,ids:d};let f=dr(a,n),p=dr(c,n),m=new H,x=new L("base",e,a?.name??e.mainDocumentPart,m),h=new L("revised",t,c?.name??t.mainDocumentPart,m),y=r.withSides(x,h),g=(P,R,E)=>{let A=oe(R.raw({...P,children:[]}));return {start:E===void 0?A.start:A.start.replace(/\bw:id="[^"]*"/,`w:id="${E}"`),end:A.end}},k=q(e,new Set([`${n}Reference`]),"id"),w=de(m,u.root,()=>{let P="",R=[],E=new Map;if(a)for(let N of O(a.root)){let C=b(N,"id"),I=b(N,"type"),U=C===void 0?void 0:s.get(C),T=U===void 0?void 0:p.get(U);if(N.localName!==n||I&&wt.has(I)||C===void 0)N.localName===n&&I&&C!==void 0&&!E.has(I)&&E.set(I,C),P+=x.serialize(N);else if(T){let v=g(N,x);P+=v.start+B(F(N,x),F(T,h),y)+v.end;}else if(i.has(C)){let v=g(N,x);P+=v.start+B(F(N,x),[],y,true)+v.end;}else P+=x.serialize(N);}else if(c){let N=O(c.root).filter(T=>{let v=b(T,"type");return v!==void 0&&wt.has(v)}),C=N.map(T=>b(T,"id")??""),I=G([...k,...C]),U=new Set(k);for(let T of N){let v=b(T,"id"),te=v!==void 0&&U.has(v)?I():v;if(te!==void 0){U.add(te),R.push(te);let Ge=b(T,"type");E.has(Ge)||E.set(Ge,te);}let Mt=h.serialize(T);P+=te===v?Mt:Mt.replace(/^(<[^>]*?\bw:id=")[^"]*"/,(Ge,Br)=>`${Br}${te}"`);}}let A=G([...f.keys(),...R,...k,...q(t,new Set([`${n}Reference`]),"id")]);for(let N of l){let C=p.get(N);if(!C||d.has(N))continue;let I=b(C,"type");if(I!==void 0&&wt.has(I)){let v=E.get(I);v===void 0?o.untracked++:d.set(N,v);continue}let U=A();d.set(N,U);let T=g(C,h,U);P+=T.start+B([],F(C,h),y,true)+T.end;}return P});return {output:{partName:a?.name??le(e,`/word/${n}s.xml`),contentType:a?.contentType??_e(`${n}s`),xml:w,isNew:!a,relType:`${Pt}/${n}s`},ids:d}}var qs=new Set(["commentRangeStart","commentRangeEnd","commentReference"]),Hs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Xs="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",kr=new RegExp(`${D}CMT:([^\xA7"]+)\xA7`,"g"),He=e=>K(e),xr=e=>Y(e,"comments");function wr(e,t,n){let r=new Set;for(let y of n)for(let g of y.xml.matchAll(kr))r.add(He(g[1]));if(r.size===0)return [...n];let o=xr(e),s=xr(t),i=new Map;for(let y of s?O(s.root):[]){let g=y.localName==="comment"?b(y,"id"):void 0;g!==void 0&&r.has(g)&&i.set(g,y);}let l=[];for(let y of o?O(o.root):[]){let g=b(y,"id");g!==void 0&&l.push(g);}let a=G([...l,...q(e,qs,"id")],0),c=new Map;for(let y of i.keys())c.set(y,a());let d=n.map(y=>({...y,xml:y.xml.replace(new RegExp(`<w:comment(?:RangeStart|RangeEnd)\\b[^>]*w:id="${D}CMT:([^\xA7"]+)\xA7"[^>]*/>`,"g"),(g,k)=>c.has(He(k))?g:"").replace(new RegExp(`<w:r>(?:(?!</w:r>).)*?<w:commentReference\\b[^>]*w:id="${D}CMT:([^\xA7"]+)\xA7"[^>]*/></w:r>`,"gs"),(g,k)=>c.has(He(k))?g:"").replace(kr,(g,k)=>c.get(He(k))??"")}));if(c.size===0)return d;let u=new H,f=o?.name??le(e,"/word/comments.xml"),p=o?new L("base",e,o.name,u):null,m=new L("revised",t,s.name,u),x=(o??s).root,h=de(u,x,()=>{let y="";for(let g of o?O(o.root):[])y+=p.serialize(g);for(let[g,k]of i)y+=m.serialize(k).replace(/\bw:id="[^"]*"/,`w:id="${c.get(g)}"`).replace(/\s\w+:(?:paraId|textId)="[^"]*"/g,"");return y});return d.push({partName:f,contentType:o?.contentType||Xs,xml:h,isNew:!o,...o?{}:{relType:Hs}}),d}var $t=hr,Zs={footnoteReference:"footnote",endnoteReference:"endnote"};function Js(e){let t=new Map,n=e[0],r=n?[n.root]:[];for(;r.length>0;){let o=r.pop(),s=Zs[o.localName];if(s){let l=`${s}:${b(o,"id")??""}`;t.has(l)||t.set(l,t.size);continue}let i=O(o);for(let l=i.length-1;l>=0;l--)r.push(i[l]);}return t}function Qs(e,t){let n=e.root.localName==="footnotes"?"footnote":"endnote",r=a=>`${n}:${b(a,"id")??""}`,o=O(e.root),s=o.filter(a=>a.localName!==n),i=o.filter(a=>a.localName===n&&t.has(r(a))).sort((a,c)=>t.get(r(a))-t.get(r(c))),l=[...s,...i];return {...e,root:{...e.root,children:l}}}var Nr=e=>e.root.localName==="footnotes"||e.root.localName==="endnotes",bt="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Or(e){let t=e.replace(/\s+/g," ").trim();if(!/^HYPERLINK\b/i.test(t))return t;let n=/\\l\s+"([^"]*)"/.exec(t);return n?`HYPERLINK \\l ${n[1]}`:"HYPERLINK"}var Er=new WeakMap;function ei(e){let t=Er.get(e);return t||Er.set(e,t=ni(e)),t}function Sr(e){let t="";for(let n of e.children)S(n)&&(n.localName==="t"?t+=n.children.map(r=>S(r)?"":r.value).join(""):t+=Sr(n));return t}function ti(e){let t=O(e).find(r=>r.localName==="sdtPr");if(!t||!O(t).some(r=>r.localName==="showingPlcHdr"))return false;let n=O(e).find(r=>r.localName==="sdtContent");return !n||Sr(n).trim()===""}function ni(e){let t=[],n=[],r=false,o=(a,c,d=false)=>{let u=a.localName,f=u==="p"?a:c,p=d||u==="sdt";if(u==="hyperlink"){let h=b(a,"anchor",bt);t.push(h===void 0?"HYPERLINK":`HYPERLINK \\l ${h}`);}else if(u==="fldChar"){let h=b(a,"fldCharType",bt);if(h==="begin")n.push({instr:"",index:t.length}),t.push("");else if(h==="end"){let y=n.pop();y&&(t[y.index]=Or(y.instr));}}let m=false,x=[];for(let h of a.children){if(!S(h)){x.push(h);continue}if(h.localName==="sdt"&&ti(h)){m=true,r=true;continue}if(h.localName==="instrText"||h.localName==="delInstrText"){let g=n[n.length-1];g&&(g.instr+=h.children.map(k=>S(k)?"":k.value).join("")),m=true;continue}if(h.localName==="fldSimple"){t.push(Or(b(h,"instr",bt)??""));let g=O(h).filter(w=>w.localName!=="fldData").map(w=>o(w,f,p)),k=f&&!p?ri(e,f,g):null;k?M(x,k):(M(x,g),r=true),m=true;continue}let y=o(h,f,p);y!==h&&(m=true),x.push(y);}return m?{...a,children:x}:a};if(!S(e.root))return {part:e,fields:""};let s=o(e.root,null);if(s===e.root)return {part:e,fields:Rt(t)};let i={...e,root:s};if(!r)return {part:i,fields:Rt(t)};let l=readOoxmlPart(serializeOoxmlPart(i),{name:e.name,contentType:e.contentType});return {part:l.ok?l.part:i,fields:Rt(t)}}function ri(e,t,n){if(!S(e.root))return null;let r={...t,children:n},o=O(e.root).find(c=>c.localName==="body"),s=o?[{...o,children:[r]}]:[r],i=readOoxmlPart(serializeOoxmlPart({...e,root:{...e.root,children:s}}),{name:e.name,contentType:e.contentType});if(!i.ok||!S(i.part.root))return null;let l=O(i.part.root)[0],a=l?.localName==="body"?O(l)[0]:l;return a?.localName==="p"?a.children.filter(c=>S(c)):null}function Rt(e){let t="",n=[];for(let r of e){if(r.startsWith("HYPERLINK")){if(r===t)continue;t=r;}n.push(r);}return n.join("|")}function we(e,t){let n=[],r=Js(e);for(let o of e){let{part:s,fields:i}=ei(Nr(o)?Qs(o,r):o),l=digestPart(s);if(!l)continue;let a=Nr(s),c=l.paragraphs.filter(d=>t==="properties"&&!a||d.text.trim()!=="").map(d=>oi(d,t));l.paragraphs.every(d=>d.text.trim()==="")||n.push(`${c.join(`
|
|
2
|
+
`)}${i?`
|
|
3
|
+
${i}`:""}`);}return n.sort().join(`
|
|
4
|
+
|
|
5
|
+
`)}function oi(e,t){if(t==="text")return e.text.replace(/\s+/g," ").trim();let n=e.paragraphProperties.filter(r=>r!=="rPr");return `${e.text}${n.join("|")}`}var si=new Set(["ins","del","moveFrom","moveTo","rPrChange","pPrChange","sectPrChange","tblPrChange","tblPrExChange","trPrChange","tcPrChange","tblGridChange","numberingChange","cellIns","cellDel","cellMerge"]),ii="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ee(e){return S(e)?e.namespaceUri===ii&&si.has(e.localName)?true:e.children.some(t=>S(t)&&ee(t)):false}var ai=new Set(["locked","bound"]),br="undecided";function Rr(e,t,n){let r=[];for(let o of $t(e)){if(!ee(o.root)){r.push(o);continue}r.push(Cr(o,t,n));}return r}function Cr(e,t,n){let r=applyTreeOp(e,{op:t});r.ok?ee(r.part.root)&&n.add(br):n.add(ai.has(r.reason)?r.reason:br);let o=r.ok?r.part:e,s=readOoxmlPart(serializeOoxmlPart(o),{name:o.name,contentType:o.contentType});return s.ok?s.part:o}var li=new TextEncoder;function Xe(e,t,n,r=new Set){let o=e;if(t){let l=new Map(e.parts);n?.name!==e.mainDocumentPart&&(n=void 0),n&&l.set(e.mainDocumentPart,n);let a=new Set;for(let c of resolveHeaderFooterResolutionBySection(e))for(let d of [c.headers,c.footers])for(let u of d.values())a.add(u.part.name);n||a.add(e.mainDocumentPart);for(let c of a){let d=l.get(c);!d||!ee(d.root)||l.set(c,Cr(d,t,r));}o={...e,parts:l};}let s=new Map,i=l=>{let a=s.get(l);if(a===void 0){let c=we([l],"text");a=c===""?"":sha256Bytes(li.encode(c)),s.set(l,a);}return a};return resolveHeaderFooterResolutionBySection(o).map(l=>{let a=[];for(let[c,d]of [["header",l.headers],["footer",l.footers]])for(let[u,f]of d){let p=i(f.part);p!==""&&a.push(`${c}:${u}=${p}`);}return a.sort().join("|")}).join(`
|
|
6
|
+
`)}function $r(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;return `${JSON.stringify(e.slice(Math.max(0,n-40),n+80))} vs ${JSON.stringify(t.slice(Math.max(0,n-40),n+80))}`}function Tr(e,t,n){let r=new Set,o=Rr(e,"acceptAllRevisions",r),s=Rr(e,"rejectAllRevisions",r),i=f=>{let p=we(o,f),m=we(s,f),x=we($t(n),f),h=we($t(t),f);return {accept:p===x,reject:m===h,detail:p!==x?`accept: ${$r(p,x)}`:m!==h?`reject: ${$r(m,h)}`:void 0}},l=()=>{let f=Xe(e,"acceptAllRevisions",o[0],r)===Xe(n),p=Xe(e,"rejectAllRevisions",s[0],r)===Xe(t),m=f?p?void 0:"reject":"accept";return {accept:f,reject:p,detail:m&&`${m}: a section shows other headers or footers`}},a=i("text"),c=a.accept&&a.reject?l():a,d=c.accept&&c.reject?i("properties"):c,u=c.detail??d.detail;return {accept:c.accept,reject:c.reject,properties:d.accept&&d.reject,...r.size>0?{guard:[...r].sort().join(",")}:{},...u===void 0?{}:{detail:u}}}var pi=1e5,mi=3e6,gi=new Set(["document","hdr","ftr","footnotes","endnotes","comments","numbering","styles"]);function Cl(e,t,n={}){let r=readOoxmlPackage(e);if(!r.ok)return {ok:false,code:"invalidOriginal",message:`The original document cannot be read (${r.reason}).`};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,code:"invalidRevised",message:`The revised document cannot be read (${o.reason}).`};let s=ki(r.package,o.package,n);return s.ok?{ok:true,bytes:s.changed?s.bytes:e,revisionCount:s.revisionCount,changed:s.changed}:s}var hi=.1,yi=.7;function ki(e,t,n={},r=false,o){let s=Ni(n);if(s)return {ok:false,code:"invalidOptions",message:s};try{return xi(e,t,n,r,o)}catch(i){if(i instanceof RangeError)return Fr;throw i}}var Fr={ok:false,code:"tooLarge",message:"The documents are too large to compare."};function xi(e,t,n,r,o){let s={...n,date:n.date??new Date},i=Mr(e,t,s,r,o);if(!i.ok||i.revisionCount>0)return i;if(![...e.parts.values()].some(l=>ee(l.root))){let l=Mr(e,e,s,true);if(l.ok&&Oi(i.package,l.package))return {...i,package:e,changed:false}}return i}function Mr(e,t,n,r,o){if(Ci(e))return {ok:false,code:"protected",message:"The original document is protected against edits. A compare writes some differences, such as style definitions or content control properties, without tracked changes."};let s=_r(e),i=_r(t);if(s.blocks+i.blocks>pi||s.text+i.text>mi)return Fr;o?.("comparing",hi);let l=Dr(e),a=Dr(t);if(!l)return Ar("original");if(!a)return Ar("revised");let c=l.parts.get(l.mainDocumentPart),d=a.parts.get(a.mainDocumentPart),u=c&&$(c.root,"body"),f=d&&$(d.root,"body");if(!c||!u)return {ok:false,code:"invalidOriginal",message:"The original document has no main story."};if(!d||!f)return {ok:false,code:"invalidRevised",message:"The revised document has no main story."};let p=Sn(l,a),m=new je;for(let[T,v]of pr(l,a))m.furnitureIds.set(T,v);m.sectionReferences=ur(l,a),collectSectionPropertyNodes(c.root).forEach((T,v)=>{T&&m.baseSectionIndex.set(T,v);});let x=new H,h=new L("base",l,l.mainDocumentPart,x),y=new L("revised",a,a.mainDocumentPart,x),g=new Ke(m,n.authorName?.trim()?n.authorName:Fi(a),n.removeDateAndTime?void 0:_i(n.date??new Date),n.detectFormatChanges??true,h,y),k=$(u,"sectPr"),w=$(f,"sectPr"),P=bi(x,u),R=g,E={outputs:[],extraRefs:"",unpaired:false},A=de(x,c.root,()=>{let T=B(F(u,h),F(f,y),g);E=gr(l,a,R);let v=ze(k??null,w??null,g,E.extraRefs,true);return `${P.start}${T}${v}${P.end}`}),N=[{partName:c.name,contentType:c.contentType,xml:A,isNew:false},...E.outputs,...p];for(let T of ["footnote","endnote"]){let v=yr(l,a,T,g);v.output&&N.push(v.output),Ri(N,T,v.ids);}if(g.state.untracked>0)return {ok:false,code:"unsupportedContent",reason:"untrackedContent",message:"The documents differ in block content that has no tracked-change form, such as an embedded file chunk."};if(E.unpaired)return {ok:false,code:"unsupportedContent",reason:"headerFooter",message:"A header or footer of an earlier section differs, and that section has no matching section in the other document that uses the same headers and footers."};if(g.state.unrecordedProperties>0)return {ok:false,code:"unsupportedContent",reason:"unrecordedSettings",message:"The revised document adds section or table settings, such as page borders, that a tracked change cannot restore on reject."};o?.("checking",yi);let C=ar(l,a,wr(l,a,N));if(!C.ok)return {ok:false,code:"unsupportedContent",reason:"packageStructure",message:C.message};let I=Tr(C.pkg,l,a),U=/\b(?:locked|bound)\b/.test(I.guard??"");return !r&&U?{ok:false,code:"unsupportedContent",reason:"lockedContent",message:"The documents differ inside a content control that is locked or bound to data. Changes there cannot be accepted or rejected."}:!r&&(!I.accept||!I.reject||I.guard)?{ok:false,code:"unsupportedContent",reason:"unverified",message:`The compare result does not reproduce both documents (${I.detail??I.guard??""}).`}:{ok:true,bytes:C.bytes,package:C.pkg,revisionCount:g.revisionCount===0?0:Pi(C.pkg),changed:true}}var wi=new Set(["document","hdr","ftr","footnotes","endnotes"]);function Pi(e){let t=0;for(let n of e.parts.values()){let r=n.root;(wi.has(r.localName)&&r.namespaceUri===Pe||n.name===e.mainDocumentPart)&&(t+=revisionItemsOf(n).length);}return t}function Ni(e){let{authorName:t,detectFormatChanges:n,removeDateAndTime:r,date:o}=e;return t!==void 0&&typeof t!="string"?"authorName must be a string.":n!==void 0&&typeof n!="boolean"?"detectFormatChanges must be a boolean.":r!==void 0&&typeof r!="boolean"?"removeDateAndTime must be a boolean.":o!==void 0&&(Object.prototype.toString.call(o)!=="[object Date]"||Number.isNaN(o.getTime()))?"date must be a valid Date.":null}function Oi(e,t){if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||e.partBytes.size!==t.partBytes.size)return false;for(let[n,r]of e.parts){let o=t.parts.get(n);if(!o||o.contentType!==r.contentType||!ooxmlTreesEqual(r,o))return false}for(let[n,r]of e.partBytes){if(e.parts.has(n)||n.endsWith(".rels")||n==="/[Content_Types].xml")continue;let o=t.partBytes.get(n);if(!o||!Ei(r,o))return false}return Ir(e)===Ir(t)&&JSON.stringify(e.externalTargets)===JSON.stringify(t.externalTargets)}function Ei(e,t){if(e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}function Ir(e){return JSON.stringify([...e.relationships.entries()].filter(([,t])=>t.length>0).sort(([t],[n])=>t<n?-1:t>n?1:0).map(([t,n])=>[t,n.map(r=>[r.id,r.type,r.rawTarget,r.targetMode])]))}function bi(e,t){let n=e.serialize({...t,children:[]}),r=/^<([^\s/>]+)([^>]*?)\/?>/.exec(n);return {start:`<${r[1]}${r[2]}>`,end:`</${r[1]}>`}}function Ri(e,t,n){for(let r=0;r<e.length;r++){let o=e[r].xml.replace(Xn,(s,i,l)=>i===t?n.get(K(l))??_(K(l)):s);e[r]={...e[r],xml:o};}}var $i=new Set(["0","false","off"]),Si=new Set(["readOnly","comments","forms","trackedChanges"]);function Ci(e){let t=Ti(e);return t!==void 0&&Si.has(t)}function Ti(e){let t=vi(e),n=t&&O(t.root).find(o=>o.localName==="documentProtection"&&o.namespaceUri===Pe);if(!n)return;let r=b(n,"enforcement",Pe);if(!(r===void 0||$i.has(r)))return b(n,"edit",Pe)??""}var Pe="http://schemas.openxmlformats.org/wordprocessingml/2006/main",vi=e=>Y(e,"settings");function Ar(e){return {ok:false,code:"unsupportedContent",reason:"unresolvedRevisions",message:`The ${e} document holds tracked changes that cannot be accepted, so its final state is unknown.`}}function Dr(e){let t=null;for(let[n,r]of e.parts){if(!ee(r.root))continue;let o=applyTreeOp(r,{op:"acceptAllRevisions"});if(!o.ok){if(o.reason==="unknown-revision")continue;return null}t??=new Map(e.parts),t.set(n,o.part);}return t?{...e,parts:t}:e}var Mi=new Set(["p","tbl","tr","tc","sdt","num","abstractNum","style"]),Ii=12,Ai=new Set(["tab","ptab","br","cr","sym","noBreakHyphen","softHyphen","fldChar","drawing","pict","object","footnoteReference","endnoteReference","commentReference"]);function _r(e){let t={blocks:0,text:0};for(let n of e.parts.values()){let r=n.root;(gi.has(r.localName)&&r.namespaceUri===Pe||n.name===e.mainDocumentPart)&&Di(r,t);}return t}function Di(e,t){let n=[...e.children];for(;n.length>0;){let r=n.pop();if(r.kind==="textValue"){t.text+=r.value.length;continue}Mi.has(r.localName)?t.blocks++:Ai.has(r.localName)?t.text++:r.localName==="r"&&(t.text+=Ii),M(n,r.children);}}function _i(e){return `${e.toISOString().slice(0,16)}:00Z`}function Fi(e){for(let t of e.parts.values())if(t.contentType.endsWith("core-properties+xml"))for(let n of ["lastModifiedBy","creator"]){let o=O(t.root).find(s=>s.localName===n)?.children.map(s=>S(s)?"":s.value).join("").trim();if(o)return o}return "Comparison"}var Ui="docx-editor.compare/1",Bi={reading:true,comparing:true,checking:true,applying:true},Li={invalidOptions:true,invalidOriginal:true,invalidRevised:true,tooLarge:true,protected:true,unsupportedContent:true},vt=e=>typeof e=="object"&&e!==null,Ur=(e,t)=>typeof t=="string"&&Object.hasOwn(e,t),Tt=e=>Object.prototype.toString.call(e)==="[object Uint8Array]",vl=e=>vt(e)&&e.protocol===Ui;function Ml(e){let t=e;return t.type==="compare"&&Tt(t.original)&&Tt(t.revised)&&vt(t.options)}function Wi(e){if(!vt(e)||typeof e.ok!="boolean")return false;if(!e.ok)return Ur(Li,e.code);let t=e.revisionCount;return typeof e.changed=="boolean"&&(e.changed?Tt(e.bytes):e.bytes===null)&&typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function Il(e){let t=e;switch(t.type){case "progress":{let n=t.fraction;return Ur(Bi,t.phase)&&typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=1}case "result":return Wi(t.result);case "error":return typeof t.message=="string";default:return false}}
|
|
7
|
+
export{Cl as a,ki as b,Ui as c,vl as d,Ml as e,Il as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkVJOGWUUQ_cjs=require('./chunk-VJOGWUUQ.cjs'),chunkZZ33FL6V_cjs=require('./chunk-ZZ33FL6V.cjs'),chunkIULA3QRZ_cjs=require('./chunk-IULA3QRZ.cjs'),store=require('@docx-editor.dev/core/store'),editor=require('@docx-editor.dev/core/editor'),i18n=require('@docx-editor.dev/i18n'),layout=require('@docx-editor.dev/core/layout');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var pt=64,we=new Set(["__proto__","constructor","prototype"]);function A(e,o,t){let n=new URLSearchParams;for(let[i,s]of Object.entries(t))n.set(i,s);let r=n.toString(),a=r.length>0?`${e}:${o}?${r}`:`${e}:${o}`;return a.length>64?{ok:false,reason:"tag-overflow",length:a.length}:{ok:true,tag:a}}function M(e){if(e.length>64)return null;let o=e.indexOf(":");if(o<=0)return null;let t=e.slice(0,o),n=e.slice(o+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let i=Object.create(null);if(r!==-1)for(let[s,d]of new URLSearchParams(n.slice(r+1))){if(we.has(s))return null;i[s]=d;}return {prefix:t,name:a,attrs:i}}var gt=262144;function L(e,o){if(o.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(o.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(o.length)} characters; the cap is ${String(262144)}`]};let t;try{t=JSON.parse(o);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=z(t);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return Oe(r)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:r.issues?{ok:false,reason:"invalid",issues:r.issues.map(Ee)}:{ok:true,value:r.value}}function K(e){let o;try{o=JSON.stringify(e)??"";}catch(t){return {ok:false,reason:"malformed",issues:[t instanceof Error?t.message:"the value cannot be serialized"]}}return o.length===0?{ok:false,reason:"malformed",issues:["the value serializes to nothing"]}:o.length>262144?{ok:false,reason:"malformed",issues:[`the payload is ${String(o.length)} characters; the cap is ${String(262144)}`]}:{ok:true,value:o}}function Oe(e){return typeof e.then=="function"}function Ee(e){let o=(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".");return o.length>0?`${o}: ${e.message}`:e.message}var Re=new Set(["__proto__","constructor","prototype"]);function z(e){if(Array.isArray(e))return e.map(z);if(e===null||typeof e!="object")return e;let o=Object.create(null);for(let[t,n]of Object.entries(e))Re.has(t)||(o[t]=z(n));return o}function re(e){let o=(e.path??[]).map(t=>{let n=typeof t=="object"?t.key:t;return typeof n=="number"?n:String(n)});return {message:e.message,path:o,pointer:o.join(".")}}function $(e,o){return {ok:false,code:"invalidArgs",reason:e,issues:o}}var ae="docxEditor";function _(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function se(e,o,t){let n=0;for(let r of store.customNodePayloadsOf(e,o,t).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let i=Number(a[1]);i>n&&(n=i);}return `cx${String(n+1)}`}function ie(e,o){let t=K(o);if(!t.ok)return {ok:false,reason:`the payload cannot be serialized: ${t.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:t.value,value:o};let r=e.schema["~standard"].validate(JSON.parse(t.value));if(Ie(r))return {ok:false,reason:`${e.name}'s schema validates asynchronously, which a write cannot await`,issues:[]};if(r.issues){let i=r.issues.map(re);return {ok:false,reason:`the payload does not match ${e.name}'s schema: `+i.map(s=>(s.pointer?`${s.pointer}: `:"")+s.message).join(", "),issues:i}}let a=K(r.value);return a.ok?{ok:true,data:a.value,value:r.value}:{ok:false,reason:`the payload cannot be serialized: ${a.issues.join(", ")}`,issues:[]}}function Ie(e){return typeof e.then=="function"}function ce(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var de=/^[A-Za-z0-9_.-]+$/,Te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function Ae(e){return e.length>0&&!Te.test(e)}function Et(e){if(!de.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!de.test(e.tagPrefix??""))throw new Error(`defineCustomNode: invalid tagPrefix ${JSON.stringify(e.tagPrefix)}`);let o=e.schema;if(o!==void 0&&typeof o?.["~standard"]?.validate!="function")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a schema that does not implement Standard Schema`);if(e.payloadNamespace!==void 0&&!Ae(e.payloadNamespace))throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a payloadNamespace that cannot be written into an XPath \u2014 no quotes, angle brackets, ampersands or control characters: ${JSON.stringify(e.payloadNamespace)}`);if(e.preserveOnExport!==void 0&&e.preserveOnExport!==true&&e.preserveOnExport!==false&&e.preserveOnExport!=="text")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has an unknown preserveOnExport ${JSON.stringify(e.preserveOnExport)}`);return Object.freeze({...e,dataOf:n=>{if(!n||n.data===void 0||n.name!==void 0&&n.name!==e.name)return;if(!e.schema)return n.data;let r=e.schema["~standard"].validate(n.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function Rt(e){chunkIULA3QRZ_cjs.a(e.licenseKey);let o=new Set;for(let t of e.nodes){let n=`${t.tagPrefix}:${t.name}`;if(o.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);o.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:t=>{e.onDiagnostic?.(t);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(_))]}}function Me(e){for(let o of e.children)if(!(o.kind==="textValue"||o.localName!=="sdtPr")){for(let t of o.children)if(!(t.kind==="textValue"||t.localName!=="tag")){for(let n of t.attributes)if(n.localName==="val")return n.value}}}function le(e){if(e.kind==="textValue")return e.value;let o="";for(let t of e.children)o+=le(t);return o}function ue(e,o,t={}){if(o.length===0)return [];let n=new Map;for(let i of o){let s=`${i.tagPrefix}:${i.name}`;if(n.has(s))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(s)}`);n.set(s,i);}let r=[],a=(i,s)=>{if(!(i.kind==="textValue"||s>64)){if(i.kind==="contentControl"){let d=Me(i),c=d!==void 0?M(d):null,m=c?n.get(`${c.prefix}:${c.name}`):void 0;if(c&&m&&d!==void 0){let g=le(i),x=Le(m,i.id,t.payloads?.get(i.id),store.contentControlPropertiesOf(i).dataBinding!==void 0,t.onDiagnostic),N=m.fromDocx?m.fromDocx({attrs:c.attrs,text:g,...x.present?{data:x.value}:{}}):c.attrs;if(N!==null){r.push({name:m.name,attrs:N,text:g,nodeId:i.id,tag:d,...x.present?{data:x.value}:{}});return}}}for(let d of i.children)a(d,s+1);}};return a(e.root,0),r}function Le(e,o,t,n,r){if(!t)return n&&r?.({code:"payload-missing",name:e.name,nodeId:o,issues:["the control binds a store node this document does not hold"]}),{present:false};let a=L(e.schema,t.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:o,issues:a.issues}),{present:false})}var me=(e,o,t)=>{let n=store.readOoxmlPackage(o);if(!n.ok)return {ok:false,code:"invalidRevised",message:`The revised document cannot be read (${n.reason}).`};let r=chunkVJOGWUUQ_cjs.b(e,n.package,t);return r.ok?{ok:true,package:r.package,revisionCount:r.revisionCount,changed:r.changed}:r};function pe(e,o){let t=e.createElement("div");t.className="docx-revision-color-picker";let n=e.createElement("span");n.textContent=o.label,n.id=`${o.id}-label`;let r=e.createElement("button");r.type="button",r.className="docx-revision-color-trigger",r.setAttribute("aria-labelledby",`${n.id} ${o.id}-value`),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",`${o.id}-options`);let a=e.createElement("span");a.className="docx-revision-color-swatch",a.setAttribute("aria-hidden","true");let i=e.createElement("span");i.id=`${o.id}-value`,r.append(a,i);let s=e.createElement("div");s.id=`${o.id}-options`,s.className="docx-revision-color-options",s.hidden=true,s.setAttribute("role","group"),s.setAttribute("aria-labelledby",n.id);let d=new Map,c=u=>u==="auto"?"currentColor":u==="byAuthor"?"var(--doc-review-author-0)":u==="none"?"transparent":`var(--doc-revision-color-${u})`,m,g=()=>{m?.(),m=void 0,e.removeEventListener("pointerdown",x,true),s.hidden=true,r.setAttribute("aria-expanded","false");},x=u=>{t.contains(u.target)||g();};t.addEventListener("focusout",u=>{t.contains(u.relatedTarget)||g();});let N=e.createElement("div");N.className="docx-revision-color-special";let C=e.createElement("div");C.className="docx-toolbar__swatch-grid",s.append(N,C);for(let u of o.colors){let p=e.createElement("button");if(p.type="button",p.dataset.value=u,p.setAttribute("aria-label",o.translate(u)),p.title=o.translate(u),["auto","none","byAuthor"].includes(u)){p.className="docx-toolbar__swatch-clear";let f=e.createElement("span");f.className="docx-revision-color-swatch",f.style.backgroundColor=c(u),f.setAttribute("aria-hidden","true"),p.append(f,e.createTextNode(o.translate(u))),N.append(p);}else p.className="docx-toolbar__swatch",p.dataset.light="",p.style.backgroundColor=c(u),C.append(p);p.addEventListener("mousedown",f=>f.preventDefault()),p.addEventListener("click",()=>{o.change(u),g(),r.focus();}),d.set(u,p);}return r.addEventListener("click",()=>{let u=s.hidden;if(s.hidden=!u,r.setAttribute("aria-expanded",String(u)),!u){g();return}m=editor.observeContentControlPopup(s,r),e.addEventListener("pointerdown",x,true),(Array.from(d.values()).find(p=>p.hasAttribute("data-selected"))??d.values().next().value)?.focus();}),s.addEventListener("keydown",u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),g(),r.focus());let p=Array.from(s.querySelectorAll("button")),f=p.indexOf(u.target),l=u.key==="Home"?0:u.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(u.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(u.key)?(f-1+p.length)%p.length:null;l!==null&&(u.preventDefault(),u.stopPropagation(),p[l]?.focus());}),t.append(n,r,s),{element:t,destroy:g,update(u,p){i.textContent=o.translate(u),a.style.backgroundColor=c(u),r.disabled=p;for(let[f,l]of d)l.setAttribute("aria-pressed",String(f===u)),l.toggleAttribute("data-selected",f===u),l.disabled=p;p&&g();}}}var W=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],fe=[...W,"hidden","caret","pound"],B=0;function ge(e){let o=e.container.ownerDocument,t=null,n=e.get(),r=null,a=new Map,i=new Map,s=i18n.createT(i18n.en),d=f=>e.translate?.(`revisionMarkup.${f}`)??s(`revisionMarkup.${f}`),c=(f,l)=>{let y=o.createElement(f);return l!==void 0&&(y.textContent=l),y},m=()=>{t?.close(),t?.remove(),t=null,a.clear();for(let f of i.values())f.destroy();i.clear(),r?.isConnected&&r.focus({preventScroll:true}),r=null;},g=()=>{for(let[f,l]of a){let[y,v]=f.split("."),h=n[y];l.tagName==="INPUT"?l.checked=h:l.value=h[v],l.disabled=(y==="movedFrom"||y==="movedTo")&&!n.trackMoves;}for(let[f,l]of i){let[y,v]=f.split("."),h=n[y];l.update(h[v],(y==="movedFrom"||y==="movedTo")&&!n.trackMoves);}},x=f=>{e.set(f);},N=e.subscribe(()=>{n=e.get(),g();}),C=(f,l,y,v,h)=>{if(y==="color"||y==="background"||l==="cells"){let O=d(l==="cells"?`${y}Cells`:`${l}${y==="background"?"Background":"Color"}`),w=pe(o,{id:`docx-revision-color-${B++}`,label:O,colors:v,translate:E=>d(`values.${E}`),change:E=>x({[l]:{[y]:E}})});return i.set(`${l}.${y}`,w),f.append(w.element),w.element}let k=c("label"),I=c("span",d(l));I.className="docx-revision-markup-field-label",k.append(I);let b=c("select");for(let O of v){let w=c("option",d(`values.${O}`));w.value=O,b.append(w);}return b.value=h,b.addEventListener("change",()=>x({[l]:{[y]:b.value}})),k.append(b),f.append(k),a.set(`${l}.${y}`,b),k},u=(f,l,y)=>{let v=c("div");v.className="docx-revision-markup-row";let h=c("span",d(l));if(h.className="docx-revision-markup-row-title",h.setAttribute("aria-hidden","true"),v.append(h),C(v,l,"mark",y,n[l].mark),C(v,l,"color",["byAuthor","auto",...editor.REVISION_MARKUP_COLORS],n[l].color),f.append(v),l!=="changedLines"){let k=c("div");k.className="docx-revision-markup-background",C(k,l,"background",["none","byAuthor",...editor.REVISION_MARKUP_COLORS],n[l].background),f.append(k);}},p=(f,l)=>{let y=c("label"),v=c("input");v.type="checkbox",v.checked=n[l],v.addEventListener("change",()=>x({[l]:v.checked}));let h=c("p",d(`${l}Note`));h.id=`docx-revision-markup-note-${B++}`,v.setAttribute("aria-describedby",h.id),y.append(v,o.createTextNode(d(l))),f.append(y,h),a.set(l,v);};return {open(){if(e.signal.aborted)return;if(t){t.focus();return}n=e.get(),r=o.activeElement,t=c("dialog"),t.className="docx-revision-markup-dialog",t.contentEditable="false",t.setAttribute("data-docx-marker","");for(let w of ["keydown","mousedown","beforeinput"])t.addEventListener(w,E=>E.stopPropagation());let f=c("h2",d("title"));f.id=`docx-revision-markup-title-${B++}`,t.setAttribute("aria-labelledby",f.id),t.append(f),t.addEventListener("cancel",w=>{w.preventDefault(),e.cancel();});let l=c("div");l.className="docx-revision-markup-body",t.append(l);let y=w=>{let E=c("fieldset");return E.className=`docx-revision-markup-${w}`,E.append(c("legend",d(w))),l.append(E),E},v=y("markup");u(v,"insertions",W),u(v,"deletions",fe),u(v,"changedLines",["none","leftBorder","rightBorder","outsideBorder"]);let h=y("moves");p(h,"trackMoves"),u(h,"movedFrom",fe),u(h,"movedTo",W);let k=y("tableCells");for(let w of ["inserted","deleted","merged","split"])C(k,"cells",w,["byAuthor","none",...editor.REVISION_MARKUP_COLORS],n.cells[w]);let I=y("formatting");p(I,"trackFormatting"),u(I,"formatting",W);let b=c("div");b.className="docx-revision-markup-actions";let O=(w,E)=>{let R=c("button",d(w));R.type="button",R.addEventListener("click",E),b.append(R);};O("reset",()=>e.reset()),O("cancel",()=>e.cancel()),O("ok",()=>{e.apply();}),t.append(b),e.container.append(t),g(),t.showModal(),t.querySelector("select")?.focus({preventScroll:true});},destroy(){N(),m();}}}var Ke=0;function ye(e){let o=e.container.ownerDocument,t=null,n=null,r=i18n.createT(i18n.en),a=c=>e.translate?.(c)??r(c),i=(c,m)=>{let g=a(`compareDocuments.${c}`);return m?g.replace(/\{(\w+)\}/g,(x,N)=>m[N]??x):g},s=(c,m)=>{let g=o.createElement(c);return m!==void 0&&(g.textContent=m),g},d=()=>{t?.close(),t?.remove(),t=null,n?.isConnected&&n.focus({preventScroll:true}),n=null;};return {open(){if(e.signal.aborted)return;if(t){t.focus();return}n=o.activeElement;let c=Ke++,m=false;t=s("dialog"),t.className="docx-compare-documents-dialog",t.contentEditable="false",t.setAttribute("data-docx-marker",""),t.tabIndex=-1;for(let S of ["keydown","mousedown","beforeinput"])t.addEventListener(S,P=>P.stopPropagation());t.addEventListener("cancel",S=>{S.preventDefault(),(!m||e.cancelable)&&e.cancel();});let g=s("h2",i("title"));g.id=`docx-compare-documents-title-${c}`,t.setAttribute("aria-labelledby",g.id);let x=s("p",i("description"));x.id=`docx-compare-documents-description-${c}`,t.setAttribute("aria-describedby",x.id);let N=s("p",i("trackedChangesAccepted"));N.id=`docx-compare-documents-tracked-${c}`,N.className="docx-compare-documents-tracked",e.originalHasTrackedChanges&&t.setAttribute("aria-describedby",`${x.id} ${N.id}`);let C=s("div");C.className="docx-compare-documents-body";let u=s("label"),p=s("input");p.type="file",p.accept=editor.COMPARE_DOCUMENTS_ACCEPT,u.append(s("span",i("revisedFile")),p);let f=s("label"),l=s("input");l.type="text",l.value=e.defaultAuthor,l.autocomplete="off",f.append(s("span",i("author")),l);let y=s("label");y.className="docx-compare-documents-check";let v=s("input");v.type="checkbox",v.checked=true,y.append(v,o.createTextNode(i("detectFormatting"))),C.append(u,f,y);let h=s("p");h.className="docx-compare-documents-error",h.setAttribute("role","alert");let k=s("p");k.className="docx-compare-documents-notice",k.setAttribute("role","status");let I=()=>{h.textContent="",k.textContent="",R.textContent=i("cancel");},b=s("progress");b.className="docx-compare-documents-progress",b.max=1,b.hidden=true,b.setAttribute("aria-label",i("comparing"));let O=s("span");O.className="docx-compare-documents-phase",O.tabIndex=-1,O.hidden=true;let w=S=>{O.textContent=S,b.setAttribute("aria-valuetext",S);},E=s("div");E.className="docx-compare-documents-actions";let R=s("button",i("cancel"));R.type="button",R.addEventListener("click",()=>e.cancel());let D=s("button",i("compare"));D.type="button",E.append(R,D);let T=S=>{m=S;for(let P of [p,l,v])P.disabled=S;R.disabled=S&&!e.cancelable,b.hidden=!S,O.hidden=!S,S?w(i("comparing")):(b.removeAttribute("value"),b.removeAttribute("aria-valuetext"),O.textContent=""),D.disabled=S||!p.files?.length||!e.canApply(),D.textContent=i(S?"comparing":"compare"),b.setAttribute("aria-busy",String(S)),t?.toggleAttribute("data-docx-busy",S),S&&(R.disabled?O:R).focus({preventScroll:true});},q=S=>{let P=!S&&!D.disabled?D:p;(P.disabled?t??p:P).focus({preventScroll:true});};p.addEventListener("change",()=>{I(),T(false);}),D.addEventListener("click",async()=>{let S=p.files?.[0];if(!S){h.textContent=i("fileRequired");return}I(),T(true);let P;try{P=new Uint8Array(await S.arrayBuffer());}catch{e.signal.aborted||(h.textContent=i("readFailed"),T(false),q(true));return}if(e.signal.aborted)return;let U=await e.apply({revised:P,authorName:l.value,detectFormatChanges:v.checked},{onProgress:Y=>{b.value=Y.fraction,w(i(`phases.${Y.phase}`));}});e.signal.aborted||(U.ok?(k.textContent=i("noDifferences"),R.textContent=a("common.close")):h.textContent=a(editor.compareDocumentsErrorKey(U)),T(false),q(!U.ok));}),t.append(g,x),e.originalHasTrackedChanges&&t.append(N),t.append(C,b,O,h,k,E),e.container.append(t),T(false),t.showModal(),p.focus({preventScroll:true});},destroy(){d();}}}function ve(e,o){let t=store.findNode(e,o);return !t||t.kind!=="paragraph"?[]:store.revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:t})}function qe(e,o,t,n){if(o.length===0)return [];let r=ue(e,o,{...t===void 0?{}:{payloads:t},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=store.locateSites(e),i=[];for(let s of r){let d=o.find(g=>g.name===s.name&&s.tag.startsWith(`${g.tagPrefix}:`));if(!d)continue;let c=d.reviewCard?d.reviewCard({attrs:s.attrs,text:s.text,...s.data===void 0?{}:{data:s.data}}):null;if(d.reviewCard&&c===null)continue;let m=a.get(s.nodeId);i.push({kind:"custom",id:s.nodeId,name:s.name,tag:s.tag,attrs:s.attrs,text:s.text,...s.data===void 0?{}:{data:s.data},carded:d.reviewCard!==void 0&&c!==null,title:c?.title??"",...c?.detail!==void 0?{detail:c.detail}:{},...c?.icon!==void 0?{icon:c.icon}:{},range:m?{partName:e.name,start:{paragraphId:m.paragraphId,offset:m.start},end:{paragraphId:m.paragraphId,offset:m.end}}:null});}return i}function ke(e){let o=store.collectReviewItems(e),t=(e.customNodes??[]).filter(ce);if(t.length===0)return o;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let d of e.furnitureParts??[])r.has(d.name)||(r.add(d.name),n.push(d));let a=[],i=new Map;for(let d of n){a.push(...qe(d,t,e.customNodePayloads,e.reportCustomNodeDiagnostic));let c=i.size;for(let[m,g]of store.paragraphOrderOfPart(d))i.has(m)||i.set(m,c+g);}return a.length===0?o:[...o,...a].sort((d,c)=>layout.reviewItemPositionRank(d,i)-layout.reviewItemPositionRank(c,i))}var Ye=3e4;function xe(e,o=Ye){return (t,n,r,{signal:a,onProgress:i})=>new Promise((s,d)=>{a.throwIfAborted();let c=e(),m=false,g,x=()=>{g!==void 0&&globalThis.clearTimeout(g),g=void 0;},N=()=>m?false:(m=true,x(),a.removeEventListener("abort",u),c.removeEventListener?.("message",p),c.removeEventListener?.("messageerror",f),c.removeEventListener?.("error",l),c.terminate(),true),C=(h,k)=>{N()&&d(new Error(h,k===void 0?void 0:{cause:k}));},u=()=>{N()&&d(a.reason);},p=h=>{let k=h.data;if(!(m||!chunkVJOGWUUQ_cjs.d(k))){if(!chunkVJOGWUUQ_cjs.f(k)){C("The compare worker sent a malformed message.");return}if(x(),k.type==="progress"){i({phase:k.phase,fraction:k.fraction});return}N()&&(k.type==="result"?s(k.result):d(new Error(`The compare worker failed: ${k.message}`)));}},f=()=>C("The compare worker sent a message that cannot be read."),l=h=>{let k=h.message;C(`The compare worker failed to run${k?`: ${k}`:""}.`);};a.addEventListener("abort",u,{once:true}),c.addEventListener("message",p),c.addEventListener("messageerror",f),c.addEventListener("error",l),g=globalThis.setTimeout(()=>C(`The compare worker did not start within ${Math.round(o/1e3)} seconds.`),o);let y=t.slice(),v=n.slice();try{c.postMessage({protocol:chunkVJOGWUUQ_cjs.c,type:"compare",original:y,revised:v,options:{...r}},[y.buffer,v.buffer]);}catch(h){C("The compare worker could not receive the documents.",h);}})}function Ne(){if(typeof Worker>"u")throw new Error("Web workers are not available here.");return new Worker(new URL("./compare-worker.js",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-OYR3V4F4.cjs', document.baseURI).href))),{type:"module"})}function go(e={}){let o=e.pane===void 0?void 0:{...editor.resolveReviewPane(e.pane)};chunkZZ33FL6V_cjs.a(e);let t=e.compareWorker;if(t!==void 0&&t!==false&&typeof t!="function")throw new TypeError("reviewModule: compareWorker must be false or a function that returns a Worker");let n=t===false?void 0:xe(t??Ne);return {id:"review",review:{compareDocuments:me,...n?{compareDocumentsInBackground:n}:{},createCompareDocumentsDialog:ye,createRevisionMarkupDialog:ge,displayModes:["all-markup","simple-markup","proposed","original"],collectReviewItems:ke,revisionItemsOfParagraph:ve,...o?{pane:o}:{}}}}function Se(e){return e.surface??null}function G(e,o){if(o==null)return null;let t=ie(e,o);return t.ok?{ok:true,serialized:t.data,value:t.value}:{ok:false,reason:t.reason,issues:t.issues}}function J(e,o,t,n,r){let a=_(o),i=e.session.part().name;return {namespaceUri:a,rootLocalName:ae,nodeId:r??se(e.session.currentPackage(),i,a),label:n,data:t}}function H(e){let o=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:tt.has(e.reason)?"invalidArgs":"unsupported",reason:o}}var tt=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function X(e,o,t){let n,r;if(t!==void 0)try{n=e.text?.(t),r=e.tagAttrs?.(t);}catch(i){return {reason:`${e.name} could not describe this payload: ${i instanceof Error?i.message:String(i)}`}}let a=o.text??n;return a===void 0?{reason:e.text?`${e.name} derives its text from \`data\`, so pass one \u2014 or pass \`text\` directly`:`${e.name} declares no \`text\`, so \`text\` is required`}:o.attrs===void 0&&e.tagAttrs&&r===void 0?{reason:`${e.name} derives its tag attrs from \`data\`, so pass one \u2014 or pass \`attrs\` directly`}:{attrs:o.attrs??r??{},text:a}}function V(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function Ce(e){let o=e.getActiveScope();if(o.kind==="headerFooter")return {kind:"headerFooter",rId:o.rId};if(o.kind==="note"){let t=store.parseNoteScopeId(o.id);if(t)return {kind:"notesPart",noteKind:t.noteKind}}return {kind:"body"}}function F(e,o){let t=Se(e),n=o===void 0?-1:o.indexOf("#"),r=o===void 0?"":n===-1?t?.session.storyParts().find(a=>store.findNode(a,o)!==null)?.name??"":o.slice(0,n);if(!t||r.length===0)return Ce(e);if(r===t.session.part().name)return {kind:"body"};for(let a of t.session.headerFooterResolutionBySection())for(let i of [a.headers,a.footers])for(let s of i.values())if(s.partName===r)return {kind:"headerFooter",rId:s.rId};for(let a of ["footnote","endnote"])if(t.session.partFor({kind:"notesPart",noteKind:a})?.name===r)return {kind:"notesPart",noteKind:a};return Ce(e)}function ot(e){let o=e.author()?.trim();return e.editingMode()!=="suggest"||!o?null:{author:o,date:`${new Date().toISOString().slice(0,19)}Z`}}function No(e,o,t={}){let n=Se(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=G(o,t.data);if(r&&!r.ok)return $(r.reason,r.issues);let a=X(o,t,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let i=A(o.tagPrefix,o.name,a.attrs);if(!i.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${i.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let s=V(e);if(s)return s;n.flushPendingInput();let d=t.at??n.state().selection.head,c=t.lock===void 0?"contentLocked":t.lock,m=F(e,d.paragraphId),g=ot(n),x=n.session.insertCustomNode({paragraphId:d.paragraphId,offset:d.offset,tag:i.tag,text:a.text,...t.alias===void 0?{}:{alias:t.alias},...c===false?{}:{lock:c},...r?{payload:J(n,o,r.serialized,a.text)}:{},...g?{revision:g}:{}},m);return x.ok?{ok:true,changed:true,...x.nodeId===void 0?{}:{nodeId:x.nodeId}}:H(x)}function be(e){return e.surface??null}function dt(e,o){let t=null,n=a=>a.id===o?true:a.kind==="textValue"?false:a.children.some(n),r=(a,i)=>{if(!(t||a.kind==="textValue"||i>64)){if(a.kind==="paragraph"){n(a)&&(t=a);return}for(let s of a.children)r(s,i+1);}};return r(e.root,0),t}function ct(e,o){let t=new Set,n=d=>{if(t.add(d.id),d.kind!=="textValue")for(let c of d.children)n(c);},r=d=>{if(d.id===o)return d;if(d.kind==="textValue")return null;for(let c of d.children){let m=r(c);if(m)return m}return null},a=r(e);if(!a)return null;n(a);let i=Number.MAX_SAFE_INTEGER,s=-1;for(let d of store.segmentsOf(e))t.has(d.runId)&&(d.start<i&&(i=d.start),d.end>s&&(s=d.end));return s<0?null:{start:i,end:s}}function Po(e,o){let t=be(e);if(!t)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=V(e);if(n)return n;t.flushPendingInput();let r=t.session.removeCustomNode(o,F(e,o));return r.ok?{ok:true,changed:true}:H(r)}function Io(e,o,t,n={}){let r=be(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=V(e);if(a)return a;r.flushPendingInput();let i=F(e,t),s=r.session.partFor(i)??r.session.part(),d=dt(s,t),c=d?ct(d,t):null,m=lt(r,t,i);if(!d||!c||!m)return {ok:false,code:"notFound",reason:"no custom node with that id"};let g=`${o.tagPrefix}:${o.name}`;if(m.identity!==null&&m.identity!==g)return {ok:false,code:"invalidArgs",reason:`node ${t} is a ${m.identity}, not a ${g}`};let x=mt(r,t,i),N=n.data===null?null:n.data===void 0?ut(x):G(o,n.data);if(N&&!N.ok)return $(N.reason,N.issues);let C=X(o,{attrs:n.attrs??(n.data===void 0?m.attrs:void 0),text:n.text??(N===null&&n.data===null?m.text:void 0)},N?.value);if("reason"in C)return {ok:false,code:"invalidArgs",reason:C.reason};let u=A(o.tagPrefix,o.name,C.attrs);if(!u.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${u.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let p=n.alias??m.alias,f=n.lock??m.lock,l=r.session.insertCustomNode({replaceControlId:t,paragraphId:d.id,offset:c.start,tag:u.tag,text:C.text,...p===void 0?{}:{alias:p},...f===false||f===void 0?{}:{lock:f},...N?{payload:J(r,o,N.serialized,C.text,x?.nodeId)}:{}},i);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:H(l)}function lt(e,o,t){let n=e.session.partFor(t)??e.session.part(),r=store.contentControlsIn(n.root).find(d=>d.node.id===o);if(!r)return null;let a=store.contentControlPropertiesOf(r.node),i=a.tag===void 0?null:M(a.tag),s=a.lock;return {identity:i?`${i.prefix}:${i.name}`:null,attrs:i?.attrs??{},text:store.contentControlTextOf(r.node),alias:a.alias,lock:s==="sdtLocked"||s==="sdtContentLocked"||s==="contentLocked"?s:s==="unlocked"?false:void 0}}function ut(e){if(!e)return null;let o=L(void 0,e.data);return o.ok?{ok:true,serialized:e.data,value:o.value}:{ok:false,reason:`the stored payload is not readable: ${o.issues.join(", ")}`,issues:[]}}function mt(e,o,t){let n=e.session.partFor(t)??e.session.part();return store.customNodePayloadsByControl(e.session.currentPackage(),n.name,e.session.part().name).get(o)}exports.a=pt;exports.b=A;exports.c=M;exports.d=gt;exports.e=L;exports.f=K;exports.g=ae;exports.h=_;exports.i=ie;exports.j=ce;exports.k=de;exports.l=Et;exports.m=Rt;exports.n=ue;exports.o=go;exports.p=No;exports.q=Po;exports.r=Io;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';var store=require('@docx-editor.dev/core/store');function M(e,...t){for(let n of t)for(let r of n)e.push(r);return e}var Ne="http://schemas.openxmlformats.org/wordprocessingml/2006/main",Lr={pgSz:{w:"12240",h:"15840",orient:"portrait"},pgMar:{top:"1440",right:"1440",bottom:"1440",left:"1440",header:"720",footer:"720",gutter:"0"},cols:{num:"1",space:"720",equalWidth:"1",sep:"0"},vAlign:{val:"top"},type:{val:"nextPage"},textDirection:{val:"lrTb"},pgNumType:{fmt:"decimal",start:"0"},lnNumType:{countBy:"0",restart:"newPage"},docGrid:{type:"default"},paperSrc:{first:"0",other:"0"}},It=new Set(["titlePg","bidi","rtlGutter","formProt","noEndnote"]),At={pgSz:new Set(["code"]),docGrid:new Set(["linePitch","charSpace"])},Ye=e=>e.namespaceUri===Ne?e.localName:null;function _t(e,t,n){let r=new Map(e.filter(l=>l.namespaceUri===Ne).map(l=>[l.localName,l])),o=e.map(l=>({name:l.namespaceUri===Ne?l.localName:"",xml:n.serialize(l)})),s=(l,a)=>o.push({name:l,xml:a});for(let l of t){if(l.namespaceUri!==Ne)return null;let a=l.localName,c=Lr[a],d=r.get(a);if(!d){if(It.has(a)){s(a,`<w:${a} w:val="0"/>`);continue}if(l.attributes.length===0&&l.children.length===0)continue;if(!c||l.children.length>0)return null;let p=a==="docGrid"?' w:type="default"':"";for(let m of l.attributes){let x=Ye(m);if(x!==null&&At[a]?.has(x)||a==="docGrid"&&x==="type")continue;let h=x===null?void 0:c[x];if(h===void 0)return null;p+=` w:${x}="${h}"`;}s(a,`<w:${a}${p}/>`);continue}let u=new Set(d.attributes.map(p=>Ye(p))),f="";for(let p of l.attributes){let m=Ye(p);if(m!==null&&u.has(m))continue;if(It.has(a)&&m==="val"){f+=' w:val="1"';continue}if(m!==null&&At[a]?.has(m)&&!(a==="docGrid"&&u.has("type")))continue;let x=m===null||!c?void 0:c[m];if(x===void 0)return null;f+=` w:${m}="${x}"`;}if(f){let p=o.find(m=>m.name===a);p&&(p.xml=p.xml.replace(/^(<[^\s/>]+)/,`$1${f}`));}}let i=l=>{let a=Dt.indexOf(l);return a<0?Dt.length:a};return o.map((l,a)=>({...l,index:a})).sort((l,a)=>i(l.name)-i(a.name)||l.index-a.index).map(l=>l.xml).join("")}var Dt=["footnotePr","endnotePr","type","pgSz","pgMar","paperSrc","pgBorders","lnNumType","pgNumType","cols","formProt","vAlign","noEndnote","titlePg","textDirection","bidi","rtlGutter","docGrid","printerSettings"];var Ve=3e3;function fe(e,t,n=Ve){return Ft(e,t,n)??Ut(e,t)}function Ft(e,t,n=Ve){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r++;let o=e.length,s=t.length;for(;o>r&&s>r&&e[o-1]===t[s-1];)o--,s--;let i=Wr(e,t,r,o,r,s,n);if(!i)return null;let l=[];for(let a=0;a<r;a++)l.push({op:"eq",a,b:a});M(l,i);for(let a=0;o+a<e.length;a++)l.push({op:"eq",a:o+a,b:s+a});return l}function Wr(e,t,n,r,o,s,i){let l=r-n,a=s-o;if(l===0&&a===0)return [];if(l===0)return Array.from({length:a},(g,k)=>({op:"ins",b:o+k}));if(a===0)return Array.from({length:l},(g,k)=>({op:"del",a:n+k}));let c=l+a,d=c+1,u=new Int32Array(2*c+3),f=[],p=-1,m=Math.min(c,i);for(let g=0;g<=m;g++){f.push(u.slice(d-g,d+g+1));for(let k=-g;k<=g;k+=2){let w=k===-g||k!==g&&u[d+k-1]<u[d+k+1]?u[d+k+1]:u[d+k-1]+1,P=w-k;for(;w<l&&P<a&&e[n+w]===t[o+P];)w++,P++;if(u[d+k]=w,w>=l&&P>=a){p=g;break}}if(p>=0)break}if(p<0)return null;let x=[],h=l,y=a;for(let g=p;g>0;g--){let k=f[g],w=C=>k[C+g],P=h-y,R=P===-g||P!==g&&w(P-1)<w(P+1),E=R?P+1:P-1,A=w(E),N=A-E;for(;h>A&&y>N;)h--,y--,x.push({op:"eq",a:n+h,b:o+y});R?x.push({op:"ins",b:o+N}):x.push({op:"del",a:n+A}),h=A,y=N;}for(;h>0&&y>0;)h--,y--,x.push({op:"eq",a:n+h,b:o+y});return Oe(x.reverse())}function Oe(e){let t=[],n=[],r=[],o=()=>{M(t,r,n),n=[],r=[];};for(let s of e)s.op==="eq"?(o(),t.push(s)):s.op==="del"?n.push(s):r.push(s);return o(),t}function Ut(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,o=t.length;for(;r>n&&o>n&&e[r-1]===t[o-1];)r--,o--;let s=[];for(let i=0;i<n;i++)s.push({op:"eq",a:i,b:i});for(let i=n;i<r;i++)s.push({op:"del",a:i});for(let i=n;i<o;i++)s.push({op:"ins",b:i});for(let i=0;r+i<e.length;i++)s.push({op:"eq",a:r+i,b:o+i});return s}function Bt(e,t,n,r,o=Ve){let s=Ft(e,t,o);if(s)return s;let i=[],l=[];for(let u=0;u<e.length;u++)n(u)&&i.push(u);for(let u=0;u<t.length;u++)r(u)&&l.push(u);if(i.length===0||i.length!==l.length||i.some((u,f)=>e[u]!==t[l[f]]))return Ut(e,t);let a=[],c=0,d=0;for(let u=0;u<=i.length;u++){let f=u<i.length?i[u]:e.length,p=u<l.length?l[u]:t.length;for(let m of fe(e.slice(c,f),t.slice(d,p),o))m.op==="eq"?a.push({op:"eq",a:m.a+c,b:m.b+d}):m.op==="del"?a.push({op:"del",a:m.a+c}):a.push({op:"ins",b:m.b+d});u<i.length&&a.push({op:"eq",a:f,b:p}),c=f+1,d=p+1;}return a}var jr=/[\p{sc=Han}\u3000-\u303F\uFF01-\uFF0F\uFF1A-\uFF20]/u,Kr=/\p{sc=Hiragana}/u,zr=/[\p{sc=Katakana}\u30FC]/u,qr=/[\p{sc=Thai}\p{sc=Lao}\p{sc=Khmer}\p{sc=Myanmar}]/u,Hr=/[\p{L}\p{M}\p{N}_]/u,Xr=/\s/u,Gr=/['\u2019]/u;function Ze(e){return jr.test(e)?"han":Kr.test(e)?"hiragana":zr.test(e)?"katakana":qr.test(e)?"dictionary":Hr.test(e)?"word":Xr.test(e)?"space":"other"}var Ee;function Yr(e){let t=[],n=0;for(;n<e.length;){let o=e.codePointAt(n)>65535?2:1,s=Ze(e.slice(n,n+o)),i=n+o;if(s!=="other"&&s!=="space")for(;i<e.length;){let a=e.codePointAt(i)>65535?2:1,c=Ze(e.slice(i,i+a));if(c!==s&&!(c==="word"&&/\p{M}/u.test(e[i]))&&(s!=="word"||!Gr.test(e[i])||Ze(e[i+1]??"")!=="word"))break;i+=a;}s==="dictionary"?Vr(e,n,i,t):t.push([n,i]),n=i;}return t}function Vr(e,t,n,r){if(Ee===void 0&&(Ee=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"word"}):null),!Ee){r.push([t,n]);return}for(let o of Ee.segment(e.slice(t,n)))r.push([t+o.index,t+o.index+o.segment.length]);}var Zr="\xB6",ne="\xB6END",be=class{#e=new Map;#t=new WeakMap;#n=new WeakMap;#i=new WeakMap;#o=new WeakMap;controls(t){let n=this.#o.get(t.wrappers);if(n===void 0){let r=t.wrappers.filter(o=>ue(o.key)).map(o=>pe(o.key)).join("");n=r===""?"":this.#r(`C:${r}`),this.#o.set(t.wrappers,n);}return n}of(t){let n=this.#t.get(t.wrappers);n||(n=new Map,this.#t.set(t.wrappers,n));let r=n.get(t.fields);if(r===void 0){let o=[...t.wrappers.filter(s=>!ue(s.key)).map(s=>this.#s(this.#n,s,()=>s.key)),...(t.fields??[]).map(s=>this.#s(this.#i,s,()=>Qr(s)))];r=o.length===0?"":this.#r(o.join("")),n.set(t.fields,r);}return r}#s(t,n,r){let o=t.get(n);return o===void 0&&(o=this.#r(r()),t.set(n,o)),o}#r(t){let n=this.#e.get(t);return n===void 0&&(n=`S${this.#e.size}`,this.#e.set(t,n)),n}};function Lt(e,t,n,r){let o=e.atoms,s="";for(let i of o)s+=i.text;for(let[i,l]of Yr(s))n.push({kind:"text",key:Jr(o,i,l,r),unit:e,from:i,to:l});n.push({kind:"mark",key:t?ne:`${Zr}${e.sectPr?"S":""}`,unit:e});}function Jr(e,t,n,r){let o="",s="";for(let i=t;i<n;i++){let l=e[i],a=r.of(l);(i===t?a!=="":a!==s)&&(o+=`${a}`),s=a,o+=l.kind==="char"?l.text:`${l.key}`;}return o}var Qr=e=>`F:${e.instr.trim().replace(/\s+/g," ")}`;function Kt(e,t){let n=[],r=0;for(;r<e.length;){if(e[r].op!=="del"){n.push(e[r]),r++;continue}let o=r;for(;o<e.length&&e[o].op==="del";)o++;let s=e.slice(r,o);if(r=o,o<e.length&&e[o].op!=="eq"||s.some(d=>!jt(t[d.a]))){M(n,s);continue}let i=s[0].a,l=s[s.length-1].a,a=0;for(;a<n.length;){let d=n[n.length-1-a];if(d.op!=="eq"||d.a!==i-1-a)break;let u=t[d.a];if(!jt(u)||u.key!==t[l-a].key)break;a++;}if(a===0){M(n,s);continue}let c=n.splice(n.length-a,a);for(let d=i-a;d<=l-a;d++)n.push({op:"del",a:d});c.forEach((d,u)=>n.push({op:"eq",a:l-a+1+u,b:d.b}));}return n}var eo=.3,to=3,Wt=/[\p{L}\p{N}]/u;function zt(e,t,n){if(!n)return [...e];let r=0,o=0;for(let l of e){let a=l.op==="ins"?null:t[l.a];l.op!=="ins"&&(a.kind!=="text"||!Wt.test(a.key)||(r++,l.op==="eq"&&o++));}if(r===0||o/r>=eo)return [...e];let s=[],i=0;for(;i<e.length;){if(e[i].op!=="eq"){s.push(e[i]),i++;continue}let l=i,a=0;for(;l<e.length&&e[l].op==="eq";){let c=t[e[l].a];c.kind==="text"&&Wt.test(c.key)&&a++,l++;}for(let c of e.slice(i,l)){let d=t[c.a];a<to&&(d.kind==="text"||d.kind==="mark"&&d.key!==ne)?s.push({op:"del",a:c.a},{op:"ins",b:c.b}):s.push(c);}i=l;}return Oe(s)}function qt(e,t,n){let r=[],o=0;for(let s=0;s<e.length;s++){let i=e[s];if(i.op!=="eq"||t[i.a].kind!=="mark")continue;let l=e.slice(o,s),a=l.every(d=>d.op!=="eq"&&(d.op==="ins"?n[d.b]:t[d.a]).kind==="text"),c=l.some(d=>d.op==="ins")&&l.some(d=>d.op==="del");a&&c&&t[i.a].key!==ne?M(r,l.filter(d=>d.op==="ins"),[{op:"ins",b:i.b}],l.filter(d=>d.op==="del"),[{op:"del",a:i.a}]):M(r,l,[i]),o=s+1;}return M(r,e.slice(o)),r}var jt=e=>e.kind==="text"&&!e.key.includes(""),no=/^[^\p{L}\p{N}]+$/u;function Ht(e,t){let n=[],r=0;for(;r<e.length;){let o=e[r];if(o.op!=="eq"){n.push(o),r++;continue}let s=r;for(;s<e.length&&e[s].op==="eq";)s++;if(e.slice(r,s).every(l=>{let a=t[l.a];return a.kind==="text"&&no.test(a.key)})&&r>0&&s<e.length&&ro(e,r,s))for(let l of e.slice(r,s))n.push({op:"del",a:l.a},{op:"ins",b:l.b});else M(n,e.slice(r,s));r=s;}return Oe(n)}function ro(e,t,n){let r=false,o=false;for(let s=t-1;s>=0&&e[s].op!=="eq";s--)e[s].op==="ins"?r=true:o=true;for(let s=n;s<e.length&&e[s].op!=="eq";s++)e[s].op==="ins"?r=true:o=true;return r&&o}function oo(e,t,n,r){let o=`<w:${e}${r.attrs()}/>${n.markRPr}`;t.markRPr!==n.markRPr&&(o+=`<w:rPrChange${r.attrs()}><w:rPr>${t.markRPr}</w:rPr></w:rPrChange>`);let s=t.pPr.join(""),i=n.pPr.join(""),l=s===i?"":`<w:pPrChange${r.attrs()}><w:pPr>${s}</w:pPr></w:pPrChange>`;return `<w:pPr>${i}<w:rPr>${o}</w:rPr>${l}</w:pPr>`}var so=3,Je=new Map,io=/[\p{L}\p{N}]+/gu;function Xt(e,t){return e.kind!=="paragraph"||e===t||e.sectPr||e.atoms.some(r=>r.kind!=="char")?false:(e.atoms.map(r=>r.text).join("").match(io)?.length??0)>=so}function Gt(e,t,n,r){if(e.length<2)return Je;let o=new Map,s=new Map;e.forEach((l,a)=>{for(let c of l.base)Xt(c,t)&&o.set(c.key,o.has(c.key)?null:{unit:c,hunk:a});for(let c of l.revised)Xt(c,n)&&s.set(c.key,s.has(c.key)?null:{unit:c,hunk:a});});let i=new Map;for(let[l,a]of o){let c=s.get(l);if(!a||!c||a.hunk===c.hunk)continue;let d=`move${++r.state.moves}`;i.set(a.unit,{kind:"moveFrom",name:d,partner:c.unit}),i.set(c.unit,{kind:"moveTo",name:d,partner:a.unit});}return i}function Yt(e,t,n){let r=t.kind==="moveFrom",o=r?e:t.partner,s=r?t.partner:e,i=n.detectFormatChanges&&o.atoms.length===s.atoms.length&&(o.pPr.join("")!==s.pPr.join("")||o.markRPr!==s.markRPr||o.atoms.some((f,p)=>f.rPr!==s.atoms[p].rPr)),l=e.atoms.map((f,p)=>{if(!i)return {mark:t.kind,atom:f,baseRPr:f.rPr,markers:f.markers};let m=s.atoms[p].rPr;return {mark:t.kind,atom:r?{...f,rPr:m}:f,baseRPr:o.atoms[p].rPr,markers:f.markers}}),a=i?oo(t.kind,o,s,n):Re(t.kind,r?e:null,r?null:e,n),c=n.rangeAttrs(t.name),d=me(l,n),u=e.trailingMarkers.join("");return ge(a,`<w:${t.kind}RangeStart${c.attrs}/>${d}<w:${t.kind}RangeEnd w:id="${c.id}"/>${u}`)}var W="http://schemas.openxmlformats.org/officeDocument/2006/relationships",S=e=>e.kind!=="textValue",O=e=>S(e)?e.children.filter(S):[],$=(e,t)=>O(e).find(n=>n.localName===t);function b(e,t,n){if(S(e))return e.attributes.find(r=>r.localName===t&&(n===void 0||r.namespaceUri===n))?.value}var lo="http://schemas.openxmlformats.org/markup-compatibility/2006",co="http://www.w3.org/2001/XMLSchema-instance";function fo(e){let t=new Set,n=[e];for(;n.length>0;){let r=n.pop();for(let o of r.attributes)if(o.namespaceUri===lo||o.namespaceUri===""&&o.localName==="Requires"||o.namespaceUri===co&&o.localName==="type")for(let i of o.value.split(/\s+/)){let l=i.indexOf(":");i&&t.add(l<0?i:i.slice(0,l));}M(n,O(r));}return t}function Vt(e,t){if(!S(e)||t.length===0)return e;let n=fo(e);if(n.size===0)return e;let r=new Set(e.namespaceBindings.map(s=>s.prefix)),o=t.filter(s=>n.has(s.prefix)&&!r.has(s.prefix));return o.length===0?e:{...e,namespaceBindings:[...e.namespaceBindings,...o]}}function $e(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _(e){return $e(e).replace(/"/g,""")}var uo={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function re(e){return e.includes("&")?e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[A-Za-z]+);/g,(t,n)=>{if(n[0]!=="#")return uo[n]??t;let r=n[1]==="x"?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return r>=0&&r<=1114111?String.fromCodePoint(r):t}):e}var po=/(?<!\s)\s+xmlns(?::([A-Za-z_][\w.-]*))?="([^"]*)"/g,H=class{#e=new Map;serialize(t){let n=store.serializeOoxmlPart({id:"fragment",name:"/fragment.xml",contentType:"application/xml",root:t});return this.strip(n.replace(/^<\?xml[^>]*\?>\s*/,""))}strip(t){return t.replace(po,(n,r,o)=>{if(r===void 0)return n;let s=r,i=this.#e.get(s);return i===void 0?(this.#e.set(s,o),""):i===o?"":n})}uriOf(t){return this.#e.get(t)}declarations(){return [...this.#e].filter(([t])=>t!==""&&t!=="xml").sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>` xmlns:${t}="${_(n)}"`).join("")}};function oe(e){let t=/^<([^\s/>]+)([^>]*)\/>$/.exec(e);if(t)return {start:`<${t[1]}${t[2]}>`,end:`</${t[1]}>`};let n=/^<([^\s/>]+)[^>]*>/.exec(e);return n?{start:n[0],end:`</${n[1]}>`}:{start:e,end:""}}function se(e){if(/^<[^>]*\/>$/.test(e))return "";let t=/^<[^>]*>/.exec(e),n=/<\/[^>]+>$/.exec(e);return !t||!n?"":e.slice(t[0].length,e.length-n[0].length)}var Se=e=>new Set([e]);function V(e,t,n,r,o="",s=false){let i=`${e}Change`,l=n??t,a=n?r.revised:r.base,c=z($(l,e),a,Z[e]);if(c+=o,t&&n&&r.detectFormatChanges&&(s||ie(e,t,n,r))){let d=z($(t,e),r.base,Z[e]);c+=`<w:${i}${r.attrs()}><w:${e}>${d}</w:${e}></w:${i}>`;}return c?`<w:${e}>${c}</w:${e}>`:e==="tblPr"?"<w:tblPr/>":""}var Z={tblPr:Se("tblPrChange"),trPr:new Set(["trPrChange","ins","del"]),tcPr:new Set(["tcPrChange","cellIns","cellDel","cellMerge"]),tblPrEx:Se("tblPrExChange")};function ie(e,t,n,r){let o=z($(t,e),r.base,Z[e]),s=z($(n,e),r.revised,Z[e]);return Ce(o)!==Ce(s)}var Ce=e=>e.replace(/\sw:rsid\w*="[^"]*"/g,"");function mo(e,t,n){let r=t??e,o=t?n.revised:n.base,s=$(r,"tblGrid"),i=z(s,o,Se("tblGridChange"));if(e&&t&&n.detectFormatChanges){let l=z($(e,"tblGrid"),n.base,Se("tblGridChange"));l!==i&&(i+=`<w:tblGridChange${n.idOnly()}><w:tblGrid>${l}</w:tblGrid></w:tblGridChange>`);}return `<w:tblGrid>${i}</w:tblGrid>`}var Zt=e=>O(e).filter(t=>t.localName==="tr"),X=e=>O(e).filter(t=>t.localName==="tc"),go=new Set(["tblPr","tblGrid","tr"]),tt=new Set(["tblPrEx","trPr","tc"]);function Jt(e,t,n,r){let o=[],s=0;for(let i of e?O(e):[])i.localName===n?s++:t.has(i.localName)||o.push({at:s,xml:r.serialize(i)});return o}var Qt=(e,t)=>e.length===t.length&&e.every((n,r)=>n.at===t[r].at&&Ce(n.xml)===Ce(t[r].xml));function Me(e,t,n,r,o){let s=Jt(e,n,r,o.base);if(!t)return s;let i=Jt(t,n,r,o.revised);return (i.length>0&&(!e||!Qt(s,i))||s.length>0&&!Qt(s,i))&&o.state.untracked++,e?s:[]}function tn(e){let t=new Map;for(let n of e)t.set(n.at,(t.get(n.at)??"")+n.xml);return n=>t.get(n)??""}function he(e,t,n){let o=mo(e,t,n),s=`<w:tbl>${V("tblPr",e,t,n)}${o}`,i=!!e&&!!t&&(ie("tblPr",e,t,n)||o.includes("<w:tblGridChange")),l=e?Zt(e):[],a=t?Zt(t):[],c=Me(e,t,go,"tr",n),d=0,u=0,f=0,p=()=>{for(;f<c.length;){let x=c[f].at;if(!(!e||d===x)||!(!t||u===x)){if(e&&d>x||t&&u>x){n.state.untracked++,f++;continue}return}s+=c[f].xml,f++;}},m=(x,h,y)=>{p(),s+=x,h&&d++,y&&u++;};if(e)if(t){let x=[],h=[],y=()=>{let g=0;for(;g<x.length&&g<h.length&&X(x[g]).length===X(h[g]).length;)m(en(x[g],h[g],n,i),true,true),g++;for(let k of x.slice(g))m(Qe(k,n,i),true,false);for(let k of h.slice(g))m(et(k,n),false,true);x=[],h=[];};for(let g of fe(l.map(ve),a.map(ve)))if(g.op==="eq"){y();let k=l[g.a],w=a[g.b];X(k).length===X(w).length?m(en(k,w,n,i),true,true):(m(Qe(k,n,i),true,false),m(et(w,n),false,true));}else g.op==="del"?x.push(l[g.a]):h.push(a[g.b]);y();}else for(let x of l)m(Qe(x,n,i),true,false);else for(let x of a)m(et(x,n),false,true);return p(),f<c.length&&n.state.untracked++,`${s}</w:tbl>`}function Te(e,t){let n=$(e,"tblPrEx");return n?t.serialize(n):""}function ho(e,t,n){let r=$(t,"tblPrEx"),o=$(e,"tblPrEx");if(!n.detectFormatChanges||!ie("tblPrEx",e,t,n))return Te(t,n.revised);if(!o)return n.state.unrecordedProperties++,Te(t,n.revised);let s=z(o,n.base,Z.tblPrEx);return `<w:tblPrEx>${r?z(r,n.revised,Z.tblPrEx):""}<w:tblPrExChange${n.attrs()}><w:tblPrEx>${s}</w:tblPrEx></w:tblPrExChange></w:tblPrEx>`}function en(e,t,n,r){let o=X(e),s=X(t),i=r||ie("trPr",e,t,n)||ie("tblPrEx",e,t,n)||s.some((c,d)=>ie("tcPr",o[d],c,n)),l=tn(Me(e,t,tt,"tc",n)),a=`<w:tr>${ho(e,t,n)}${V("trPr",e,t,n)}`;return s.forEach((c,d)=>{let u=o[d];a+=`${l(d)}<w:tc>${V("tcPr",u,c,n,"",i)}${B(F(u,n.base),F(c,n.revised),n)}</w:tc>`;}),`${a}${l(s.length)}</w:tr>`}function Qe(e,t,n){let r=tn(Me(e,null,tt,"tc",t)),o=l=>{if(!n||!t.detectFormatChanges)return V("tcPr",l,null,t);let a=z($(l,"tcPr"),t.base,Z.tcPr);return `<w:tcPr>${a}<w:tcPrChange${t.attrs()}><w:tcPr>${a}</w:tcPr></w:tcPrChange></w:tcPr>`},s=`<w:tr>${Te(e,t.base)}${V("trPr",e,null,t,`<w:del${t.attrs()}/>`)}`,i=X(e);for(let[l,a]of i.entries())s+=`${r(l)}<w:tc>${o(a)}${B(F(a,t.base),[],t)}</w:tc>`;return `${s}${r(i.length)}</w:tr>`}function et(e,t){Me(null,e,tt,"tc",t);let n=`<w:tr>${Te(e,t.revised)}${V("trPr",null,e,t,`<w:ins${t.attrs()}/>`)}`;for(let r of X(e))n+=`<w:tc>${V("tcPr",null,r,t)}${B([],F(r,t.revised),t)}</w:tc>`;return `${n}</w:tr>`}function ye(e,t,n){let r=t??e,o=t?n.revised:n.base,i=((c,d)=>O(c).filter(u=>u.localName==="sdtPr"||u.localName==="sdtEndPr").map(u=>d.serialize(u)).join(""))(r,o),l=(c,d)=>{let u=c?$(c,"sdtContent"):void 0;return u?F(u,d):[]},a=B(l(e,n.base),l(t,n.revised),n);return `<w:sdt>${i}<w:sdtContent>${a}</w:sdtContent></w:sdt>`}function B(e,t,n,r=false){if(e.length===0&&t.length===0)return "";let o=nn(e),s=nn(t);if((o<e.length||s<t.length)&&e[o-1]?.kind==="paragraph"&&t[s-1]?.kind==="paragraph")return B(e.slice(0,o),t.slice(0,s),n,r)+B(e.slice(o),t.slice(s),n);let i=[],l=null;for(let f of fe(e.map(p=>p.key),t.map(p=>p.key)))f.op==="eq"?(l=null,i.push({kind:"pair",base:e[f.a],revised:t[f.b]})):(l||(l={base:[],revised:[]},i.push({kind:"hunk",...l})),f.op==="del"?l.base.push(e[f.a]):l.revised.push(t[f.b]));wo(i);let a=e[e.length-1],c=t[t.length-1],d=Gt(i.filter(f=>f.kind==="hunk"),a,c,n),u="";for(let f of i)if(f.kind==="pair")u+=an(f.base,f.revised,n,f.base===a&&f.revised===c);else {let p=a?.kind==="paragraph"&&c?.kind==="paragraph"&&f.base.includes(a)&&f.revised.includes(c),m=r&&(e.length===0||t.length===0);u+=ln(f.base,f.revised,p||m?a??null:null,p||m?c??null:null,n,d);}return u}var yo=/<[A-Za-z_][\w.-]*:fldData[\s/>]/;function ko(e,t,n){for(let r=0;r<e.to-e.from;r++){let o=n.controls(e.unit.atoms[e.from+r]),s=n.controls(t.unit.atoms[t.from+r]);if(o!==""&&s!==""&&o!==s)return true}return false}var xo=/^(?:customXml|altChunk|oMathPara|oMath)$/;function nn(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n.kind!=="opaque"||xo.test(n.node.localName))break;t--;}return t}function wo(e){let t=e[e.length-1],n=e[e.length-2];if(t?.kind!=="hunk"||n?.kind!=="pair"||n.base.kind!=="paragraph"||n.revised.kind!=="paragraph")return;let r=t.base[t.base.length-1],o=t.revised[t.revised.length-1];r?.kind==="paragraph"&&o?.kind==="paragraph"||e.splice(e.length-2,2,{kind:"hunk",base:[n.base,...t.base],revised:[n.revised,...t.revised]});}function an(e,t,n,r=false){return e.kind==="paragraph"&&t.kind==="paragraph"?ln([e],[t],r?e:null,r?t:null,n):e.kind==="table"&&t.kind==="table"?rn(e.node,t.node,n)??he(e.node,t.node,n):e.kind==="sdt"&&t.kind==="sdt"?rn(e.node,t.node,n)??ye(e.node,t.node,n):n.base.serialize(e.node)}var Po=/<(?:[\w.-]+:)?(?:footnoteReference|endnoteReference|commentReference|commentRangeStart)\b/;function rn(e,t,n){let r=n.base.raw(e);if(Po.test(r))return null;let o=n.revised.raw(t);return n.base.keyOf(r)!==n.revised.keyOf(o)?null:n.base.remap(r)}function on(e,t,n,r){let o=[];for(let s of e){let i=n.get(s);i&&s.kind==="paragraph"?o.push({kind:"move",key:`${i.kind}:${i.name}`,unit:s,end:i}):s.kind==="paragraph"?Lt(s,s===t,o,r):o.push({kind:"block",key:s.key,unit:s});}return o}function ln(e,t,n,r,o,s=Je){let i=Ro(e,t,o);if(i.length===0)return nt(e,t,n,r,o,s);let l="",a=0,c=0;for(let[d,u]of i)l+=nt(e.slice(a,d),t.slice(c,u),n,r,o,s),l+=cn(e[d],t[u],o),a=d+1,c=u+1;return l+nt(e.slice(a),t.slice(c),n,r,o,s)}function nt(e,t,n,r,o,s){if(e.length===0&&t.length===0)return "";let i=new be,l=on(e,n,s,i),a=on(t,r,s,i),c=bo(Eo(qt(zt(Ht(Kt(Bt(l.map(h=>h.key),a.map(h=>h.key),h=>l[h].kind!=="text",h=>a[h].kind!=="text"),l),l),l,e.length>1||t.length>1),l,a),l,a),l,a),d="",u=[],f="",p=(h,y="both")=>{let g=y==="base"?No:Oo;u.length===0||y!=="both"&&f===""&&u.every(k=>g.has(k.mark))?d+=h:f+=h;},m=(h,y,g)=>{let k=(y&&h!=="ins"?y.trailingMarkers.join(""):"")+(g&&g!==y&&h!=="del"?g.trailingMarkers.join(""):"");d+=ge(Re(h,y,g,o),me(u,o)+k),u=[],d+=f,f="";},x=(h,y)=>{let g=h.unit.atoms;for(let k=h.from;k<h.to;k++)if(g[k].wrappers.some(w=>w.key.startsWith("fldSimple|")&&yo.test(w.start))){o.state.untracked++;break}for(let k=h.from;k<h.to;k++){let w=g[k];if(w.note&&y==="del"&&o.state.deletedNotes.push({kind:w.note.kind,base:w.note.id}),w.note&&y==="ins"){o.state.newNotes.push({kind:w.note.kind,revised:w.note.id});let P=Ie(w.note.kind,w.note.id);w={...w,xml:w.xml.replace(/\bw:id="[^"]*"/,`w:id="${P}"`)};}if(w.node){let P=rt(y==="del"?w:null,y==="ins"?w:null,o);w={...w,xml:P,delXml:P};}u.push({mark:y,atom:w,baseRPr:"",markers:w.markers});}};for(let h of c){if(h.op==="pair"){p(cn(h.base,h.revised,o));continue}if(h.op==="eq"){let k=l[h.a],w=a[h.b];if(k.kind==="text"&&w.kind==="text"&&ko(k,w,i))x(k,"del"),x(w,"ins");else if(k.kind==="text"&&w.kind==="text")for(let P=0;P<k.to-k.from;P++){let R=k.unit.atoms[k.from+P],E=w.unit.atoms[w.from+P];R.note&&E.note&&(o.state.notePairs.push({kind:E.note.kind,base:R.note.id,revised:E.note.id}),E={...E,xml:R.xml}),R.node&&E.node?E={...E,xml:rt(R,E,o)}:E.kind==="object"&&R.kind==="object"&&!E.note&&(E={...E,xml:R.xml,delXml:R.delXml}),u.push({mark:"eq",atom:E,baseRPr:R.rPr,markers:[...R.markers,...E.markers]});}else k.kind==="mark"&&w.kind==="mark"?m("eq",k.unit,w.unit):k.kind==="block"&&w.kind==="block"&&p(an(k.unit,w.unit,o));continue}let y=h.op==="del"?l[h.a]:a[h.b],g=h.op;y.kind==="text"?x(y,g):y.kind==="mark"?y.key===ne&&(l.length===0||a.length===0)?m("eq",y.unit,y.unit):m(g,g==="del"?y.unit:null,g==="ins"?y.unit:null):y.kind==="move"?p(Yt(y.unit,y.end,o),y.end.kind==="moveFrom"?"base":"revised"):p(g==="del"?Co(y.unit,o):To(y.unit,o),g==="del"?"base":"revised");}return u.length>0&&(d+=ge("",me(u,o)),o.state.untracked++),d+f}var No=new Set(["ins","moveTo"]),Oo=new Set(["del","moveFrom"]);function Eo(e,t,n){let r=[],o=0;for(;o<e.length;){if(e[o].op==="eq"){r.push(e[o]),o++;continue}let s=o;for(;s<e.length&&e[s].op!=="eq";)s++;let i=e.slice(o,s),l=i.filter(f=>f.op==="ins"),a=i.filter(f=>f.op==="del"),c=0,d=0,u=new Map;a.forEach((f,p)=>{let m=t[f.a];if(m.kind!=="block")return;let x=u.get(m.unit.kind)??{positions:[],next:0};x.positions.push(p),u.set(m.unit.kind,x);});for(let f=0;f<l.length;f++){let p=n[l[f].b];if(p.kind!=="block"||p.unit.kind==="opaque")continue;let m=u.get(p.unit.kind);if(!m)continue;for(;m.next<m.positions.length&&m.positions[m.next]<d;)m.next++;let x=m.positions[m.next]??-1;x<0||(M(r,l.slice(c,f),a.slice(d,x)),r.push({op:"pair",base:t[a[x].a].unit,revised:p.unit}),c=f+1,d=x+1);}M(r,l.slice(c),a.slice(d)),o=s;}return r}function bo(e,t,n){let r=[],o=0;for(;o<e.length;){let s=e[o];if(s.op!=="ins"&&s.op!=="del"){r.push(s),o++;continue}let i=o;for(;i<e.length&&(e[i].op==="ins"||e[i].op==="del");)i++;let l=e.slice(o,i),a=l.filter(f=>f.op==="del"),c=-1;a.forEach((f,p)=>{f.op==="del"&&t[f.a].kind==="block"&&(c=p);});let d=[...l].reverse().find(f=>f.op==="ins"),u=d!==void 0&&n[d.b].kind==="mark";if(c<0||!d||c===a.length-1&&u)M(r,l);else {let f=l.filter(p=>p.op==="ins");M(r,a.slice(0,c+1),f,a.slice(c+1));}o=i;}return r}function sn(e,t){if(e.kind!=="sdt")return null;let n=$(e.node,"sdtPr");return n?t.keyOf(t.raw(n)):""}function Ro(e,t,n){if(e.length+t.length<=2)return [];let r=new Map;t.forEach((i,l)=>{let a=sn(i,n.revised);if(a===null)return;let c=r.get(a)??{at:[],next:0};c.at.push(l),r.set(a,c);});let o=[];if(r.size===0)return o;let s=-1;for(let i=0;i<e.length;i++){let l=sn(e[i],n.base),a=l===null?void 0:r.get(l);if(!a)continue;for(;a.next<a.at.length&&a.at[a.next]<=s;)a.next++;let c=a.at[a.next];c!==void 0&&(a.next++,o.push([i,c]),s=c);}return o}function cn(e,t,n){return e.kind==="table"?he(e.node,t.node,n):ye(e.node,t.node,n)}var $o="http://schemas.openxmlformats.org/wordprocessingml/2006/main",So=new Set(["altChunk","customXml","r","hyperlink","fldSimple"]),dn=e=>e.node.namespaceUri!==$o||So.has(e.node.localName);function Co(e,t){return e.kind==="table"?he(e.node,null,t):e.kind==="sdt"?ye(e.node,null,t):(dn(e)&&t.state.untracked++,t.base.serialize(e.node))}function To(e,t){return e.kind==="table"?he(null,e.node,t):e.kind==="sdt"?ye(null,e.node,t):(dn(e)&&t.state.untracked++,"")}var vo=e=>`${D}TXBX:${e}\xA7`;function Ae(e){let t=[],n=r=>{if(S(r)){if(r.localName==="txbxContent"){t.push(r);return}for(let o of r.children)n(o);}};return n(e),t}function ot(e){let t=0,n=r=>S(r)?r.localName==="txbxContent"?{...r,children:[{id:`${r.id}:marker`,kind:"textValue",value:vo(t++)}]}:{...r,children:r.children.map(n)}:r;return n(e)}function rt(e,t,n){let r=t??e,o=t?n.revised:n.base,s=r.node,i=o.serialize(ot(s)),l=e?.node?Ae(e.node):[],a=t?.node?Ae(t.node):[],c=Math.max(l.length,a.length),d=[];for(let f=0;f<c;f++){let p=l[f],m=a[f];d.push(B(p?F(p,n.base):[],m?F(m,n.revised):[],n));}let u=new RegExp(`${D}TXBX:(\\d+)\xA7`,"g");return i.replace(u,(f,p)=>d[Number(p)]??f)}var Mo="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function q(e,t,n="val"){let r=new Set;for(let o of e.parts.values()){let s=[o.root];for(let i=s.pop();i;i=s.pop()){if(t.has(i.localName)&&i.namespaceUri===Mo){let l=b(i,n);l!==void 0&&r.add(l);}for(let l of O(i))s.push(l);}}return r}function G(e,t=1){let n=new Set;for(let o of e){n.add(o);let s=o.trim();/^[+-]?\d+$/.test(s)&&n.add(String(BigInt(s)));}let r=t;return ()=>{for(;n.has(String(r));)r++;return n.add(String(r)),String(r)}}var Uo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";function Y(e,t){switch(t){case "styles":{let n=store.stylesPartOf(e);return n&&(store.relationshipsOf(e,e.mainDocumentPart).some(o=>{if(o.type!==Uo)return false;let s=store.resolveRelationship(o);return s.mode==="Internal"&&s.target.ok&&s.target.partName===n.name})||n.name==="/word/styles.xml")?n:void 0}case "numbering":{let n=store.numberingRootOf(e);if(!n)return;for(let r of e.parts.values())if(r.root===n)return r;return}case "settings":return store.settingsPartOf(e)??void 0;case "footnotes":return store.resolveNotesPart(e,"footnote")??void 0;case "endnotes":return store.resolveNotesPart(e,"endnote")??void 0;case "comments":{let n=store.commentsPartNameForStory(e,e.mainDocumentPart);return n===null?void 0:e.parts.get(n)}}}var un=new WeakMap,De=e=>(e.startsWith("/")?e:`/${e}`).replace(/[A-Z]/g,t=>t.toLowerCase());function ae(e,t){let n=un.get(e);if(!n){let r=new Set;for(let o of e.parts.keys())r.add(De(o));for(let o of e.partBytes.keys())r.add(De(o));Bo(e,r),un.set(e,n=r);}return n.has(De(t))}function Bo(e,t){for(let n of e.relationships.values())for(let r of n){let o=store.resolveRelationship(r);o.mode==="Internal"&&o.target.ok&&t.add(De(o.target.partName));}}function le(e,t){let n=r=>ae(e,r);if(!n(t))return t;for(let r=2;;r++){let o=t.replace(/\.xml$/,`${r}.xml`);if(!n(o))return o}}var _e=e=>`application/vnd.openxmlformats-officedocument.wordprocessingml.${e}+xml`;var Wo="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Nn=new WeakMap;function On(e){return Nn.get(e)}var jo=/(<(?:[\w.-]+:)?numId\b[^>]*?\s(?:[\w.-]+:)?val=")([^"]*)(")/g;function Ue(e,t){return t.size===0||!e.includes("numId")?e:e.replace(jo,(n,r,o,s)=>{let i=t.get(o);return i===void 0?n:`${r}${i}${s}`})}var ce=(e,t)=>Y(e,t);function j(e){return store.serializeOoxmlPart({id:"fragment",name:"/fragment.xml",contentType:"application/xml",root:e}).replace(/^<\?xml[^>]*\?>\s*/,"")}function En(e,t,n){let r=/^<([^\s/>]+)([^>]*)\/>\s*$/.exec(e);if(r)return `<${r[1]}${r[2]}>${n}</${r[1]}>`;let o=t.length>0?new RegExp(`<(?:[\\w.-]+:)?(?:${t.join("|")})[\\s/>]`).exec(e):null,s=o?o.index:e.lastIndexOf("</");return e.slice(0,s)+n+e.slice(s)}var bn=(e,t,n)=>En(j(e.root),t,n),Ko=e=>e.replace(/<(?:[\w.-]+:)?numPicBullet\b[\s\S]*?<\/(?:[\w.-]+:)?numPicBullet>/g,"").replace(/<(?:[\w.-]+:)?lvlPicBulletId\b[^>]*\/>/g,""),mn=e=>Ko(e).replace(/<(?:[\w.-]+:)?(?:nsid|styleLink|numStyleLink)\b[^>]*\/>/g,"").replace(/\s[\w.-]+:durableId="[^"]*"/g,"");function Rn(e,t,n,r){return {partName:le(e,`/word/${r}.xml`),contentType:_e(r),xml:t,isNew:true,relType:`${Wo}/${r}`}}var $n="http://schemas.openxmlformats.org/wordprocessingml/2006/main",gn=new Set(["numId"]),zo=new Set(["abstractNumId"]),qo=new Set(["pStyle","rStyle","tblStyle","basedOn","next","link","numStyleLink","styleLink"]);function Ho(e,t,n){let r=ce(t,"styles");if(!r)return null;let o=ce(e,"styles"),s=new Set(q(e,qo)),i=new Map;for(let c of o?O(o.root):[]){if(c.localName!=="style")continue;let d=b(c,"styleId");s.add(d),d!==void 0&&!i.has(d)&&i.set(d,c);}let l="",a=new Map;for(let c of O(r.root)){if(c.localName!=="style")continue;let d=b(c,"styleId"),u=d===void 0?void 0:i.get(d);if(u&&!a.has(u)){let m=Xo(u,c,n);m!==null&&a.set(u,m);continue}if(d===void 0||s.has(d))continue;s.add(d);let f=/^<[^>]*>/.exec(j(c))[0],p=j(c).replace(f,f.replace(/\s[\w.-]*:?default="[^"]*"/,""));l+=Ue(p,n);}return !l&&a.size===0?null:o?{partName:o.name,contentType:o.contentType,xml:a.size===0?bn(o,[],l):Zo(o,a,l),isNew:false}:Rn(e,`<w:styles xmlns:w="${$n}">${l}</w:styles>`,r,"styles")}function Xo(e,t,n){let r=j(e),o=Ue(j(t),n);if(kn(r)===kn(o))return null;let s=Go(/^<[^>]*?\/?>/.exec(r)[0],/^<[^>]*?\/?>/.exec(o)[0]);if(s===null)return o;let i=/^<([^\s/>]+)/.exec(r)[1];return `${s}${Vo(o)}</${i}>`}function Go(e,t){let n=new Map;for(let l of t.matchAll(yn))n.set(l[1]??"",l[2]);let r=new Map;for(let l of e.matchAll(yn))r.set(l[1]??"",l[2]);let o=/^<([^\s/>]+)/.exec(e)[1],s=[...e.matchAll(Yo)].map(l=>l[0]).filter(l=>!/^\s*xmlns(?::|=)/.test(l));for(let l of [o,...s.map(a=>a.trim())]){let a=/^([\w.-]+):/.exec(l)?.[1];if(a===void 0||a==="xml")continue;let c=n.get(a);if(c!==void 0&&r.has(a)&&c!==r.get(a))return null}let i="";for(let[l,a]of r)n.has(l)||(i+=hn(l,a));for(let[l,a]of n)i+=hn(l,a);return `<${o}${i}${s.join("")}>`}var hn=(e,t)=>e===""?` xmlns="${t}"`:` xmlns:${e}="${t}"`,Yo=/\s[\w.:-]+="[^"]*"/g,yn=/\sxmlns(?::([A-Za-z_][\w.-]*))?="([^"]*)"/g,kn=e=>e.replace(/\s[\w.-]+:rsid\w*="[^"]*"/g,"").replace(/<(?:[\w.-]+:)?rsid\b[^>]*\/>/g,"");function Vo(e){if(/^<[^>]*\/>$/.test(e))return "";let t=/^<[^>]*>/.exec(e)[0];return e.slice(t.length,e.lastIndexOf("</"))}function Zo(e,t,n){let r=e.root,o=j(r),s=/^<[^>]*?\/?>/.exec(o)[0].replace(/\/>$/,">"),i=/^<([^\s/>]+)/.exec(o)[1],l="";for(let a of O(r))l+=t.get(a)??j(a);return `${s}${l}${n}</${i}>`}function Jo(e){return O(e).filter(n=>n.localName!=="nsid"&&n.localName!=="tmpl"&&n.localName!=="styleLink"&&n.localName!=="numStyleLink").map(j).join("")}function st(e,t){let n=new Map,r=new Map;for(let s of O(e.root))if(s.localName==="abstractNum"){let i=b(s,"abstractNumId");i!==void 0&&n.set(i,s);}else if(s.localName==="num"){let i=b(s,"numId");i!==void 0&&r.set(i,s);}let o=new Map;for(let s of t?O(t.root):[]){if(s.localName!=="style")continue;let i=b(s,"styleId"),l=$(s,"pPr"),a=l&&$(l,"numPr"),c=a&&$(a,"numId"),d=c&&b(c,"val");i!==void 0&&d!==void 0&&o.set(i,d);}return {abstracts:n,nums:r,styleLists:o}}var xn=e=>b($(e,"abstractNumId")??e,"val"),Qo=4;function Fe(e,t){let n=xn(e);for(let r=0;n!==void 0&&r<Qo;r++){let o=t.abstracts.get(n),s=o&&$(o,"numStyleLink"),i=s&&b(s,"val"),l=i===void 0?void 0:t.styleLists.get(i),a=l===void 0?void 0:t.nums.get(l),c=a&&xn(a);if(c===void 0||c===n)return n;n=c;}return n}function wn(e){let t=new Map;return n=>{let r=Fe(n,e)??"",o=t.get(r);if(o===void 0){let i=e.abstracts.get(r);o=i?Jo(i):`missing:${r}`,t.set(r,o);}let s=O(n).filter(i=>i.localName!=="abstractNumId").map(j).join("");return `${o}${s}`}}function Pn(e){let t=new Map;for(let[n,r]of e.nums){let o=Fe(r,e);if(o===void 0)continue;let s=t.get(o)??[];s.push(n),t.set(o,s);}return t}function es(e,t){let n=new Map,r=ce(t,"numbering"),o=ce(e,"numbering");if(!r){for(let y of o?st(o,void 0).nums.keys():[])n.set(y,"0");return {map:n,output:null}}let s=o?st(o,ce(e,"styles")):{abstracts:new Map,nums:new Map,styleLists:new Map},i=st(r,ce(t,"styles")),l=wn(s),a=wn(i),c=Pn(s),d=new Map,u=new Set;for(let[y,g]of Pn(i)){let k,w=g.every(E=>{let A=s.nums.get(E);if(!A||l(A)!==a(i.nums.get(E)))return false;let N=Fe(A,s);return k??=N,N===k}),P=new Set(g),R=k!==void 0&&(c.get(k)??[]).every(E=>!i.nums.has(E)||P.has(E));if(!(!w||!R||k===void 0)){for(let E of g)u.add(E);d.set(y,k);}}let f=G([...s.abstracts.keys(),...q(e,zo)]),p=G([...s.nums.keys(),...i.nums.keys(),...q(e,gn),...q(t,gn)]),m="",x="";for(let[y,g]of i.nums){if(u.has(y))continue;let k=Fe(g,i),w=k===void 0?void 0:i.abstracts.get(k);if(!w||k===void 0){n.set(y,"0");continue}let P=d.get(k);P===void 0&&(P=f(),d.set(k,P),m+=mn(j(w).replace(/(\babstractNumId=")[^"]*"/,`$1${P}"`)));let R=p();x+=mn(j(g).replace(/(\bnumId=")[^"]*"/,`$1${R}"`).replace(/(<(?:[\w.-]+:)?abstractNumId\b[^>]*?\s(?:[\w.-]+:)?val=")[^"]*"/,`$1${P}"`)),n.set(y,R);}for(let y of s.nums.keys())!i.nums.has(y)&&!n.has(y)&&n.set(y,"0");if(!m&&!x)return {map:n,output:null};if(!o){let y=`<w:numbering xmlns:w="${$n}">${m}${x}</w:numbering>`;return {map:n,output:Rn(e,y,r,"numbering")}}let h=bn(o,["num","numIdMacAtCleanup"],m);return h=En(h,["numIdMacAtCleanup"],x),{map:n,output:{partName:o.name,contentType:o.contentType,xml:h,isNew:false}}}function Sn(e,t){let n=es(e,t);return Nn.set(t,n.map),[Ho(e,t,n.map),n.output].filter(r=>r!==null)}var We="\uFFFC",D=`\xA7${[...globalThis.crypto.getRandomValues(new Uint32Array(4))].map(e=>e.toString(16).padStart(8,"0")).join("")}`,rs=e=>`${D}CMT:${J(e)}\xA7`,J=e=>encodeURIComponent(e),K=e=>decodeURIComponent(e),Tn=/(\b([A-Za-z_][\w.-]*):(id|embed|link|pict|href|dm|lo|qs|cs|relid)=")([^"]+)"/g,os="urn:schemas-microsoft-com:office:office",ct=`${D}REL:`,dt=`${D}DOCPR:`,ss=/(<(?:[A-Za-z_][\w.-]*:)?docPr\b[^>]*?\sid=")([^"]*)"/g,ft=`${D}ZORDER:`,is=/(<(?:[A-Za-z_][\w.-]*:)?anchor\b[^>]*?\srelativeHeight=")([^"]*)"/g,as=new Set(["bookmarkStart","bookmarkEnd","commentRangeStart","commentRangeEnd","permStart","permEnd","moveFromRangeStart","moveFromRangeEnd","moveToRangeStart","moveToRangeEnd"]),Fn=new Set(["proofErr","lastRenderedPageBreak","noProof"]),ls=new Set(["hyperlink","sdt","fldSimple","smartTag","customXml","dir","bdo"]),Un={sdt:new Set(["sdtPr","sdtEndPr"]),smartTag:new Set(["smartTagPr"]),customXml:new Set(["customXmlPr"]),fldSimple:new Set(["fldData"])},ue=e=>e.startsWith("sdt|")||e.startsWith("smartTag|")||e.startsWith("customXml|");function pe(e){if(!e.startsWith("sdt|"))return e;let t=/<w:id w:val="([^"]*)"/.exec(e)?.[1];return t===void 0?e:`sdt#${t}`}var L=class{constructor(t,n,r,o){this.name=t;this.pkg=n;this.partName=r;this.scope=o;this.#e=new Map([...store.relationshipsOf(n,r).map(s=>[s.id,{type:s.type,target:s.rawTarget,external:s.targetMode==="External"}]),...n.externalTargets.filter(s=>s.ownerPart===r).map(s=>[s.id,{type:s.type,target:s.rawTarget,external:true}])]);}name;pkg;partName;scope;#e;#t=new Map;relKey(t){let n=this.#e.get(t);if(!n)return `missing:${t}`;if(n.external)return `${n.type}|${n.target}`;let r=this.#t.get(t);if(r===void 0){let o=Bn(this.partName,n.target),s={seen:new Set,visits:0,local:false};r=`${n.type}|${Ln(this.pkg,o,s)}`,this.#t.set(t,r);}return r}externalTarget(t){let n=this.#e.get(t);return n?.external?n.target:void 0}raw(t){let n=this.pkg.parts.get(this.partName)?.root,r=this.scope.serialize(Vt(t,n&&S(n)?n.namespaceBindings:[])),o=this.name==="revised"?On(this.pkg):void 0;return o?Ue(r,o):r}serialize(t){return this.remap(this.raw(t))}remap(t){if(this.name==="base")return t;let n=vn(t);return t.replace(Tn,(r,o,s,i,l)=>this.#n(s,i,n)?`${o}${ct}${J(this.partName)}|${J(re(l))}\xA7"`:r).replace(ss,(r,o,s)=>`${o}${dt}${J(re(s))}\xA7"`).replace(is,(r,o,s)=>`${o}${ft}${J(re(s))}\xA7"`)}keyOf(t){let n=vn(t);return ds(t).replace(Tn,(r,o,s,i,l)=>this.#n(s,i,n)?`${o}${this.relKey(re(l))}"`:r)}#n(t,n,r){return (r.get(t)??this.scope.uriOf(t))===(n==="relid"?os:W)}},it=/\s[\w.-]+:(?:paraId|textId|rsid\w*)="[^"]*"/g,cs=/\sxmlns:([\w.-]+)="[^"]*"/g;function ds(e){if(!it.test(e))return e;it.lastIndex=0;let t=e.replace(it,"");return t.replace(cs,(n,r)=>t.includes(`${r}:`,t.indexOf(n)+n.length)?n:"")}function vn(e){let t=new Map;if(!e.includes("xmlns:"))return t;for(let n of e.matchAll(/\sxmlns:([^\s=]+)="([^"]*)"/g))t.has(n[1])||t.set(n[1],n[2]);return t}function Bn(e,t){let n=store.resolveInternalTarget(e,t);return n.ok?n.partName:`invalid:${e}|${t}`}var Mn=new WeakMap,In=new TextEncoder,An=256,fs=0;function Ln(e,t,n){let r=Mn.get(e);r||Mn.set(e,r=new Map);let o=r.get(t);if(o!==void 0)return o;if(n.seen.has(t))return n.local=true,`cycle:${t}`;if(n.seen.size>=An||n.visits>=An)return n.local=true,`overflow:${++fs}`;n.seen.add(t);let s=e.parts.get(t),i=e.partBytes.get(t)??e.partBytes.get(t.slice(1))??(s?In.encode(store.serializeOoxmlPart(s)):void 0),l=i?store.sha256Bytes(i):`missing:${t}`,a=n.local;n.local=false;for(let c of store.relationshipsOf(e,t)){n.visits++;let d=c.targetMode==="External"?`external:${c.rawTarget}`:Ln(e,Bn(t,c.rawTarget),n);l+=`|${c.id}:${c.type}:${d}`;}return n.seen.delete(t),l=store.sha256Bytes(In.encode(l)),n.local||r.set(t,l),n.local||=a,l}function F(e,t){let n=[];for(let r of O(e))switch(r.localName){case "p":n.push(ms(r,t));break;case "tbl":n.push({kind:"table",side:t.name,node:r,key:`T:${us(r)}`});break;case "sdt":n.push({kind:"sdt",side:t.name,node:r,key:`S:${t.keyOf(t.raw(r))}`});break;case "sectPr":case "tcPr":break;default:n.push({kind:"opaque",side:t.name,node:r,key:`O:${t.keyOf(t.raw(r))}`});}return n}function us(e){let t=[];for(let n of O(e).filter(r=>r.localName==="tr"))t.push(ve(n));return t.join("")}function ve(e){return O(e).filter(t=>t.localName==="tc").map(t=>at(t)).join("")}function at(e){return S(e)?e.localName==="p"?`${e.children.map(at).join("")}\xB6`:e.localName==="instrText"?"":e.children.map(at).join(""):e.value}var Be="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ps(e,t,n){let r=b(e,"fldCharType",Be);r==="begin"&&(t.fieldStack.push({instr:""}),t.fields=[...t.fieldStack]),n(),r==="end"&&t.fieldStack.length>0&&(t.fieldStack.pop(),t.fields=t.fieldStack.length>0?[...t.fieldStack]:void 0);}function ms(e,t){let n=$(e,"pPr"),r=[],o="",s=null;for(let a of n?O(n):[])a.localName==="rPr"?o=se(t.serialize(Wn(a))):a.localName==="sectPr"?s=a:a.localName!=="pPrChange"&&r.push(t.serialize(a));let i={atoms:[],pending:[],fieldStack:[],fields:void 0};for(let a of e.children)S(a)&&a.localName!=="pPr"&<(a,t,[],i);let l=i.atoms.map(a=>a.kind==="char"?a.text:`${a.key}`).join("");return {kind:"paragraph",side:t.name,node:e,pPr:r,markRPr:o,sectPr:s,atoms:i.atoms,trailingMarkers:i.pending,key:`P:${l}`}}var gs=new Set(["ins","del","moveFrom","moveTo","rPrChange"]);function Wn(e){return {...e,children:e.children.filter(t=>!(S(t)&&gs.has(t.localName)))}}function lt(e,t,n,r){let o=e.localName;if(!Fn.has(o)){if(as.has(o)){t.name==="base"?r.pending.push(t.serialize(e)):(o==="commentRangeStart"||o==="commentRangeEnd")&&r.pending.push(jn(t.serialize(e)));return}if(o==="r"){ks(e,t,n,r);return}if(o==="ins"||o==="moveTo"){for(let s of O(e))lt(s,t,n,r);return}if(!(o==="del"||o==="moveFrom")){if(ls.has(o)){let s=hs(e,t),i=o==="sdt"?$(e,"sdtContent"):e,l=r.atoms.length;for(let a of i?O(i):[])Un[o]?.has(a.localName)||lt(a,t,[...n,s],r);r.atoms.length===l&&r.atoms.push({kind:"object",text:We,xml:"",delXml:"",key:"empty",rPr:"",wrappers:[...n,s],markers:ut(r),...r.fields?{fields:r.fields}:{}}),s.atomCount=r.atoms.length-l;return}Le(e,"",t,n,r,true);}}}function hs(e,t){let n=e.localName,r=Un[n],o=r?O(e).filter(p=>r.has(p.localName)):[],s=n==="sdt"?$(e,"sdtContent"):void 0,i={...e,children:[...o,...s?[{...s,children:[]}]:[]]},l=t.raw(i),a,c;if(n==="sdt"){let p=l.lastIndexOf("<w:sdtContent"),m=oe(l.slice(p,l.indexOf(">",p)+1));a=l.slice(0,p)+m.start,c=`${m.end}</w:sdt>`;}else (({start:a,end:c}=oe(l))),o.length>0&&(a+=se(l));let d=b(e,"id",W),u=`${n}|${d?t.relKey(d):""}|${t.keyOf(a)}`,f=ys(e,t,d);return {key:u,start:t.remap(a),end:c,...f===void 0?{}:{field:f}}}var Dn=e=>/["\\]/.test(e)?void 0:`"${e}"`;function ys(e,t,n){if(e.localName==="fldSimple"){if($(e,"fldData"))return;let s=b(e,"instr",Be);return s&&s.trim()!==""?s:void 0}if(e.localName!=="hyperlink")return;let r=["HYPERLINK"];if(n){let s=t.externalTarget(n),i=s===void 0?void 0:Dn(s);if(i===void 0)return;r.push(i);}for(let[s,i]of [["anchor","l"],["tooltip","o"],["tgtFrame","t"]]){let l=b(e,s,Be);if(l===void 0)continue;let a=Dn(l);if(a===void 0)return;r.push(`\\${i} ${a}`);}if(r.length===1)return;let o=b(e,"history",Be);return o!=="1"&&o!=="true"&&o!=="on"&&r.push("\\h"),` ${r.join(" ")} `}function ks(e,t,n,r){let o=$(e,"rPr"),s=o?se(t.serialize(Wn(o))):"";for(let i of O(e))switch(i.localName){case "rPr":break;case "t":case "delText":{let l=i.children.map(a=>a.kind==="textValue"?a.value:"").join("");for(let a=0;a<l.length;a++)r.atoms.push({kind:"char",text:l[a],xml:"",delXml:"",key:"",rPr:s,wrappers:n,markers:ut(r),...r.fields?{fields:r.fields}:{}});break}case "commentReference":{let l=`<w:r>${s?`<w:rPr>${s}</w:rPr>`:""}${t.serialize(i)}</w:r>`;r.pending.push(t.name==="base"?l:jn(l));break}case "fldChar":ps(i,r,()=>Le(i,s,t,n,r));break;case "instrText":{let l=r.fieldStack[r.fieldStack.length-1];l&&(l.instr+=i.children.map(a=>a.kind==="textValue"?a.value:"").join("")),Le(i,s,t,n,r);break}default:Fn.has(i.localName)||Le(i,s,t,n,r);}}function Le(e,t,n,r,o,s=false){let i=n.raw(e),l=n.remap(i),a=l.replace(/^<w:instrText\b/,"<w:delInstrText").replace(/<\/w:instrText>$/,"</w:delInstrText>"),c=Ae(e).length>0,d=e.localName==="footnoteReference"?"footnote":e.localName==="endnoteReference"?"endnote":void 0,u=d?b(e,"id"):void 0;o.atoms.push({kind:"object",text:We,xml:l,delXml:a,key:d?`noteRef:${d}:${e.attributes.filter(f=>f.localName!=="id").map(f=>`${f.namespaceUri??""}|${f.localName}=${f.value}`).sort().join(" ")}`:c?n.keyOf(n.raw(ot(e))):n.keyOf(i),rPr:t,wrappers:r,markers:ut(o),...d&&u!==void 0?{note:{kind:d,id:u}}:{},...c?{node:e}:{},...s?{outsideRun:true}:{},...o.fields?{fields:o.fields}:{}});}function jn(e){return e.replace(/\bw:id="([^"]*)"/,(t,n)=>`w:id="${rs(re(n))}"`)}var xs=Object.freeze([]);function ut(e){if(e.pending.length===0)return xs;let t=e.pending;return e.pending=[],t}var ws="http://schemas.openxmlformats.org/wordprocessingml/2006/main",je=class{nextId=1;count=0;untracked=0;furnitureIds=new Map;sectionReferences=new Map;baseSectionIndex=new WeakMap;unrecordedProperties=0;moves=0;notePairs=[];newNotes=[];deletedNotes=[]},Ie=(e,t)=>`${D}NOTE:${e}:${J(t)}\xA7`,Xn=new RegExp(`${D}NOTE:(footnote|endnote):([^\xA7"]+)\xA7`,"g"),Ke=class e{constructor(t,n,r,o,s,i){this.state=t;this.author=n;this.date=r;this.detectFormatChanges=o;this.base=s;this.revised=i;}state;author;date;detectFormatChanges;base;revised;withSides(t,n){return new e(this.state,this.author,this.date,this.detectFormatChanges,t,n)}get revisionCount(){return this.state.count}rangeAttrs(t){let n=this.state.nextId++,r=this.date===void 0?"":` w:date="${this.date}"`;return {id:n,attrs:` w:id="${n}" w:author="${_(this.author)}"${r} w:name="${t}"`}}idOnly(){return this.state.count++,` w:id="${this.state.nextId++}"`}attrs(){this.state.count++;let t=this.date===void 0?"":` w:date="${this.date}"`;return ` w:id="${this.state.nextId++}" w:author="${_(this.author)}"${t}`}},Ps=(e,t)=>e.length===t.length&&e.every((n,r)=>n.key===t[r].key);function Gn(e){let t=[],n=0;for(;n<e.length;){let r=e[n],o=r.atom.wrappers.findIndex(p=>p.field!==void 0);if(o<0||r.mark==="eq"){t.push(r),n++;continue}let s=r.atom.wrappers[o],i=n+1;for(;i<e.length&&e[i].atom.wrappers[o]===s;)i++;if(!((n===0||e[n-1].atom.wrappers[o]!==s)&&i-n===s.atomCount&&e.slice(n,i).every(p=>p.mark===r.mark))){M(t,e.slice(n,i)),n=i;continue}let a=r.atom.wrappers.slice(0,o),c=(p,m,x=[])=>({mark:r.mark,baseRPr:"",markers:x,atom:{kind:"object",text:We,xml:p,delXml:m,key:"",rPr:"",wrappers:a,markers:x}}),d=p=>{let m=`<w:fldChar w:fldCharType="${p}"/>`;return c(m,m)},u=$e(s.field),f=e.slice(n,i).map((p,m)=>({...p,markers:m===0?[]:p.markers,atom:{...p.atom,wrappers:[...a,...p.atom.wrappers.slice(o+1)]}}));M(t,[{...d("begin"),markers:r.markers},c(`<w:instrText xml:space="preserve">${u}</w:instrText>`,`<w:delInstrText xml:space="preserve">${u}</w:delInstrText>`),d("separate")],Gn(f),[d("end")]),n=i;}return t}var Kn=new Set(["del","moveFrom"]);function Ns(e){let t=new Map,n=r=>t.get(r)??r;for(let r=1;r<e.length;r++){let o=e[r-1],s=e[r],i=Kn.has(o.mark);if(i===Kn.has(s.mark))continue;let[l,a]=i?[o,s]:[s,o],c=Math.min(l.atom.wrappers.length,a.atom.wrappers.length);for(let d=0;d<c;d++){let u=n(l.atom.wrappers[d]),f=n(a.atom.wrappers[d]);if(!(u===f||u.key===f.key)){if(!ue(u.key)||pe(u.key)!==pe(f.key))break;t.set(u,f);}}}return t.size===0?e:e.map(r=>r.atom.wrappers.some(o=>t.has(o))?{...r,atom:{...r.atom,wrappers:r.atom.wrappers.map(n)}}:r)}function me(e,t){let n=Ns(e),r=n.some(d=>d.mark!=="eq")?Gn(n):n,o="",s=[],i="eq",l=()=>{i!=="eq"&&(o+=`</w:${i}>`),i="eq";},a=d=>{let u=0;for(;u<s.length&&u<d.length&&s[u].key===d[u].key;)u++;if(!(u===s.length&&u===d.length)){for(l();s.length>u;)o+=s.pop().end;for(let f=u;f<d.length;f++)s.push(d[f]),o+=d[f].start;}},c=0;for(;c<r.length;){let d=r[c],u=zn(d,t),f=c+1;for(;f<r.length;){let p=r[f];if(p.markers.length>0||p.mark!==d.mark||p.atom.rPr!==d.atom.rPr||p.atom.kind==="object"||d.atom.kind==="object"||!Ps(p.atom.wrappers,d.atom.wrappers)||zn(p,t)!==u||u&&p.baseRPr!==d.baseRPr)break;f++;}if(a(d.atom.wrappers),d.markers.length>0&&(l(),o+=d.markers.join("")),d.mark!==i&&(l(),d.mark!=="eq"&&(o+=`<w:${d.mark}${t.attrs()}>`),i=d.mark),d.atom.outsideRun){o+=d.atom.xml,c=f;continue}o+=Os(r.slice(c,f),u?d.baseRPr:null,d.mark==="del",t),c=f;}for(l();s.length>0;)o+=s.pop().end;return o}var zn=(e,t)=>(e.mark==="eq"||e.mark==="moveFrom"||e.mark==="moveTo")&&t.detectFormatChanges&&e.baseRPr!==e.atom.rPr;function Os(e,t,n,r){let o=e[0].atom.rPr;t!==null&&(o+=`<w:rPrChange${r.attrs()}><w:rPr>${t}</w:rPr></w:rPrChange>`);let s="",i="",l=()=>{if(i==="")return;let a=n?"w:delText":"w:t";s+=`<${a} xml:space="preserve">${$e(i)}</${a}>`,i="";};for(let{atom:a}of e)a.kind==="char"?i+=a.text:(l(),s+=n?a.delXml:a.xml);return l(),`<w:r>${o?`<w:rPr>${o}</w:rPr>`:""}${s}</w:r>`}var mt=e=>e.localName==="headerReference"||e.localName==="footerReference",pt=e=>e?O(e).filter(t=>!mt(t)&&t.localName!=="sectPrChange"):[];function qn(e,t){return pt(e).map(n=>t.serialize(n)).join("")}function ze(e,t,n,r="",o=false){let s=t??e;if(!s)return "";let i=t?n.revised:n.base,l=(e?O(e).filter(mt).map(f=>n.base.serialize(f)).join("")+(o?"":bs(e,n)):t&&!o?Es(t,n):"")+r,a=t||!o?qn(s,i):"",c="";if(n.detectFormatChanges&&(o||e&&t)){let f=e?qn(e,n.base):"";if(Hn(f)!==Hn(a)){let p=_t(pt(e),a?pt(s):[],n.base);p===null&&n.state.unrecordedProperties++,c=`<w:sectPrChange${n.attrs()}><w:sectPr>${p??f}</w:sectPr></w:sectPrChange>`;}}return `${i.raw({...s,children:[]}).replace(/\/>$/,">")}${l}${a}${c}</w:sectPr>`}function Es(e,t){let n="";for(let r of O(e).filter(mt)){let o=b(r,"type",ws)??"default",s=t.state.furnitureIds.get(b(r,"id",W)??"");if(s===void 0||!/^(default|first|even)$/.test(o)){t.state.unrecordedProperties++;continue}n+=`<w:${r.localName} xmlns:r="${W}" w:type="${o}" r:id="${_(s)}"/>`;}return n}function bs(e,t){let n=t.state,r=n.baseSectionIndex.get(e);if(r===void 0)return "";let o="";for(let{kind:s,type:i,id:l}of n.sectionReferences.get(r)??[])o+=`<w:${s}Reference xmlns:r="${W}" w:type="${i}" r:id="${_(l)}"/>`;return o}var Hn=e=>e.replace(/\sw:rsid\w*="[^"]*"/g,"");function Re(e,t,n,r){let o=e==="del"||e==="moveFrom"?t:n,s=o.markRPr;e!=="eq"?s=`<w:${e}${r.attrs()}/>${s}`:t&&r.detectFormatChanges&&t.markRPr!==o.markRPr&&(s+=`<w:rPrChange${r.attrs()}><w:rPr>${t.markRPr}</w:rPr></w:rPrChange>`);let i="";e==="eq"?i=ze(t?.sectPr??null,o.sectPr,r):o.sectPr&&(e==="ins"||e==="del")&&(i=ze(e==="del"?o.sectPr:null,e==="del"?null:o.sectPr,r));let l="";e==="eq"&&t&&r.detectFormatChanges&&t.pPr.join("")!==o.pPr.join("")&&(l=`<w:pPrChange${r.attrs()}><w:pPr>${t.pPr.join("")}</w:pPr></w:pPrChange>`);let a=`${o.pPr.join("")}${s?`<w:rPr>${s}</w:rPr>`:""}${i}${l}`;return a?`<w:pPr>${a}</w:pPr>`:""}function ge(e,t){return `<w:p>${e}${t}</w:p>`}function z(e,t,n){if(!e)return "";let r={...e,children:e.children.filter(o=>!(o.kind!=="textValue"&&n.has(o.localName)))};return se(t.serialize(r))}var Rs=new RegExp(`${dt}([^\xA7"]*)\xA7`,"g"),$s=new RegExp(`${ft}([^\xA7"]*)\xA7`,"g"),Ss=/<(?:[A-Za-z_][\w.-]*:)?docPr\b[^>]*?\sid="([^"]*)"/g,Cs=/<(?:[A-Za-z_][\w.-]*:)?anchor\b[^>]*?\srelativeHeight="([^"]*)"/g,Zn=4294967295,Yn=1024,qe=class{#e=new Set;#t=new Set;#n=1;constructor(t,n){for(let[r,o]of t.parts){if(n.has(r)||!o.root||!S(o.root))continue;let s=[o.root];for(let i=s.pop();i;i=s.pop()){let l=a=>i.attributes.find(c=>c.localName===a&&!c.namespaceUri)?.value;if(i.localName==="docPr"){let a=l("id");a!==void 0&&this.#e.add(a);}else if(i.localName==="anchor"){let a=l("relativeHeight");a!==void 0&&this.#t.add(a);}for(let a of i.children)S(a)&&s.push(a);}}}reserveWritten(t){for(let n of t.matchAll(Ss))this.#e.add(n[1]);for(let n of t.matchAll(Cs))this.#t.add(n[1]);}resolve(t){return t.replace(Rs,(n,r)=>{let o=K(r);if(Vn(o)&&!this.#e.has(o))return this.#e.add(o),_(o);for(;this.#e.has(String(this.#n));)this.#n++;let s=String(this.#n);return this.#e.add(s),s}).replace($s,(n,r)=>{let o=K(r);if(!Vn(o))return _(o);let s=Number(o);for(;this.#t.has(String(s))&&s+Yn<=Zn;)s+=Yn;let i=String(s);return this.#t.add(i),i})}},Vn=e=>/^\d{1,10}$/.test(e)&&Number(e)<=Zn;var _s="urn:schemas-microsoft-com:office:office";function Fs(e,t){let n=e.parts.get(t)?.root;if(!n||!S(n))return [];let r=[],o=[n];for(let s=o.pop();s;s=o.pop()){for(let i of s.attributes)(i.namespaceUri===W||i.namespaceUri===_s&&i.localName==="relid")&&r.push(i.value);for(let i of s.children)S(i)&&o.push(i);}return r}var Us=new RegExp(`${ct}([^\xA7"|]+)\\|([^\xA7"]+)\xA7`,"g"),Bs=new RegExp(`${D}NEW:([^\xA7"]+)\xA7`,"g"),Qn="http://schemas.openxmlformats.org/package/2006/relationships",er="application/vnd.openxmlformats-package.relationships+xml",tr="The original document declares no content type for relationship parts, which the compare result needs.";function nr(e,t){let n=store.withPart(e,t);return store.resolveContentTypeOf(n,t.name)===null?null:n}function rr(e,t,n){let r=store.relationshipsOf(e,t).find(s=>s.id===n);if(r)return {type:r.type,target:r.rawTarget,external:r.targetMode==="External"};let o=e.externalTargets.find(s=>s.ownerPart===t&&s.id===n);return o?{type:o.type,target:o.rawTarget,external:true}:null}function or(e,t){let n=store.resolveInternalTarget(e,t);return n.ok?n.partName:null}var Ls=8;function Ws(e,t){return e.parts.has(t)||e.partBytes.has(t)||e.partBytes.has(t.slice(1))}function js(e,t){let n=s=>(s?t.map(i=>i.replace("<Relationship ",`<${s}Relationship `)):t).join(""),r=/<\/((?:[\w.-]+:)?)Relationships>\s*$/;if(r.test(e))return e.replace(r,(s,i)=>`${n(i)}</${i}Relationships>`);let o=/<((?:[\w.-]+:)?)Relationships(\b[^>]*?)\s*\/>\s*$/;return o.test(e)?e.replace(o,(s,i,l)=>`<${i}Relationships${l}>${n(i)}</${i}Relationships>`):null}function ht(e,t){let n=e.slice(0,e.lastIndexOf("/")+1);return t.startsWith(n)?t.slice(n.length):t}var yt=class{constructor(t){this.base=t;}base;#e=new Map;#t=new Map;#n=1;add(t,n,r,o){let s=this.#t.get(t);s||(s=new Set([...store.relationshipsOf(this.base,t).map(a=>a.id),...this.base.externalTargets.filter(a=>a.ownerPart===t).map(a=>a.id),...Fs(this.base,t)]),this.#t.set(t,s));let i;do i=`rIdCmp${this.#n++}`;while(s.has(i));s.add(i);let l=this.#e.get(t)??[];return l.push(`<Relationship Id="${i}" Type="${_(n)}" Target="${_(r)}"${o?' TargetMode="External"':""}/>`),this.#e.set(t,l),i}entries(){return this.#e.entries()}};function ar(e,t,n){let r=e,o=new yt(e),s=e.mainDocumentPart,i=new Map;for(let p of n)p.isNew&&p.relType&&i.set(p.partName,o.add(s,p.relType,ht(s,p.partName),false));let l=new Map,a=1,c=(p,m)=>{let x=l.get(p);if(x)return x;let h=t.partBytes.get(p)??t.partBytes.get(p.slice(1));if(!h)return {failure:`The revised document refers to a missing part (${p}).`};if(m>Ls)return {failure:"The revised document nests related parts too deeply."};let y=/\.[A-Za-z0-9]+$/.exec(p)?.[0]??"",g;do g=`/word/media/compare${a++}${y}`;while(Ws(r,g)||ae(e,g));l.set(p,g),r=store.withBinaryPart(r,g,h,store.resolveContentTypeOf(t,p)??"application/octet-stream");let k=new Map;for(let N of store.relationshipsOf(t,p))k.set(N.id,{type:N.type,target:N.rawTarget,external:N.targetMode==="External"});for(let N of t.externalTargets)N.ownerPart!==p||k.has(N.id)||k.set(N.id,{type:N.type,target:N.rawTarget,external:true});let w=[...k].map(([N,C])=>({id:N,...C}));if(w.length===0)return g;let P="";for(let N of w){let C=N.target;if(!N.external){let I=or(p,N.target);if(I===null)return {failure:`The revised document has an invalid part name (${N.target}).`};let U=c(I,m+1);if(typeof U!="string")return U;C=ht(g,U);}P+=`<Relationship Id="${_(N.id)}" Type="${_(N.type)}" Target="${_(C)}"${N.external?' TargetMode="External"':""}/>`;}let R=store.relsPartNameFor(g),E=store.readOoxmlPart(`<Relationships xmlns="${Qn}">${P}</Relationships>`,{name:R,contentType:er});if(!E.ok)return {failure:`A relationship part is not valid XML (${E.reason}).`};let A=nr(r,E.part);return A?(r=A,g):{failure:tr}},d=new qe(e,new Set(n.map(p=>p.partName)));for(let p of n)d.reserveWritten(p.xml);for(let p of n){let m=new Map,x=null,h=d.resolve(p.xml.replace(Bs,(g,k)=>i.get(k)??""));if(h=h.replace(Us,(g,k,w)=>{let P=K(k),R=K(w),E=`${P}|${R}`,A=m.get(E);if(A)return A;let N=rr(t,P,R);if(!N)return rr(e,p.partName,R)&&(x=`The revised document refers to a missing relationship (${R}).`),_(R);let C=N.target;if(!N.external){let U=or(P,N.target),T=U===null?{failure:`The revised document has an invalid part name (${N.target}).`}:c(U,0);if(typeof T!="string")return x=T.failure,_(R);C=ht(p.partName,T);}let I=o.add(p.partName,N.type,C,N.external);return m.set(E,I),I}),x)return {ok:false,message:x};let y=store.readOoxmlPart(h,{name:p.partName,contentType:p.contentType});if(!y.ok)return {ok:false,message:`A compared story is not valid XML (${y.reason}).`};r=store.withPart(r,y.part),p.isNew&&(r=store.withContentTypeOverride(r,p.partName,p.contentType));}for(let[p,m]of o.entries()){let x=store.relsPartNameFor(p),h=r.parts.get(x),y=h?js(store.serializeOoxmlPart(h),m):`<Relationships xmlns="${Qn}">${m.join("")}</Relationships>`;if(y===null)return {ok:false,message:"A relationship part has no root to add relationships to."};let g=store.readOoxmlPart(y,{name:x,contentType:h?.contentType||er});if(!g.ok)return {ok:false,message:`A relationship part is not valid XML (${g.reason}).`};let k=nr(r,g.part);if(!k)return {ok:false,message:tr};r=k;}let u;try{u=store.writeOoxmlPackage(r);}catch(p){return {ok:false,message:`The compared package cannot be written (${p.message}).`}}let f=store.readOoxmlPackage(u);return f.ok?{ok:true,bytes:u,pkg:f.package}:{ok:false,message:`The compared package does not read back (${f.reason}).`}}var Pt="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function de(e,t,n,r){let o=oe(e.serialize({...t,children:[]})),s=n(true);return `${o.start.replace(/>$/,`${e.declarations()}>`)}${""}${s}${""}${o.end}`}function Q(e){let t=store.resolveHeaderFooterResolutionBySection(e),n=t[t.length-1];return n?xe(n):new Map}function xe(e){let t=new Map;for(let[n,r]of [["header",e.headers],["footer",e.footers]])for(let[o,s]of r)t.set(`${n}:${o}`,{kind:n,type:o,part:s.part,rId:s.rId});return t}function lr(e){let t=store.resolveHeaderFooterResolutionBySection(e),n=mr(e),r=new Set;for(let o of t.slice(0,-1))for(let s of xe(o).values()){if(n.has(s.part.name))continue;let i=store.serializeOoxmlPart(s.part).replace(/\sw:rsid\w*="[^"]*"/g,"");r.add(`${s.kind}:${s.type}:${i}`);}return r}var cr=new WeakMap;function Ot(e,t){let n=cr.get(e);if(n||cr.set(e,n=new WeakMap),n.has(t))return n.get(t);let r=zs(e,t);return n.set(t,r),r}function zs(e,t){let n=store.resolveHeaderFooterResolutionBySection(e),r=store.resolveHeaderFooterResolutionBySection(t);if(n.length!==r.length){let c=lr(e),d=lr(t);return c.size===d.size&&[...c].every(f=>d.has(f))?{pairs:[],added:[]}:null}let o=new Map,s=Q(e),i=Q(t);for(let[c,d]of s)o.set(d.part.name,i.get(c)?.part.name??"");let l=[],a=[];for(let c=0;c<n.length-1;c++){let d=xe(n[c]),u=xe(r[c]);for(let f of new Set([...d.keys(),...u.keys()])){let p=d.get(f),m=u.get(f);if(!p){a.push({index:c,ref:m});continue}let x=m?.part.name??"",h=o.get(p.part.name);if(h!==void 0){if(h!==x)return null;continue}o.set(p.part.name,x),l.push({base:p,revised:m});}}return {pairs:l,added:a}}function fr(e,t){let n=`/word/compare-${t.kind}-${t.type}.xml`;for(let r=2;ae(e,n);r++)n=`/word/compare-${t.kind}-${t.type}-${r}.xml`;return n}function Et(e,t){let n=new Map,r=new Map,o=Q(e),s=new Set;for(let[a,c]of Q(t)){let u=o.get(a)?.rId;if(!u){let f=fr(e,c);s.add(f),u=`${D}NEW:${f}\xA7`,r.has(c.part.name)||r.set(c.part.name,u);}n.has(c.part.name)||n.set(c.part.name,u);}let i=Ot(e,t);for(let{base:a,revised:c}of i?.pairs??[])c&&!n.has(c.part.name)&&n.set(c.part.name,a.rId);let l=[];for(let{index:a,ref:c}of i?.added??[]){if(r.has(c.part.name))continue;let d=`/word/compare-${c.kind}-${c.type}-s${a+1}`,u=`${d}.xml`;for(let p=2;ae(e,u)||s.has(u);p++)u=`${d}-${p}.xml`;s.add(u);let f=`${D}NEW:${u}\xA7`;r.set(c.part.name,f),n.has(c.part.name)||n.set(c.part.name,f),l.push({partName:u,ref:c});}return {ids:n,insertedIds:r,created:l}}function ur(e,t){let{insertedIds:n}=Et(e,t),r=new Map;for(let{index:o,ref:s}of Ot(e,t)?.added??[]){let i=r.get(o)??[];i.push({kind:s.kind,type:s.type,id:n.get(s.part.name)}),r.set(o,i);}return r}function pr(e,t){let n=Et(e,t).ids,r=new Map;for(let o of store.resolveHeaderFooterResolutionBySection(t))for(let s of xe(o).values()){let i=n.get(s.part.name);i!==void 0&&!r.has(s.rId)&&r.set(s.rId,i);}return r}function mr(e){return new Set([...Q(e).values()].map(t=>t.part.name))}function xt(e,t,n,r,o){let s=new H,i=new L("base",e,n?.part.name??e.mainDocumentPart,s),l=new L("revised",t,r?.part.name??t.mainDocumentPart,s),a=o.withSides(i,l),c=(n??r).part.root;return de(s,c,()=>B(n?F(n.part.root,i):[],r?F(r.part.root,l):[],a,!n||!r))}function gr(e,t,n){let r=Q(e),o=Q(t),s=[],i="";for(let a of new Set([...r.keys(),...o.keys()])){let c=r.get(a),d=o.get(a),u=xt(e,t,c,d,n);if(c)s.push({partName:c.part.name,contentType:c.part.contentType,xml:u,isNew:false});else {let f=d,p=fr(e,f);s.push({partName:p,contentType:f.part.contentType,xml:u,isNew:true,relType:`${Pt}/${f.kind}`}),i+=`<w:${f.kind}Reference xmlns:r="${W}" w:type="${f.type}" r:id="${D}NEW:${p}\xA7"/>`;}}let l=Ot(e,t);for(let{base:a,revised:c}of l?.pairs??[])s.push({partName:a.part.name,contentType:a.part.contentType,xml:xt(e,t,a,c,n),isNew:false});for(let{partName:a,ref:c}of Et(e,t).created)s.push({partName:a,contentType:c.part.contentType,xml:xt(e,t,void 0,c,n),isNew:true,relType:`${Pt}/${c.kind}`});return {outputs:s,extraRefs:i,unpaired:l===null}}var wt=new Set(["separator","continuationSeparator","continuationNotice"]);function hr(e){let t=new Set([e.mainDocumentPart,...mr(e)]);for(let n of ["footnote","endnote"]){let r=Nt(e,n);r&&t.add(r.name);}return [...t].flatMap(n=>e.parts.get(n)??[])}var Nt=(e,t)=>Y(e,`${t}s`);function dr(e,t){let n=new Map;for(let r of e?O(e.root):[]){if(r.localName!==t)continue;let o=b(r,"id");o!==void 0&&n.set(o,r);}return n}function yr(e,t,n,r){let o=r.state,s=new Map(o.notePairs.filter(P=>P.kind===n).map(P=>[P.base,P.revised])),i=new Set(o.deletedNotes.filter(P=>P.kind===n).map(P=>P.base)),l=o.newNotes.filter(P=>P.kind===n).map(P=>P.revised),a=Nt(e,n),c=Nt(t,n),d=new Map;if(s.size===0&&i.size===0&&l.length===0)return {output:null,ids:d};let u=a??c;if(!u)return {output:null,ids:d};let f=dr(a,n),p=dr(c,n),m=new H,x=new L("base",e,a?.name??e.mainDocumentPart,m),h=new L("revised",t,c?.name??t.mainDocumentPart,m),y=r.withSides(x,h),g=(P,R,E)=>{let A=oe(R.raw({...P,children:[]}));return {start:E===void 0?A.start:A.start.replace(/\bw:id="[^"]*"/,`w:id="${E}"`),end:A.end}},k=q(e,new Set([`${n}Reference`]),"id"),w=de(m,u.root,()=>{let P="",R=[],E=new Map;if(a)for(let N of O(a.root)){let C=b(N,"id"),I=b(N,"type"),U=C===void 0?void 0:s.get(C),T=U===void 0?void 0:p.get(U);if(N.localName!==n||I&&wt.has(I)||C===void 0)N.localName===n&&I&&C!==void 0&&!E.has(I)&&E.set(I,C),P+=x.serialize(N);else if(T){let v=g(N,x);P+=v.start+B(F(N,x),F(T,h),y)+v.end;}else if(i.has(C)){let v=g(N,x);P+=v.start+B(F(N,x),[],y,true)+v.end;}else P+=x.serialize(N);}else if(c){let N=O(c.root).filter(T=>{let v=b(T,"type");return v!==void 0&&wt.has(v)}),C=N.map(T=>b(T,"id")??""),I=G([...k,...C]),U=new Set(k);for(let T of N){let v=b(T,"id"),te=v!==void 0&&U.has(v)?I():v;if(te!==void 0){U.add(te),R.push(te);let Ge=b(T,"type");E.has(Ge)||E.set(Ge,te);}let Mt=h.serialize(T);P+=te===v?Mt:Mt.replace(/^(<[^>]*?\bw:id=")[^"]*"/,(Ge,Br)=>`${Br}${te}"`);}}let A=G([...f.keys(),...R,...k,...q(t,new Set([`${n}Reference`]),"id")]);for(let N of l){let C=p.get(N);if(!C||d.has(N))continue;let I=b(C,"type");if(I!==void 0&&wt.has(I)){let v=E.get(I);v===void 0?o.untracked++:d.set(N,v);continue}let U=A();d.set(N,U);let T=g(C,h,U);P+=T.start+B([],F(C,h),y,true)+T.end;}return P});return {output:{partName:a?.name??le(e,`/word/${n}s.xml`),contentType:a?.contentType??_e(`${n}s`),xml:w,isNew:!a,relType:`${Pt}/${n}s`},ids:d}}var qs=new Set(["commentRangeStart","commentRangeEnd","commentReference"]),Hs="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Xs="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",kr=new RegExp(`${D}CMT:([^\xA7"]+)\xA7`,"g"),He=e=>K(e),xr=e=>Y(e,"comments");function wr(e,t,n){let r=new Set;for(let y of n)for(let g of y.xml.matchAll(kr))r.add(He(g[1]));if(r.size===0)return [...n];let o=xr(e),s=xr(t),i=new Map;for(let y of s?O(s.root):[]){let g=y.localName==="comment"?b(y,"id"):void 0;g!==void 0&&r.has(g)&&i.set(g,y);}let l=[];for(let y of o?O(o.root):[]){let g=b(y,"id");g!==void 0&&l.push(g);}let a=G([...l,...q(e,qs,"id")],0),c=new Map;for(let y of i.keys())c.set(y,a());let d=n.map(y=>({...y,xml:y.xml.replace(new RegExp(`<w:comment(?:RangeStart|RangeEnd)\\b[^>]*w:id="${D}CMT:([^\xA7"]+)\xA7"[^>]*/>`,"g"),(g,k)=>c.has(He(k))?g:"").replace(new RegExp(`<w:r>(?:(?!</w:r>).)*?<w:commentReference\\b[^>]*w:id="${D}CMT:([^\xA7"]+)\xA7"[^>]*/></w:r>`,"gs"),(g,k)=>c.has(He(k))?g:"").replace(kr,(g,k)=>c.get(He(k))??"")}));if(c.size===0)return d;let u=new H,f=o?.name??le(e,"/word/comments.xml"),p=o?new L("base",e,o.name,u):null,m=new L("revised",t,s.name,u),x=(o??s).root,h=de(u,x,()=>{let y="";for(let g of o?O(o.root):[])y+=p.serialize(g);for(let[g,k]of i)y+=m.serialize(k).replace(/\bw:id="[^"]*"/,`w:id="${c.get(g)}"`).replace(/\s\w+:(?:paraId|textId)="[^"]*"/g,"");return y});return d.push({partName:f,contentType:o?.contentType||Xs,xml:h,isNew:!o,...o?{}:{relType:Hs}}),d}var $t=hr,Zs={footnoteReference:"footnote",endnoteReference:"endnote"};function Js(e){let t=new Map,n=e[0],r=n?[n.root]:[];for(;r.length>0;){let o=r.pop(),s=Zs[o.localName];if(s){let l=`${s}:${b(o,"id")??""}`;t.has(l)||t.set(l,t.size);continue}let i=O(o);for(let l=i.length-1;l>=0;l--)r.push(i[l]);}return t}function Qs(e,t){let n=e.root.localName==="footnotes"?"footnote":"endnote",r=a=>`${n}:${b(a,"id")??""}`,o=O(e.root),s=o.filter(a=>a.localName!==n),i=o.filter(a=>a.localName===n&&t.has(r(a))).sort((a,c)=>t.get(r(a))-t.get(r(c))),l=[...s,...i];return {...e,root:{...e.root,children:l}}}var Nr=e=>e.root.localName==="footnotes"||e.root.localName==="endnotes",bt="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function Or(e){let t=e.replace(/\s+/g," ").trim();if(!/^HYPERLINK\b/i.test(t))return t;let n=/\\l\s+"([^"]*)"/.exec(t);return n?`HYPERLINK \\l ${n[1]}`:"HYPERLINK"}var Er=new WeakMap;function ei(e){let t=Er.get(e);return t||Er.set(e,t=ni(e)),t}function Sr(e){let t="";for(let n of e.children)S(n)&&(n.localName==="t"?t+=n.children.map(r=>S(r)?"":r.value).join(""):t+=Sr(n));return t}function ti(e){let t=O(e).find(r=>r.localName==="sdtPr");if(!t||!O(t).some(r=>r.localName==="showingPlcHdr"))return false;let n=O(e).find(r=>r.localName==="sdtContent");return !n||Sr(n).trim()===""}function ni(e){let t=[],n=[],r=false,o=(a,c,d=false)=>{let u=a.localName,f=u==="p"?a:c,p=d||u==="sdt";if(u==="hyperlink"){let h=b(a,"anchor",bt);t.push(h===void 0?"HYPERLINK":`HYPERLINK \\l ${h}`);}else if(u==="fldChar"){let h=b(a,"fldCharType",bt);if(h==="begin")n.push({instr:"",index:t.length}),t.push("");else if(h==="end"){let y=n.pop();y&&(t[y.index]=Or(y.instr));}}let m=false,x=[];for(let h of a.children){if(!S(h)){x.push(h);continue}if(h.localName==="sdt"&&ti(h)){m=true,r=true;continue}if(h.localName==="instrText"||h.localName==="delInstrText"){let g=n[n.length-1];g&&(g.instr+=h.children.map(k=>S(k)?"":k.value).join("")),m=true;continue}if(h.localName==="fldSimple"){t.push(Or(b(h,"instr",bt)??""));let g=O(h).filter(w=>w.localName!=="fldData").map(w=>o(w,f,p)),k=f&&!p?ri(e,f,g):null;k?M(x,k):(M(x,g),r=true),m=true;continue}let y=o(h,f,p);y!==h&&(m=true),x.push(y);}return m?{...a,children:x}:a};if(!S(e.root))return {part:e,fields:""};let s=o(e.root,null);if(s===e.root)return {part:e,fields:Rt(t)};let i={...e,root:s};if(!r)return {part:i,fields:Rt(t)};let l=store.readOoxmlPart(store.serializeOoxmlPart(i),{name:e.name,contentType:e.contentType});return {part:l.ok?l.part:i,fields:Rt(t)}}function ri(e,t,n){if(!S(e.root))return null;let r={...t,children:n},o=O(e.root).find(c=>c.localName==="body"),s=o?[{...o,children:[r]}]:[r],i=store.readOoxmlPart(store.serializeOoxmlPart({...e,root:{...e.root,children:s}}),{name:e.name,contentType:e.contentType});if(!i.ok||!S(i.part.root))return null;let l=O(i.part.root)[0],a=l?.localName==="body"?O(l)[0]:l;return a?.localName==="p"?a.children.filter(c=>S(c)):null}function Rt(e){let t="",n=[];for(let r of e){if(r.startsWith("HYPERLINK")){if(r===t)continue;t=r;}n.push(r);}return n.join("|")}function we(e,t){let n=[],r=Js(e);for(let o of e){let{part:s,fields:i}=ei(Nr(o)?Qs(o,r):o),l=store.digestPart(s);if(!l)continue;let a=Nr(s),c=l.paragraphs.filter(d=>t==="properties"&&!a||d.text.trim()!=="").map(d=>oi(d,t));l.paragraphs.every(d=>d.text.trim()==="")||n.push(`${c.join(`
|
|
2
|
+
`)}${i?`
|
|
3
|
+
${i}`:""}`);}return n.sort().join(`
|
|
4
|
+
|
|
5
|
+
`)}function oi(e,t){if(t==="text")return e.text.replace(/\s+/g," ").trim();let n=e.paragraphProperties.filter(r=>r!=="rPr");return `${e.text}${n.join("|")}`}var si=new Set(["ins","del","moveFrom","moveTo","rPrChange","pPrChange","sectPrChange","tblPrChange","tblPrExChange","trPrChange","tcPrChange","tblGridChange","numberingChange","cellIns","cellDel","cellMerge"]),ii="http://schemas.openxmlformats.org/wordprocessingml/2006/main";function ee(e){return S(e)?e.namespaceUri===ii&&si.has(e.localName)?true:e.children.some(t=>S(t)&&ee(t)):false}var ai=new Set(["locked","bound"]),br="undecided";function Rr(e,t,n){let r=[];for(let o of $t(e)){if(!ee(o.root)){r.push(o);continue}r.push(Cr(o,t,n));}return r}function Cr(e,t,n){let r=store.applyTreeOp(e,{op:t});r.ok?ee(r.part.root)&&n.add(br):n.add(ai.has(r.reason)?r.reason:br);let o=r.ok?r.part:e,s=store.readOoxmlPart(store.serializeOoxmlPart(o),{name:o.name,contentType:o.contentType});return s.ok?s.part:o}var li=new TextEncoder;function Xe(e,t,n,r=new Set){let o=e;if(t){let l=new Map(e.parts);n?.name!==e.mainDocumentPart&&(n=void 0),n&&l.set(e.mainDocumentPart,n);let a=new Set;for(let c of store.resolveHeaderFooterResolutionBySection(e))for(let d of [c.headers,c.footers])for(let u of d.values())a.add(u.part.name);n||a.add(e.mainDocumentPart);for(let c of a){let d=l.get(c);!d||!ee(d.root)||l.set(c,Cr(d,t,r));}o={...e,parts:l};}let s=new Map,i=l=>{let a=s.get(l);if(a===void 0){let c=we([l],"text");a=c===""?"":store.sha256Bytes(li.encode(c)),s.set(l,a);}return a};return store.resolveHeaderFooterResolutionBySection(o).map(l=>{let a=[];for(let[c,d]of [["header",l.headers],["footer",l.footers]])for(let[u,f]of d){let p=i(f.part);p!==""&&a.push(`${c}:${u}=${p}`);}return a.sort().join("|")}).join(`
|
|
6
|
+
`)}function $r(e,t){let n=0;for(;n<e.length&&e[n]===t[n];)n++;return `${JSON.stringify(e.slice(Math.max(0,n-40),n+80))} vs ${JSON.stringify(t.slice(Math.max(0,n-40),n+80))}`}function Tr(e,t,n){let r=new Set,o=Rr(e,"acceptAllRevisions",r),s=Rr(e,"rejectAllRevisions",r),i=f=>{let p=we(o,f),m=we(s,f),x=we($t(n),f),h=we($t(t),f);return {accept:p===x,reject:m===h,detail:p!==x?`accept: ${$r(p,x)}`:m!==h?`reject: ${$r(m,h)}`:void 0}},l=()=>{let f=Xe(e,"acceptAllRevisions",o[0],r)===Xe(n),p=Xe(e,"rejectAllRevisions",s[0],r)===Xe(t),m=f?p?void 0:"reject":"accept";return {accept:f,reject:p,detail:m&&`${m}: a section shows other headers or footers`}},a=i("text"),c=a.accept&&a.reject?l():a,d=c.accept&&c.reject?i("properties"):c,u=c.detail??d.detail;return {accept:c.accept,reject:c.reject,properties:d.accept&&d.reject,...r.size>0?{guard:[...r].sort().join(",")}:{},...u===void 0?{}:{detail:u}}}var pi=1e5,mi=3e6,gi=new Set(["document","hdr","ftr","footnotes","endnotes","comments","numbering","styles"]);function Cl(e,t,n={}){let r=store.readOoxmlPackage(e);if(!r.ok)return {ok:false,code:"invalidOriginal",message:`The original document cannot be read (${r.reason}).`};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,code:"invalidRevised",message:`The revised document cannot be read (${o.reason}).`};let s=ki(r.package,o.package,n);return s.ok?{ok:true,bytes:s.changed?s.bytes:e,revisionCount:s.revisionCount,changed:s.changed}:s}var hi=.1,yi=.7;function ki(e,t,n={},r=false,o){let s=Ni(n);if(s)return {ok:false,code:"invalidOptions",message:s};try{return xi(e,t,n,r,o)}catch(i){if(i instanceof RangeError)return Fr;throw i}}var Fr={ok:false,code:"tooLarge",message:"The documents are too large to compare."};function xi(e,t,n,r,o){let s={...n,date:n.date??new Date},i=Mr(e,t,s,r,o);if(!i.ok||i.revisionCount>0)return i;if(![...e.parts.values()].some(l=>ee(l.root))){let l=Mr(e,e,s,true);if(l.ok&&Oi(i.package,l.package))return {...i,package:e,changed:false}}return i}function Mr(e,t,n,r,o){if(Ci(e))return {ok:false,code:"protected",message:"The original document is protected against edits. A compare writes some differences, such as style definitions or content control properties, without tracked changes."};let s=_r(e),i=_r(t);if(s.blocks+i.blocks>pi||s.text+i.text>mi)return Fr;o?.("comparing",hi);let l=Dr(e),a=Dr(t);if(!l)return Ar("original");if(!a)return Ar("revised");let c=l.parts.get(l.mainDocumentPart),d=a.parts.get(a.mainDocumentPart),u=c&&$(c.root,"body"),f=d&&$(d.root,"body");if(!c||!u)return {ok:false,code:"invalidOriginal",message:"The original document has no main story."};if(!d||!f)return {ok:false,code:"invalidRevised",message:"The revised document has no main story."};let p=Sn(l,a),m=new je;for(let[T,v]of pr(l,a))m.furnitureIds.set(T,v);m.sectionReferences=ur(l,a),store.collectSectionPropertyNodes(c.root).forEach((T,v)=>{T&&m.baseSectionIndex.set(T,v);});let x=new H,h=new L("base",l,l.mainDocumentPart,x),y=new L("revised",a,a.mainDocumentPart,x),g=new Ke(m,n.authorName?.trim()?n.authorName:Fi(a),n.removeDateAndTime?void 0:_i(n.date??new Date),n.detectFormatChanges??true,h,y),k=$(u,"sectPr"),w=$(f,"sectPr"),P=bi(x,u),R=g,E={outputs:[],extraRefs:"",unpaired:false},A=de(x,c.root,()=>{let T=B(F(u,h),F(f,y),g);E=gr(l,a,R);let v=ze(k??null,w??null,g,E.extraRefs,true);return `${P.start}${T}${v}${P.end}`}),N=[{partName:c.name,contentType:c.contentType,xml:A,isNew:false},...E.outputs,...p];for(let T of ["footnote","endnote"]){let v=yr(l,a,T,g);v.output&&N.push(v.output),Ri(N,T,v.ids);}if(g.state.untracked>0)return {ok:false,code:"unsupportedContent",reason:"untrackedContent",message:"The documents differ in block content that has no tracked-change form, such as an embedded file chunk."};if(E.unpaired)return {ok:false,code:"unsupportedContent",reason:"headerFooter",message:"A header or footer of an earlier section differs, and that section has no matching section in the other document that uses the same headers and footers."};if(g.state.unrecordedProperties>0)return {ok:false,code:"unsupportedContent",reason:"unrecordedSettings",message:"The revised document adds section or table settings, such as page borders, that a tracked change cannot restore on reject."};o?.("checking",yi);let C=ar(l,a,wr(l,a,N));if(!C.ok)return {ok:false,code:"unsupportedContent",reason:"packageStructure",message:C.message};let I=Tr(C.pkg,l,a),U=/\b(?:locked|bound)\b/.test(I.guard??"");return !r&&U?{ok:false,code:"unsupportedContent",reason:"lockedContent",message:"The documents differ inside a content control that is locked or bound to data. Changes there cannot be accepted or rejected."}:!r&&(!I.accept||!I.reject||I.guard)?{ok:false,code:"unsupportedContent",reason:"unverified",message:`The compare result does not reproduce both documents (${I.detail??I.guard??""}).`}:{ok:true,bytes:C.bytes,package:C.pkg,revisionCount:g.revisionCount===0?0:Pi(C.pkg),changed:true}}var wi=new Set(["document","hdr","ftr","footnotes","endnotes"]);function Pi(e){let t=0;for(let n of e.parts.values()){let r=n.root;(wi.has(r.localName)&&r.namespaceUri===Pe||n.name===e.mainDocumentPart)&&(t+=store.revisionItemsOf(n).length);}return t}function Ni(e){let{authorName:t,detectFormatChanges:n,removeDateAndTime:r,date:o}=e;return t!==void 0&&typeof t!="string"?"authorName must be a string.":n!==void 0&&typeof n!="boolean"?"detectFormatChanges must be a boolean.":r!==void 0&&typeof r!="boolean"?"removeDateAndTime must be a boolean.":o!==void 0&&(Object.prototype.toString.call(o)!=="[object Date]"||Number.isNaN(o.getTime()))?"date must be a valid Date.":null}function Oi(e,t){if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||e.partBytes.size!==t.partBytes.size)return false;for(let[n,r]of e.parts){let o=t.parts.get(n);if(!o||o.contentType!==r.contentType||!store.ooxmlTreesEqual(r,o))return false}for(let[n,r]of e.partBytes){if(e.parts.has(n)||n.endsWith(".rels")||n==="/[Content_Types].xml")continue;let o=t.partBytes.get(n);if(!o||!Ei(r,o))return false}return Ir(e)===Ir(t)&&JSON.stringify(e.externalTargets)===JSON.stringify(t.externalTargets)}function Ei(e,t){if(e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}function Ir(e){return JSON.stringify([...e.relationships.entries()].filter(([,t])=>t.length>0).sort(([t],[n])=>t<n?-1:t>n?1:0).map(([t,n])=>[t,n.map(r=>[r.id,r.type,r.rawTarget,r.targetMode])]))}function bi(e,t){let n=e.serialize({...t,children:[]}),r=/^<([^\s/>]+)([^>]*?)\/?>/.exec(n);return {start:`<${r[1]}${r[2]}>`,end:`</${r[1]}>`}}function Ri(e,t,n){for(let r=0;r<e.length;r++){let o=e[r].xml.replace(Xn,(s,i,l)=>i===t?n.get(K(l))??_(K(l)):s);e[r]={...e[r],xml:o};}}var $i=new Set(["0","false","off"]),Si=new Set(["readOnly","comments","forms","trackedChanges"]);function Ci(e){let t=Ti(e);return t!==void 0&&Si.has(t)}function Ti(e){let t=vi(e),n=t&&O(t.root).find(o=>o.localName==="documentProtection"&&o.namespaceUri===Pe);if(!n)return;let r=b(n,"enforcement",Pe);if(!(r===void 0||$i.has(r)))return b(n,"edit",Pe)??""}var Pe="http://schemas.openxmlformats.org/wordprocessingml/2006/main",vi=e=>Y(e,"settings");function Ar(e){return {ok:false,code:"unsupportedContent",reason:"unresolvedRevisions",message:`The ${e} document holds tracked changes that cannot be accepted, so its final state is unknown.`}}function Dr(e){let t=null;for(let[n,r]of e.parts){if(!ee(r.root))continue;let o=store.applyTreeOp(r,{op:"acceptAllRevisions"});if(!o.ok){if(o.reason==="unknown-revision")continue;return null}t??=new Map(e.parts),t.set(n,o.part);}return t?{...e,parts:t}:e}var Mi=new Set(["p","tbl","tr","tc","sdt","num","abstractNum","style"]),Ii=12,Ai=new Set(["tab","ptab","br","cr","sym","noBreakHyphen","softHyphen","fldChar","drawing","pict","object","footnoteReference","endnoteReference","commentReference"]);function _r(e){let t={blocks:0,text:0};for(let n of e.parts.values()){let r=n.root;(gi.has(r.localName)&&r.namespaceUri===Pe||n.name===e.mainDocumentPart)&&Di(r,t);}return t}function Di(e,t){let n=[...e.children];for(;n.length>0;){let r=n.pop();if(r.kind==="textValue"){t.text+=r.value.length;continue}Mi.has(r.localName)?t.blocks++:Ai.has(r.localName)?t.text++:r.localName==="r"&&(t.text+=Ii),M(n,r.children);}}function _i(e){return `${e.toISOString().slice(0,16)}:00Z`}function Fi(e){for(let t of e.parts.values())if(t.contentType.endsWith("core-properties+xml"))for(let n of ["lastModifiedBy","creator"]){let o=O(t.root).find(s=>s.localName===n)?.children.map(s=>S(s)?"":s.value).join("").trim();if(o)return o}return "Comparison"}var Ui="docx-editor.compare/1",Bi={reading:true,comparing:true,checking:true,applying:true},Li={invalidOptions:true,invalidOriginal:true,invalidRevised:true,tooLarge:true,protected:true,unsupportedContent:true},vt=e=>typeof e=="object"&&e!==null,Ur=(e,t)=>typeof t=="string"&&Object.hasOwn(e,t),Tt=e=>Object.prototype.toString.call(e)==="[object Uint8Array]",vl=e=>vt(e)&&e.protocol===Ui;function Ml(e){let t=e;return t.type==="compare"&&Tt(t.original)&&Tt(t.revised)&&vt(t.options)}function Wi(e){if(!vt(e)||typeof e.ok!="boolean")return false;if(!e.ok)return Ur(Li,e.code);let t=e.revisionCount;return typeof e.changed=="boolean"&&(e.changed?Tt(e.bytes):e.bytes===null)&&typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function Il(e){let t=e;switch(t.type){case "progress":{let n=t.fraction;return Ur(Bi,t.phase)&&typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=1}case "result":return Wi(t.result);case "error":return typeof t.message=="string";default:return false}}
|
|
7
|
+
exports.a=Cl;exports.b=ki;exports.c=Ui;exports.d=vl;exports.e=Ml;exports.f=Il;
|