@docx-editor.dev/core 2.14.1 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +6 -5
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +16 -10
- package/dist/binding.js +1 -1
- package/dist/chunk-24APKZAN.cjs +11 -0
- package/dist/chunk-2YH4MSHX.cjs +2 -0
- package/dist/chunk-5Y7AADI6.js +1 -0
- package/dist/chunk-AREFLNUP.js +11 -0
- package/dist/chunk-AS7YZNQE.cjs +2 -0
- package/dist/chunk-AVGCKH6A.cjs +20 -0
- package/dist/chunk-CDYVDQRI.cjs +5 -0
- package/dist/chunk-FGBADUSK.cjs +1 -0
- package/dist/chunk-HOEWFH5U.cjs +1 -0
- package/dist/chunk-KFELX7CN.js +2 -0
- package/dist/{chunk-OKEDGR65.js → chunk-KXPVOPR5.js} +1 -1
- package/dist/chunk-LGFKIF4M.cjs +1 -0
- package/dist/chunk-M52QXFKI.js +1 -0
- package/dist/chunk-MNUKSXRO.js +1 -0
- package/dist/chunk-PBOIGBDO.js +2 -0
- package/dist/chunk-PMHGONET.cjs +1 -0
- package/dist/chunk-PXKZUTHX.cjs +2 -0
- package/dist/chunk-Q4AB7E4O.cjs +1 -0
- package/dist/chunk-QJYH6AYD.js +1 -0
- package/dist/chunk-QRC37MWG.cjs +20 -0
- package/dist/chunk-RJSB6RJ7.js +20 -0
- package/dist/chunk-SB54HLFJ.js +20 -0
- package/dist/chunk-VP7SDFCM.js +1 -0
- package/dist/chunk-XCESLTJL.js +2 -0
- package/dist/{chunk-KIAP7PFQ.cjs → chunk-YL4Q5LZP.cjs} +1 -1
- package/dist/chunk-Z4527AXR.js +5 -0
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +4 -3
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +4 -3
- package/dist/contracts/editor.d.ts +7 -7
- package/dist/contracts/interaction.d.ts +7 -7
- package/dist/contracts/modules.d.ts +8 -7
- package/dist/{custom-node-writes-DntmaAVW.d.ts → custom-node-writes-C9ArIlJh.d.ts} +2 -2
- package/dist/{editor-a6VvsfYU.d.ts → editor-sRxrFJd8.d.ts} +29 -21
- package/dist/editor.cjs +1 -1
- package/dist/editor.d.ts +27 -58
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -0
- package/dist/export.d.ts +337 -0
- package/dist/export.js +2 -0
- package/dist/font-resolver-BYEHQGTw.d.ts +251 -0
- package/dist/headless-document-view-DELC4E5v.d.ts +134 -0
- package/dist/hf-references-DTrHkktY.d.ts +70 -0
- package/dist/{index-C5ZnSRkF.d.ts → index-C3Gvq4jN.d.ts} +55 -246
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +18 -16
- package/dist/index.js +1 -1
- package/dist/{shaped-measurer-CFPnXFs9.d.cts → layout-shaping-DoGR5cf8.d.ts} +86 -12
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +1106 -729
- package/dist/layout.js +1 -1
- package/dist/{note-properties-CDFiNXcD.d.ts → note-properties-DSe8igrz.d.ts} +2 -2
- package/dist/{omml-equation-BY49UOIF.d.ts → omml-equation-BpRmfDAf.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +6 -6
- package/dist/output.js +1 -1
- package/dist/{protocol-gOY5GA8K.d.cts → protocol-DZzKxH5r.d.ts} +18 -12
- package/dist/{review-items-CCS1h93f.d.ts → review-items-DYRx187i.d.ts} +2 -2
- package/dist/{review-reads-BjZYeMd4.d.ts → review-reads-LbGUdNzn.d.ts} +22 -25
- package/dist/{revision-projection-BeXVrSSV.d.ts → revision-projection-DHRJH48u.d.ts} +1 -1
- package/dist/{semantic-cell-selection-BK91NCCG.d.ts → semantic-cell-selection-BXVWCBYm.d.ts} +4 -4
- package/dist/{semantic-interaction-BmQ7h2cq.d.ts → semantic-interaction-DZsDmPg5.d.ts} +1 -1
- package/dist/{semantic-paint-WJD2KeG1.d.ts → semantic-paint-f7SqN4oW.d.ts} +2 -2
- package/dist/{semantic-records-BpozY7-j.d.cts → semantic-records-EIdwId-a.d.ts} +301 -205
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +15 -65
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-D6HzlPR4.d.ts → tree-op-types-egdarvH_.d.ts} +7 -3
- package/dist/{tree-package-fragment-CWFjgH6a.d.ts → tree-package-fragment-DjkH4ESI.d.ts} +4 -70
- package/dist/{tree-session-contract-B2HfGt79.d.ts → tree-session-contract-CGOOgPjW.d.ts} +29 -23
- package/dist/{tree-store-APgWx6qn.d.ts → tree-store-DKJB0IcA.d.ts} +2 -2
- package/package.json +7 -2
- package/dist/automation.d.cts +0 -82
- package/dist/binding.d.cts +0 -153
- package/dist/chunk-2PIHW2QM.cjs +0 -1
- package/dist/chunk-2QTY5S6T.js +0 -1
- package/dist/chunk-4Z5MODAE.cjs +0 -2
- package/dist/chunk-5TKAPFZT.cjs +0 -2
- package/dist/chunk-DRQHIQ4R.cjs +0 -1
- package/dist/chunk-F2K6SDHA.cjs +0 -20
- package/dist/chunk-FBA57EUJ.js +0 -2
- package/dist/chunk-KTAQ7BRQ.js +0 -20
- package/dist/chunk-LBAHXZCU.cjs +0 -5
- package/dist/chunk-MCDUQYWP.js +0 -5
- package/dist/chunk-MQP26KCF.js +0 -1
- package/dist/chunk-NDJGSR6M.cjs +0 -19
- package/dist/chunk-NJNFJPGB.cjs +0 -11
- package/dist/chunk-O5M4CR4P.cjs +0 -2
- package/dist/chunk-UKUOZXUD.js +0 -19
- package/dist/chunk-VQ4R5LTU.js +0 -2
- package/dist/chunk-ZBEJHJN2.js +0 -11
- package/dist/chunk-ZVTW7RGD.js +0 -2
- package/dist/collaboration/replication.d.cts +0 -216
- package/dist/collaboration.d.cts +0 -176
- package/dist/contracts/document.d.cts +0 -273
- package/dist/contracts/editor.d.cts +0 -10
- package/dist/contracts/interaction.d.cts +0 -10
- package/dist/contracts/modules.d.cts +0 -130
- package/dist/contracts/types.d.cts +0 -562
- package/dist/custom-node-writes-C46r3_5O.d.cts +0 -310
- package/dist/document-properties-D6Ahr8D6.d.cts +0 -28
- package/dist/document-properties-D6Ahr8D6.d.ts +0 -28
- package/dist/editor-AJ06hyyg.d.cts +0 -1994
- package/dist/editor.d.cts +0 -393
- package/dist/failure-BnGjoXf0.d.cts +0 -64
- package/dist/index-Cbw4lkOt.d.cts +0 -3391
- package/dist/index.d.cts +0 -23
- package/dist/layout.d.cts +0 -2486
- package/dist/note-properties-Y6qYh2Hv.d.cts +0 -67
- package/dist/omml-equation-DB8d-jCq.d.cts +0 -84
- package/dist/output.d.cts +0 -74
- package/dist/protocol-BsmQgblT.d.ts +0 -1358
- package/dist/review-items-CaAkgi5s.d.cts +0 -360
- package/dist/review-reads-DEsV0OOW.d.cts +0 -163
- package/dist/revision-projection-DXbrfNGD.d.cts +0 -156
- package/dist/semantic-cell-selection-BMhku3B1.d.cts +0 -451
- package/dist/semantic-interaction-DUAnxbgf.d.cts +0 -160
- package/dist/semantic-paint-DufNL1Zr.d.cts +0 -247
- package/dist/semantic-records-92UnKeU_.d.ts +0 -2821
- package/dist/shaped-measurer-BWbindlI.d.ts +0 -168
- package/dist/store.d.cts +0 -2500
- package/dist/tree-op-types-BUulYD5y.d.cts +0 -3099
- package/dist/tree-package-fragment-Dhyw7oPm.d.cts +0 -732
- package/dist/tree-session-contract-BY9xd7s_.d.cts +0 -613
- package/dist/tree-store-DEEQ9wz_.d.cts +0 -416
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk24APKZAN_cjs=require('./chunk-24APKZAN.cjs'),fflate=require('fflate');function G(e){return e.kind!=="textValue"}function F(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunk24APKZAN_cjs.ca}function re(e,t){for(let n of e)t(n),n.kind!=="textValue"&&re(n.children,t);}function he(e){if(e.kind==="textValue")return `T(${e.value})`;if(e.namespaceUri===chunk24APKZAN_cjs.ca&&e.localName.startsWith("rsid"))return "";let t=e.attributes.filter(r=>!r.localName.startsWith("rsid")&&!(r.namespaceUri===chunk24APKZAN_cjs.fa&&(r.localName==="paraId"||r.localName==="textId"))).map(r=>`${r.namespaceUri}|${r.localName}=${r.value}`).sort().join(","),n=e.children.map(he).join("");return `E(${e.namespaceUri}:${e.localName}[${t}]{${n}})`}function it(e){return `S[${e.attributes.filter(n=>n.localName!=="styleId").map(n=>`${n.localName}=${n.value}`).sort().join(",")}]${e.children.map(he).join("")}`}function wt(e){let t=[],n=new Map,r=new Set,o=null;if(e&&G(e.root))for(let i of e.root.children){if(!G(i))continue;if(F(i,"docDefaults")){o=i;continue}if(!F(i,"style"))continue;t.push(i);let a=chunk24APKZAN_cjs.Fe(i,"styleId");a&&n.set(a,i);let s=i.children.find(d=>F(d,"name")),l=s?chunk24APKZAN_cjs.Fe(s,"val"):void 0;l&&r.add(l);}return {part:e,styles:t,docDefaults:o,byId:n,names:r}}function St(e,t,n){let r=new Map;if(!e)return r;let o=e.children.find(a=>F(a,t));if(!o||!G(o))return r;let i=o.children.find(a=>F(a,n));if(!i||!G(i))return r;for(let a of i.children)a.kind!=="textValue"&&r.set(a.localName,a);return r}function dn(e,t,n,r){let o=t;for(let i=0;i<16&&o;i+=1){let a=e.byId.get(o);if(!a)return false;let s=a.children.find(d=>F(d,n));if(s&&G(s)&&s.children.some(d=>d.kind!=="textValue"&&d.localName===r))return true;let l=a.children.find(d=>F(d,"basedOn"));o=l?chunk24APKZAN_cjs.Fe(l,"val"):void 0;}return false}function Ni(e,t){for(let n of e.styles){if(chunk24APKZAN_cjs.Fe(n,"type")!==t)continue;let r=chunk24APKZAN_cjs.Fe(n,"default");if(r==="1"||r==="true")return chunk24APKZAN_cjs.Fe(n,"styleId")}}function Tt(e,t){let n=e.children.find(r=>F(r,t));return n&&G(n)?n:null}var Si=new Map(["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"].map((e,t)=>[e,t])),Ti=new Map(["rStyle","rFonts","b","bCs","i","iCs","caps","smallCaps","strike","dstrike","outline","shadow","emboss","imprint","noProof","snapToGrid","vanish","webHidden","color","spacing","w","kern","position","sz","szCs","highlight","u","effect","bdr","shd","fitText","vertAlign","rtl","cs","em","lang","eastAsianLayout","specVanish","oMath","rPrChange"].map((e,t)=>[e,t]));function cn(e,t,n){let r=St(t.docDefaults,"rPrDefault","rPr"),o=St(n.docDefaults,"rPrDefault","rPr"),i=St(t.docDefaults,"pPrDefault","pPr"),a=St(n.docDefaults,"pPrDefault","pPr"),s=(f,x,p)=>{let k=Ni(f,"paragraph"),w=k?f.byId.get(k):void 0;if(!w)return k;for(let[T,R]of [["rPr",x],["pPr",p]]){let S=Tt(w,T);if(S)for(let D of S.children)D.kind!=="textValue"&&R.set(D.localName,D);}return k};s(t,r,i),s(n,o,a);let l=new Map;for(let[f,x]of r){let p=o.get(f);(!p||he(p)!==he(x))&&l.set(f,x);}let d=new Map;for(let[f,x]of i){if(f==="sectPr")continue;let p=a.get(f);(!p||he(p)!==he(x))&&d.set(f,x);}if(l.size===0&&d.size===0)return e;let c=0,u=()=>`fragment#materialized-${c++}`,m=f=>{let x=p=>p.kind==="textValue"?{id:u(),kind:"textValue",value:p.value}:{...p,id:u(),children:p.children.map(x)};return x(f)},g=(f,x,p)=>{if(p.length===0)return f;let k=Tt(f,x);if(k){let T=x==="rPr"?Ti:Si,R=[...k.children];for(let D of p){let V=D.kind==="textValue"?Number.MAX_SAFE_INTEGER:T.get(D.localName)??Number.MAX_SAFE_INTEGER,Q=R.length;for(let A=0;A<R.length;A+=1){let B=R[A];if(B.kind==="textValue")continue;let L=T.get(B.localName);if(L!==void 0&&L>V){Q=A;break}}R.splice(Q,0,D);}let S={...k,children:R};return {...f,children:f.children.map(D=>D===k?S:D)}}let w={id:u(),kind:x==="rPr"?"runProperties":"paragraphProperties",namespaceUri:chunk24APKZAN_cjs.ca,localName:x,prefix:"w",namespaceBindings:[],attributes:[],children:p};return {...f,children:[w,...f.children]}},y=f=>{let x=Tt(f,"pPr"),p=x?.children.find(S=>F(S,"pStyle")),k=p?chunk24APKZAN_cjs.Fe(p,"val"):void 0,w=[];for(let[S,D]of d)x?.children.some(Q=>Q.kind!=="textValue"&&Q.localName===S)||k&&dn(t,k,"pPr",S)||w.push(m(D));let T=S=>{if(S.kind==="textValue")return S;if(S.kind==="run"){let V=Tt(S,"rPr"),Q=V?.children.find(L=>F(L,"rStyle")),A=Q?chunk24APKZAN_cjs.Fe(Q,"val"):void 0,B=[];for(let[L,X]of l)V?.children.some(M=>M.kind!=="textValue"&&M.localName===L)||A&&dn(t,A,"rPr",L)||k&&dn(t,k,"rPr",L)||B.push(m(X));return g(S,"rPr",B)}if(S.kind==="paragraphProperties"||S.kind==="runProperties")return S;let D=S.children.map(T);return D.some((V,Q)=>V!==S.children[Q])?{...S,children:D}:S};return T(g(f,"pPr",w))},P=f=>{if(f.kind==="textValue")return f;if(f.kind==="paragraph")return y(f);let x=f.children.map(P);return x.some((p,k)=>p!==f.children[k])?{...f,children:x}:f};return e.map(P)}function wi(e,t){return {...e,children:t}}function Ei(e,t){return e.kind!=="textValue"&&e.localName===t&&e.namespaceUri===chunk24APKZAN_cjs.ca}var Ci=new Set(["commentRangeStart","commentRangeEnd"]),Mi=new Set(["altChunk","subDoc"]);function Di(e){return e.kind==="run"&&e.children.some(t=>t.kind==="commentReference")}var Ai=new Set(["DDE","DDEAUTO","INCLUDE","INCLUDEPICTURE","INCLUDETEXT","IMPORT","LINK","DATABASE","AUTOTEXT","AUTOTEXTLIST","GOTOBUTTON","MACROBUTTON","PRINT","ADDIN"]);function xo(e){if(e===void 0)return false;let t=e.trim().replace(/^"+/,"").split(/\s+/,1)[0]??"";return Ai.has(t.toUpperCase())}function _i(e){if(e.kind!=="run")return null;for(let t of e.children)if(t.kind==="fldChar"){let n=chunk24APKZAN_cjs.Fe(t,"fldCharType");return n==="separate"||n==="end"?n:"begin"}return null}function Ui(e){if(e.kind!=="run")return null;let t="",n=false;for(let r of e.children)if(r.kind==="instrText"){n=true;for(let o of r.children)o.kind==="textValue"&&(t+=o.value);}return n?t:null}function Fi(e){let t=[],n=new Set,r=i=>{if(i.dangerous){for(let a of i.machinery)n.add(a);for(let a of i.instr)n.add(a);for(let a of i.preResult)n.add(a);}},o=i=>{if(i.kind!=="textValue"){if(i.kind==="run"){let a=_i(i);if(a==="begin"){t.push({dangerous:false,afterSeparate:false,machinery:[i.id],instr:[],preResult:[]});return}let s=t[t.length-1];if(s){if(a==="separate"){s.afterSeparate=true,s.machinery.push(i.id);return}if(a==="end"){s.machinery.push(i.id),t.pop(),r(s);return}let l=Ui(i);if(l!==null){s.instr.push(i.id),xo(l)&&(s.dangerous=true);return}s.afterSeparate||s.preResult.push(i.id);return}return}for(let a of i.children)o(a);}};for(let i of e)o(i);for(;t.length>0;){let i=t.pop();i.dangerous=true,r(i);}return n}function Li(e,t){if(e.kind==="textValue")return e;if(e.namespaceUri===chunk24APKZAN_cjs.ca&&(Ci.has(e.localName)||e.localName==="sectPr"||Mi.has(e.localName))||Di(e)||t.has(e.id))return "drop";if(Ei(e,"fldSimple")&&xo(chunk24APKZAN_cjs.Fe(e,"instr")))return mn(e.children,t);let n=mn(e.children,t);return n.length===e.children.length&&n.every((r,o)=>r===e.children[o])?e:wi(e,n)}function mn(e,t){let n=[];for(let r of e){let o=Li(r,t);o!=="drop"&&(Array.isArray(o)?n.push(...o):n.push(o));}return n}function un(e){let t=Fi(e);return mn(e,t)}var Te="http://schemas.openxmlformats.org/officeDocument/2006/relationships",$i="http://schemas.openxmlformats.org/package/2006/relationships",Bi="http://schemas.openxmlformats.org/drawingml/2006/main",md="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",ud="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",pd="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",fd="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",gd="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",hd="application/vnd.openxmlformats-package.relationships+xml",Hi=`${Te}/styles`,ji=`${Te}/numbering`,yd=`${Te}/footnotes`,xd=`${Te}/endnotes`,kd=`${Te}/officeDocument`,Wi=`${Te}/theme`;function de(e){return e.kind!=="textValue"}function ko(e,t){return {...e,children:t}}function Be(e,t){if(t(e),e.kind!=="textValue")for(let n of e.children)Be(n,t);}var Vi=new Set(["pStyle","rStyle","tblStyle"]);function Pd(e,t){for(let n of e)Be(n,r=>{if(r.kind!=="textValue"&&Vi.has(r.localName)&&r.namespaceUri===chunk24APKZAN_cjs.ca){let o=chunk24APKZAN_cjs.Fe(r,"val");o&&t.add(o);}});}function Od(e,t){for(let n of e)Be(n,r=>{if(r.kind!=="textValue"&&r.localName==="numId"&&r.namespaceUri===chunk24APKZAN_cjs.ca){let o=chunk24APKZAN_cjs.Fe(r,"val");o&&t.add(o);}});}function Id(e,t){for(let n of e)Be(n,r=>{if(r.kind!=="textValue")for(let o of r.attributes)o.namespaceUri===Te&&o.value.length>0&&t.add(o.value);});}function ye(e){return /^\d+$/.test(e)?e.replace(/^0+(?=\d)/,""):e}function Oo(e,t){let n={footnote:new Set,endnote:new Set},r=[],o=i=>{for(let a of i)Be(a,s=>{if(s.kind!=="noteReference")return;let l=s.localName==="footnoteReference"?"footnote":"endnote",d=chunk24APKZAN_cjs.Fe(s,"id");if(d===void 0)return;let c=ye(d);n[l].has(c)||(n[l].add(c),r.push({kind:l,id:c}));});};for(o(e);r.length>0;){let i=r.pop(),a=t(i.kind,i.id);a!==null&&o([a]);}return n}function pn(e,t,n){if(e.kind==="textValue")return e;let r=[],o=false;for(let i of e.children){if(i.kind!=="textValue"&&i.namespaceUri===chunk24APKZAN_cjs.ca&&(i.localName==="footnoteReference"||i.localName==="endnoteReference")){let l=i.localName==="footnoteReference"?t:n,d=chunk24APKZAN_cjs.Fe(i,"id");if(i.kind!=="noteReference"||d===void 0||!l.has(ye(d))){o=true;continue}}let s=pn(i,t,n);s!==i&&(o=true),r.push(s);}return o?{...e,children:r}:e}function Ki(e,t){for(let n of chunk24APKZAN_cjs._b(e,t)){if(n.type!==Hi||n.targetMode==="External")continue;let r=chunk24APKZAN_cjs.w(n.ownerPart,n.rawTarget);if(r.ok)return e.parts.get(r.partName)??null}return e.parts.get("/word/styles.xml")??null}function Io(e,t,n){for(let r of chunk24APKZAN_cjs._b(e,t)){if(r.type!==n||r.targetMode==="External")continue;let o=chunk24APKZAN_cjs.w(r.ownerPart,r.rawTarget);if(o.ok)return e.parts.get(o.partName)??null}return null}function Rd(e,t){let n=Ki(e,t),r=new Map,o=[],i=null;if(n&&de(n.root))for(let a of n.root.children){if(!de(a))continue;if(a.localName==="docDefaults"&&a.namespaceUri===chunk24APKZAN_cjs.ca){i=a;continue}if(a.localName!=="style"||a.namespaceUri!==chunk24APKZAN_cjs.ca)continue;let s=chunk24APKZAN_cjs.Fe(a,"styleId");s&&r.set(s,a),(chunk24APKZAN_cjs.Fe(a,"default")==="1"||chunk24APKZAN_cjs.Fe(a,"default")==="true")&&o.push(a);}return {part:n,byId:r,defaults:o,docDefaults:i}}var zi=new Set(["basedOn","link","next"]);function bd(e,t){let n=new Set,r=[...t];for(let a of e.defaults){let s=chunk24APKZAN_cjs.Fe(a,"styleId");s&&r.push(s);}let o=[];for(;r.length>0;){let a=r.pop();if(n.has(a))continue;n.add(a);let s=e.byId.get(a);if(s){o.push(s);for(let l of s.children)if(de(l)&&zi.has(l.localName)&&l.namespaceUri===chunk24APKZAN_cjs.ca){let d=chunk24APKZAN_cjs.Fe(l,"val");d&&r.push(d);}}}if(!e.part||!de(e.part.root))return o;let i=new Map;return e.part.root.children.forEach((a,s)=>i.set(a,s)),o.sort((a,s)=>(i.get(a)??0)-(i.get(s)??0))}function vd(e,t,n){let r=Io(e,t,ji)??e.parts.get("/word/numbering.xml")??null;if(!r||!de(r.root)||n.size===0)return {part:r,nums:[],abstracts:[]};let o=[],i=new Set;for(let s of r.root.children){if(!de(s)||s.localName!=="num"||s.namespaceUri!==chunk24APKZAN_cjs.ca)continue;let l=chunk24APKZAN_cjs.Fe(s,"numId");if(!(!l||!n.has(l))){o.push(s);for(let d of s.children)if(de(d)&&d.localName==="abstractNumId"){let c=chunk24APKZAN_cjs.Fe(d,"val");c&&i.add(c);}}}let a=[];for(let s of r.root.children){if(!de(s)||s.localName!=="abstractNum"||s.namespaceUri!==chunk24APKZAN_cjs.ca)continue;let l=chunk24APKZAN_cjs.Fe(s,"abstractNumId");l&&i.has(l)&&a.push(s);}return {part:r,nums:o,abstracts:a}}var Et={latin:null,eastAsia:null,cs:null};function Nd(e,t){let n=Io(e,t,Wi);if(!n)return {major:Et,minor:Et};let r={major:{...Et},minor:{...Et}};return Be(n.root,o=>{if(o.kind==="textValue"||o.namespaceUri!==Bi||o.localName!=="majorFont"&&o.localName!=="minorFont")return;let i=o.localName==="majorFont"?r.major:r.minor;for(let a of o.children){if(!de(a))continue;let s=chunk24APKZAN_cjs.Fe(a,"typeface");s&&(a.localName==="latin"?i.latin=s:a.localName==="ea"?i.eastAsia=s:a.localName==="cs"&&(i.cs=s));}}),{major:r.major,minor:r.minor}}function Gi(e,t){let n=t.startsWith("major")?e.major:e.minor;return t.endsWith("EastAsia")?n.eastAsia??n.latin:t.endsWith("Bidi")?n.cs??n.latin:n.latin}var Xi=[["asciiTheme","ascii"],["hAnsiTheme","hAnsi"],["eastAsiaTheme","eastAsia"],["cstheme","cs"]],Po=new Set(["themeColor","themeTint","themeShade","themeFill","themeFillTint","themeFillShade"]);function Yi(e,t){if(e.kind==="textValue")return e;let n=e.attributes;if(e.localName==="rFonts"&&e.namespaceUri===chunk24APKZAN_cjs.ca){let i=[],a=new Map;for(let s of e.attributes){let l=Xi.find(([d])=>d===s.localName);if(l&&s.namespaceUri===chunk24APKZAN_cjs.ca){let d=Gi(t,s.value);d&&a.set(l[1],d);continue}i.push(s);}for(let[s,l]of a)i.some(d=>d.localName===s)||i.push({kind:"genericExtension",namespaceUri:chunk24APKZAN_cjs.ca,localName:s,prefix:"w",value:l});n=i;}else e.attributes.some(i=>Po.has(i.localName)&&i.namespaceUri===chunk24APKZAN_cjs.ca&&e.attributes.some(a=>a.localName==="val"))&&(n=e.attributes.filter(i=>!(Po.has(i.localName)&&i.namespaceUri===chunk24APKZAN_cjs.ca)));let r=e.children.map(i=>Yi(i,t)),o=r.some((i,a)=>i!==e.children[a]);return n===e.attributes&&!o?e:{...e,attributes:n,children:r}}function Sd(e,t,n){return {id:e,name:e,contentType:t,root:n}}function Td(e,t){if(e.root.kind==="document"){let r=e.root.children.find(i=>i.kind==="body"),o=r&&de(r)?ko(r,t):{id:"fragment#body",kind:"body",namespaceUri:chunk24APKZAN_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return ko(e.root,[o])}let n={id:"fragment#body",kind:"body",namespaceUri:chunk24APKZAN_cjs.ca,localName:"body",prefix:"w",namespaceBindings:[],attributes:[],children:t};return {id:"fragment#document",kind:"document",namespaceUri:chunk24APKZAN_cjs.ca,localName:"document",prefix:"w",namespaceBindings:de(e.root)?e.root.namespaceBindings:[],attributes:[],children:[n]}}function wd(e){let t=e.map(n=>{let r=n.targetMode==="External"?' TargetMode="External"':"";return `<Relationship Id="${chunk24APKZAN_cjs.N(n.id)}" Type="${chunk24APKZAN_cjs.N(n.type)}" Target="${chunk24APKZAN_cjs.N(n.rawTarget)}"${r}/>`}).join("");return `<Relationships xmlns="${$i}">${t}</Relationships>`}function Ed(e,t){let n=t;for(;e.has(`rId${n}`);)n+=1;return `rId${n}`}function Cd(e){let t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}var Ro="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function q(e,t,n,r){return {...e,attributes:e.attributes.map(o=>o.localName===n&&o.namespaceUri===t?{...o,value:r}:o)}}var qi=new Set(["pStyle","rStyle","tblStyle","basedOn","link","next","styleLink","numStyleLink"]),fn=chunk24APKZAN_cjs.df,xe=new Map;function He(e,t){let n=t.styleIds??xe,r=t.numIds??xe,o=t.relIds??xe,i=t.footnoteIds??xe,a=t.endnoteIds??xe,s=t.bookmarkIds??xe,l=t.sdtIds??xe,d=t.revisionIds??xe,c=t.docPrIds??xe,u=(m,g)=>{if(m.kind==="textValue")return m;let y=m;if(m.namespaceUri===chunk24APKZAN_cjs.ca&&qi.has(m.localName)){let p=chunk24APKZAN_cjs.Fe(m,"val"),k=p!==void 0?n.get(p):void 0;k!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"val",k));}if(F(m,"numId")){let p=chunk24APKZAN_cjs.Fe(m,"val"),k=p!==void 0?r.get(p):void 0;k!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"val",k));}if(m.kind==="noteReference"){let p=m.localName==="footnoteReference"?i:a,k=chunk24APKZAN_cjs.Fe(m,"id"),w=k!==void 0?p.get(ye(k)):void 0;w!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"id",w));}if(m.kind==="bookmarkStart"||m.kind==="bookmarkEnd"){let p=chunk24APKZAN_cjs.Fe(m,"id"),k=p!==void 0?s.get(p):void 0;k!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"id",k));}if(F(m,"id")&&g==="sdtPr"){let p=chunk24APKZAN_cjs.Fe(m,"val"),k=p!==void 0?l.get(p):void 0;k!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"val",k));}if(fn(m)){let p=chunk24APKZAN_cjs.Fe(m,"id"),k=p!==void 0?d.get(p):void 0;k!==void 0&&(y=q(y,chunk24APKZAN_cjs.ca,"id",k));}if(m.kind==="drawingDocPr"){let p=m.attributes.find(w=>w.localName==="id"&&w.namespaceUri==="")?.value,k=p!==void 0?c.get(p):void 0;k!==void 0&&(y=q(y,"","id",k));}for(let p of y.attributes){if(p.namespaceUri!==Ro)continue;let k=o.get(p.value);k!==void 0&&k!==p.value&&(y=q(y,Ro,p.localName,k));}let P=m.localName,f=y.children.map(p=>u(p,P));return y!==m||f.some((p,k)=>p!==y.children[k])?{...y,children:f}:m};return u(e,"")}function bo(e,t,n){let r=e,o=n.get(e)??2;for(;t.has(r);)r=`${e}${o}`,o+=1;return n.set(e,o),r}function vo(e,t,n){let r=`${e} (pasted)`,o=n.get(e)??2;for(;t.has(r);)r=`${e} (pasted ${o})`,o+=1;return n.set(e,o),r}var Ji=1e5;function No(e){let t=chunk24APKZAN_cjs.Fb(),n=Qi(e,t),r=Zi(e,t),o=es(e,t);return !n||!r||!o?null:{bookmarkIds:n,revisionIds:r,docPrIds:o}}function gn(e,t,n,r){if(e)return chunk24APKZAN_cjs.Hb(t,e,r);let o=n;return ()=>String(o++)}function So(e,t){if(e.add(t),!/^\d{1,10}$/.test(t))return;let n=Number(t);n<=chunk24APKZAN_cjs.Db&&e.add(String(n));}function To(e,t){if(t===void 0)return e;let n=Number(t);return Number.isInteger(n)&&n>e?n:e}function Qi(e,t){let n=new Map;if(e.fragmentBookmarkIds.length===0)return n;let r=0,o=new Set;for(let a of [e.ownerPart,...e.notesParts])re([a.root],s=>{if(s.kind!=="bookmarkStart"&&s.kind!=="bookmarkEnd")return;let l=chunk24APKZAN_cjs.Fe(s,"id");l!==void 0&&(So(o,l),s.kind==="bookmarkStart"&&(r=To(r,l)));});let i=gn(t,o,r+1,chunk24APKZAN_cjs.Db);for(let a of e.fragmentBookmarkIds){if(n.has(a))continue;let s=i();if(s===null)return null;n.set(a,s);}return n}function Zi(e,t){let n=new Map;if(!e.hasRevision)return n;let r=0,o=new Set;for(let s of [e.ownerPart,...e.notesParts]){let l=s===e.ownerPart;re([s.root],d=>{if(!chunk24APKZAN_cjs.df(d))return;let c=chunk24APKZAN_cjs.Fe(d,"id");c!==void 0&&So(o,c),l&&(r=To(r,c));});}let i=gn(t,o,r+1,chunk24APKZAN_cjs.Db),a=false;return re(e.travelling,s=>{if(a||!chunk24APKZAN_cjs.df(s))return;let l=chunk24APKZAN_cjs.Fe(s,"id");if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}function es(e,t){let n=new Map;if(!e.hasDocPr)return n;let{used:r}=chunk24APKZAN_cjs.Jb(e.pkg),o=Ji;if(!t){let s=chunk24APKZAN_cjs.Kb(e.pkg);s.ok&&(o=s.id);}let i=gn(t,r,o,chunk24APKZAN_cjs.Ib),a=false;return re(e.travelling,s=>{if(a||s.kind==="textValue"||s.kind!=="drawingDocPr")return;let l=s.attributes.find(c=>c.localName==="id"&&c.namespaceUri==="")?.value;if(l===void 0||n.has(l))return;let d=i();d===null?a=true:n.set(l,d);}),a?null:n}var we="http://schemas.openxmlformats.org/officeDocument/2006/relationships",ts=`${we}/hyperlink`,wo=`${we}/image`,Ct=`${we}/numbering`,hn=`${we}/styles`,Eo="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",Co="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function st(e,t,n,r){for(let o of chunk24APKZAN_cjs._b(e,t)){if(o.type!==n||o.targetMode==="External")continue;let i=chunk24APKZAN_cjs.w(o.ownerPart,o.rawTarget);if(i.ok){let a=e.parts.get(i.partName);if(a)return a}}return e.parts.get(r)??null}function yn(e,t){let n=0;return re([e],r=>{let o=t(r);if(o===void 0)return;let i=Number(o);Number.isInteger(i)&&i>n&&(n=i);}),n}function Mt(e,t,n,r){if(n.length===0)return e;let o=chunk24APKZAN_cjs.Aa(t,"paste"),i=n.map(d=>chunk24APKZAN_cjs.Je(d,o)),a=chunk24APKZAN_cjs.th(t,i),s=r??a.root.children.length,l=chunk24APKZAN_cjs.Ga(a,a.root.id,s,i,{deferValidation:true});return l.ok?chunk24APKZAN_cjs.Yb(e,l.part):null}function Mo(e){let t=new Set;return re(e,n=>{if(n.kind!=="textValue")for(let r of n.attributes)r.namespaceUri===we&&r.value.length>0&&t.add(r.value);}),t}function Do(e,t){if(t.size===0)return [...e];let n=o=>{if(o.kind==="textValue")return o;if(o.kind==="drawing"){let a=false;return re([o],s=>{if(s.kind!=="textValue")for(let l of s.attributes)l.namespaceUri===we&&t.has(l.value)&&(a=true);}),a?null:o}if(o.kind==="hyperlink"){let a=o.attributes.find(s=>s.namespaceUri===we)?.value;if(a!==void 0&&t.has(a))return r(o.children)}let i=r(o.children);return i.length===o.children.length&&i.every((a,s)=>a===o.children[s])?o:{...o,children:i}};function r(o){let i=[];for(let a of o){let s=n(a);s!==null&&(Array.isArray(s)?i.push(...s):i.push(s));}return i}return r(e)}var ns=new Set(["image/png","image/jpeg","image/gif","image/bmp","image/webp"]),Ao={"image/jpg":"image/jpeg","image/x-ms-bmp":"image/bmp","image/x-bmp":"image/bmp"};function rs(e,t){let n=chunk24APKZAN_cjs.lb(e);return n==="unknown"||(Object.hasOwn(Ao,t)?Ao[t]:t)!==n||ns.has(n)&&!chunk24APKZAN_cjs.Lb(e,n)?null:n}function _o(e,t,n){let r=t.parts.get(t.mainDocumentPart);if(!r)return {ok:false,reason:"no-fragment-document"};if(!e.parts.has(n))return {ok:false,reason:"no-target-part"};let o=r.root.kind==="document"?r.root.children.find(h=>h.kind==="body"):null;if(!o||!G(o))return {ok:false,reason:"no-fragment-document"};let i=un(o.children.filter(h=>h.kind==="paragraph"||h.kind==="table"||h.kind==="contentControl"));if(i.length===0)return {ok:false,reason:"no-fragment-document"};let a=e,s=st(t,t.mainDocumentPart,Ct,"/word/numbering.xml"),l=new Map,d=[],c=[];if(s&&G(s.root)){let h=new Map,I=[];for(let E of s.root.children)if(G(E))if(F(E,"abstractNum")){let H=chunk24APKZAN_cjs.Fe(E,"abstractNumId");H&&h.set(H,E);}else F(E,"num")&&I.push(E);let O=st(a,a.mainDocumentPart,Ct,"/word/numbering.xml"),N=new Map,C=new Map;if(O&&G(O.root)){for(let E of O.root.children)if(G(E)&&F(E,"abstractNum")){let H=chunk24APKZAN_cjs.Fe(E,"abstractNumId");H&&C.set(H,E);}for(let E of O.root.children){if(!G(E)||!F(E,"num"))continue;let H=chunk24APKZAN_cjs.Fe(E,"numId");if(!H)continue;let ae=E.children.find($=>F($,"abstractNumId")),z=ae?chunk24APKZAN_cjs.Fe(ae,"val"):void 0,pe=z?C.get(z):void 0;N.set(`${pe?it(pe):"none"}::${E.children.filter($=>F($,"lvlOverride")).map(he).join("")}`,H);}}let _=(O?yn(O.root,E=>E.kind!=="textValue"&&F(E,"abstractNum")?chunk24APKZAN_cjs.Fe(E,"abstractNumId"):void 0):0)+1,j=(O?yn(O.root,E=>E.kind!=="textValue"&&F(E,"num")?chunk24APKZAN_cjs.Fe(E,"numId"):void 0):0)+1,te=new Map;for(let E of I){let H=chunk24APKZAN_cjs.Fe(E,"numId");if(!H)continue;let ae=E.children.find(Pe=>F(Pe,"abstractNumId")),z=ae?chunk24APKZAN_cjs.Fe(ae,"val"):void 0,pe=z?h.get(z):void 0,$=`${pe?it(pe):"none"}::${E.children.filter(Pe=>F(Pe,"lvlOverride")).map(he).join("")}`,K=N.get($);if(K!==void 0){l.set(H,K);continue}let Z=z?te.get(z):void 0;Z===void 0&&pe&&z&&(Z=String(_++),te.set(z,Z),c.push(q(pe,chunk24APKZAN_cjs.ca,"abstractNumId",Z)));let Me=String(j++);l.set(H,Me);let Re=q(E,chunk24APKZAN_cjs.ca,"numId",Me);if(Z!==void 0){let Pe=Re.children.map(De=>F(De,"abstractNumId")?q(De,chunk24APKZAN_cjs.ca,"val",Z):De);Re={...Re,children:Pe};}d.push(Re),N.set($,Me);}}let u=wt(st(t,t.mainDocumentPart,hn,"/word/styles.xml")),m=st(a,a.mainDocumentPart,hn,"/word/styles.xml"),g=wt(m),y=new Map,P=[],f=new Set(g.byId.keys()),x=new Set(g.names),p=new Map,k=new Map,w=new Map,T=(h,I)=>{let O=w.get(h);return O===void 0&&(O=it(I),w.set(h,O)),O},R=h=>({...h,attributes:h.attributes.filter(I=>!(I.localName==="default"&&I.namespaceUri===chunk24APKZAN_cjs.ca))});for(let h of u.styles){let I=chunk24APKZAN_cjs.Fe(h,"styleId");if(!I)continue;let O=g.byId.get(I),N=it(He(h,{styleIds:y,numIds:l}));if(O&&T(I,O)===N){y.set(I,I);continue}if(!O){y.set(I,I),f.add(I),P.push(R(h));continue}let C=bo(`${I}Pasted`,f,p);f.add(C),y.set(I,C),P.push(R(q(h,chunk24APKZAN_cjs.ca,"styleId",C)));}let S=P.map(h=>{let I=h.children.find(_=>F(_,"name")),O=I?chunk24APKZAN_cjs.Fe(I,"val"):void 0;if(!O||!x.has(O))return O&&x.add(O),h;let N=vo(O,x,k);x.add(N);let C=h.children.map(_=>F(_,"name")?q(_,chunk24APKZAN_cjs.ca,"val",N):_);return {...h,children:C}}),D=null,V=1,Q=()=>{if(D)return D;let h=new Map;for(let[I,O]of a.partBytes){let N=I.startsWith("/")?I:`/${I}`;if(!N.startsWith("/word/media/"))continue;h.set(chunk24APKZAN_cjs.a(O),N);let C=/\/image(\d+)\./.exec(N);C&&(V=Math.max(V,Number(C[1])+1));}return D=h,h},A=new Map,B=h=>{let I=A.get(h);if(!I){I=new Map;for(let O of chunk24APKZAN_cjs._b(a,h)){if(O.targetMode==="External"||O.type!==wo)continue;let N=chunk24APKZAN_cjs.w(O.ownerPart,O.rawTarget);N.ok&&I.set(N.partName,O.id);}A.set(h,I);}return I},L=(h,I)=>{let O=h.lastIndexOf("."),N=O===-1?"":h.slice(O+1);return /^[A-Za-z0-9]{1,8}$/.test(N)?N.toLowerCase():I==="image/jpeg"?"jpeg":I==="image/gif"?"gif":"png"},X=(h,I,O)=>{let N=new Map,C=new Set,_=B(I),j=[],te=new Set,E=[],H=[],ae=new Map,z=[],pe=t.relationships.get(h)??[];for(let $ of pe){if(!O.has($.id))continue;if($.targetMode==="External"){if($.type===ts){let Ae=chunk24APKZAN_cjs.Jd(a,$.rawTarget,I);Ae?(a=Ae.pkg,N.set($.id,Ae.relationshipId)):C.add($.id);}else C.add($.id);continue}let K=chunk24APKZAN_cjs.w($.ownerPart,$.rawTarget);if(!K.ok){C.add($.id);continue}let Z=t.partBytes.get(K.partName)??t.partBytes.get(K.partName.replace(/^\//,"")),Me=(chunk24APKZAN_cjs.$b(t,K.partName)??"").toLowerCase();if(!Z||!Me.startsWith("image/")){C.add($.id);continue}let Re=rs(Z,Me);if(Re===null){C.add($.id);continue}let Pe=Re,De=Q(),er=chunk24APKZAN_cjs.a(Z),ne=De.get(er);if(!ne){let Ae=L(K.partName,Pe),vi=ht=>a.partBytes.has(ht)||a.partBytes.has(ht.slice(1))||a.parts.has(ht)||te.has(ht),Vt=`/word/media/image${V}.${Ae}`;for(;vi(Vt);)V+=1,Vt=`/word/media/image${V}.${Ae}`;V+=1,ne=Vt,j.push({partName:ne,bytes:Z,contentType:Pe}),te.add(ne),De.set(er,ne);}let bi=ne.startsWith("/word/")?ne.slice(6):ne,tr=_.get(ne);if(tr!==void 0){N.set($.id,tr);continue}let gt=ae.get(ne);gt===void 0&&(gt=E.length,ae.set(ne,gt),E.push(bi),H.push(ne)),z.push({recordId:$.id,index:gt});}if(j.length>0&&(a=chunk24APKZAN_cjs.Pb(a,j)),E.length>0){let $=chunk24APKZAN_cjs.cc(chunk24APKZAN_cjs.dc(a,I),I,E.map(K=>[wo,K]));if($.ok){a=$.pkg,$.ids.forEach((K,Z)=>{_.set(H[Z],K);});for(let K of z)N.set(K.recordId,$.ids[K.index]);}else for(let K of z)C.add(K.recordId);}return {relIdMap:N,dropRelIds:C}},oe=X(t.mainDocumentPart,n,Mo(i));i=Do(i,oe.dropRelIds);let M=new Map,qe=new Map,J=[],jt=(h,I)=>G(h)&&h.namespaceUri===chunk24APKZAN_cjs.ca&&h.localName===I,Kn={},Ii=Oo(i,(h,I)=>{let O=Kn[h];if(O===void 0){O=new Map,Kn[h]=O;let N=chunk24APKZAN_cjs.Xe(t,h);if(N&&G(N.root))for(let C of N.root.children){if(!jt(C,h))continue;let _=chunk24APKZAN_cjs.Fe(C,"id");if(_===void 0)continue;let j=ye(_);O.has(j)||O.set(j,C);}}return O.get(I)??null});for(let h of ["footnote","endnote"]){let I=h==="footnote"?M:qe,O=Ii[h];if(O.size===0)continue;let N=chunk24APKZAN_cjs.Xe(t,h);if(!N||!G(N.root))continue;let C=chunk24APKZAN_cjs.mf(a,h);if(!C.ok||!C.package)return {ok:false,reason:"merge-refused"};a=C.package;let _=chunk24APKZAN_cjs.Xe(a,h);if(!_)return {ok:false,reason:"merge-refused"};let j=yn(_.root,E=>jt(E,h)?chunk24APKZAN_cjs.Fe(E,"id"):void 0)+1,te=[];for(let E of N.root.children){if(!jt(E,h))continue;let H=chunk24APKZAN_cjs.Fe(E,"id"),ae=chunk24APKZAN_cjs.Fe(E,"type");if(ae==="separator"||ae==="continuationSeparator"||H===void 0||!O.has(ye(H))||I.has(ye(H)))continue;let z=String(j++);I.set(ye(H),z),te.push(q(E,chunk24APKZAN_cjs.ca,"id",z));}te.length>0&&J.push({kind:h,fragmentPartName:N.name,bodies:un(te)});}let Ce=a.parts.get(n),zn=[...i,...J.flatMap(h=>h.bodies)],Gn=[],Wt=new Set,Xn=false,Yn=false,Je=new Map;re(zn,h=>{if(h.kind!=="textValue"){if(h.kind==="bookmarkStart"||h.kind==="bookmarkEnd"){let I=chunk24APKZAN_cjs.Fe(h,"id");if(I!==void 0&&Gn.push(I),h.kind==="bookmarkStart"){let O=chunk24APKZAN_cjs.Fe(h,"name");O&&Wt.add(O);}return}if(fn(h)){Xn=true;return}if(h.kind==="drawingDocPr"){Yn=true;return}if(h.kind==="contentControlProperties")for(let I of h.children){if(!F(I,"id"))continue;let O=chunk24APKZAN_cjs.Fe(I,"val");if(O!==void 0&&!Je.has(O)){let N=0,C=`${O}:${Je.size}`;for(let _=0;_<C.length;_+=1)N=N*31+C.charCodeAt(_)>>>0;Je.set(O,String(N%2147483647||1));}}}});let ft=No({pkg:a,ownerPart:Ce,notesParts:J.map(h=>chunk24APKZAN_cjs.Xe(a,h.kind)).filter(h=>h!==null),travelling:zn,fragmentBookmarkIds:Gn,hasRevision:Xn,hasDocPr:Yn});if(!ft)return {ok:false,reason:"merge-refused"};let qn=ft.bookmarkIds,Jn=ft.revisionIds,Qn=ft.docPrIds;if(Wt.size>0){let h=new Set;if(re([Ce.root],I=>{if(I.kind!=="textValue"&&I.kind==="bookmarkStart"){let O=chunk24APKZAN_cjs.Fe(I,"name"),N=chunk24APKZAN_cjs.Fe(I,"id");O&&N!==void 0&&Wt.has(O)&&h.add(N);}}),h.size>0){let I=N=>{if(N.kind==="textValue")return N;let C=[],_=false;for(let j of N.children){if((j.kind==="bookmarkStart"||j.kind==="bookmarkEnd")&&h.has(chunk24APKZAN_cjs.Fe(j,"id")??"")){_=true;continue}let te=I(j);te!==j&&(_=true),C.push(te);}return _?{...N,children:C}:N},O=I(Ce.root);O!==Ce.root&&(chunk24APKZAN_cjs.Ea(Ce.root,O),a=chunk24APKZAN_cjs.Yb(a,{...Ce,root:O}));}}let Zn=h=>pn(h,M,qe);for(let h of J){h.bodies=h.bodies.map(Zn);let I=chunk24APKZAN_cjs.Xe(a,h.kind);if(!I)return {ok:false,reason:"merge-refused"};let O=X(h.fragmentPartName,I.name,Mo(h.bodies)),N=Do(h.bodies,O.dropRelIds);N=[...cn(N,u,g)],N=N.map(_=>He(_,{styleIds:y,numIds:l,relIds:O.relIdMap,footnoteIds:M,endnoteIds:qe,bookmarkIds:qn,sdtIds:Je,revisionIds:Jn,docPrIds:Qn}));let C=Mt(a,a.parts.get(I.name),N);if(!C)return {ok:false,reason:"merge-refused"};a=C;}if(S.length>0){let h=S.map(O=>He(O,{styleIds:y,numIds:l}));if(!m){let O=chunk24APKZAN_cjs.ta(`<w:styles xmlns:w="${chunk24APKZAN_cjs.ca}"></w:styles>`,{name:"/word/styles.xml",contentType:Co});if(!O.ok)return {ok:false,reason:"merge-refused"};a=chunk24APKZAN_cjs.fc(a,"/word/styles.xml",O.part.root,Co);let N=chunk24APKZAN_cjs.ec(chunk24APKZAN_cjs.dc(a,a.mainDocumentPart),a.mainDocumentPart,hn,"styles.xml");if(!N.ok)return {ok:false,reason:"merge-refused"};a=N.pkg,m=a.parts.get("/word/styles.xml")??null;}if(!m)return {ok:false,reason:"merge-refused"};let I=Mt(a,a.parts.get(m.name),h);if(!I)return {ok:false,reason:"merge-refused"};a=I,g=wt(a.parts.get(m.name)??null);}if(c.length>0||d.length>0){let h=st(a,a.mainDocumentPart,Ct,"/word/numbering.xml");if(!h){let _=chunk24APKZAN_cjs.ta(`<w:numbering xmlns:w="${chunk24APKZAN_cjs.ca}"></w:numbering>`,{name:"/word/numbering.xml",contentType:Eo});if(!_.ok)return {ok:false,reason:"merge-refused"};a=chunk24APKZAN_cjs.fc(a,"/word/numbering.xml",_.part.root,Eo);let j=chunk24APKZAN_cjs.ec(chunk24APKZAN_cjs.dc(a,a.mainDocumentPart),a.mainDocumentPart,Ct,"numbering.xml");if(!j.ok)return {ok:false,reason:"merge-refused"};a=j.pkg,h=a.parts.get("/word/numbering.xml")??null;}if(!h)return {ok:false,reason:"merge-refused"};let I=a.parts.get(h.name),O=I.root.children.findIndex(_=>F(_,"num")),N=c.map(_=>He(_,{styleIds:y,numIds:l})),C=Mt(a,I,N,O===-1?void 0:O);if(!C)return {ok:false,reason:"merge-refused"};if(a=C,C=Mt(a,a.parts.get(h.name),d),!C)return {ok:false,reason:"merge-refused"};a=C;}let Ri=[...cn(i,u,g)].map(Zn).map(h=>He(h,{styleIds:y,numIds:l,relIds:oe.relIdMap,footnoteIds:M,endnoteIds:qe,bookmarkIds:qn,sdtIds:Je,revisionIds:Jn,docPrIds:Qn}));return {ok:true,pkg:a,blocks:Ri}}var os=16*1024*1024;function as(e){let t=e.parts.get(e.mainDocumentPart);if(!t||t.root.kind!=="document")return false;let n=t.root.children.find(i=>i.kind==="body");if(!n||n.kind!=="body"||n.children.length>chunk24APKZAN_cjs.qh)return false;let r=0,o=(i,a,s)=>{if(a>s||(r+=1,r>chunk24APKZAN_cjs.sh))return false;if(i.kind==="textValue")return true;for(let l of i.children)if(!o(l,a+1,s))return false;return true};for(let i of n.children)if(!o(i,1,chunk24APKZAN_cjs.rh))return false;for(let[i,a]of e.parts)if(i!==e.mainDocumentPart&&/\/(styles|numbering|footnotes|endnotes)\.xml$/.test(i)&&!o(a.root,1,chunk24APKZAN_cjs.rh*4))return false;return true}function Uo(e,t,n){if(n.fragmentBytes.byteLength>os)return {ok:false,reason:"invalidArgs",detail:"fragment-too-large"};let r=chunk24APKZAN_cjs.Wb(n.fragmentBytes);if(!r.ok)return {ok:false,reason:"invalidArgs",detail:`fragment-read:${r.reason}`};let o=r.package;if(!as(o))return {ok:false,reason:"invalidArgs",detail:"fragment-over-budget"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let{store:a,story:s}=i;if(a.compositionActive||e.compositionSessionOpen())return {ok:false,reason:"invalidArgs",detail:"ime-composition-active"};let l=e.currentPackage(),d=a.checkpoint(),c=a.historyDepth,u=0,m="";return chunk24APKZAN_cjs.xa(e,()=>{let g=a.transact(P=>{for(let k of n.priorOps??[])if(!P.apply(k))return;let f=null,x=P.applyPackage(k=>(f=_o(k,o,s.partName),f.ok?f.pkg:k)),p=f;if(!p||!p.ok){m=`fragment-merge:${p?p.reason:"no-merge"}`,P.apply({op:"insertText",paragraphId:"\0fragment-abort",offset:0,text:"x"});return}x&&(u=p.blocks.length,P.apply({op:"insertFragment",paragraphId:n.paragraphId,offset:n.offset,blocks:p.blocks,lastMarkCovered:n.lastMarkCovered}));},{story:s,...n.actorId?{actorId:n.actorId}:{}});return m.length>0?{ok:false,reason:"invalidArgs",detail:m}:g.ok?g.change?{ok:true,change:e.promoteStoryTransactionToPackageUnit(l,a,d,c),blockCount:u}:{ok:true,change:null,blockCount:u}:{ok:false,reason:g.reason,...g.detail?{detail:g.detail}:{}}},g=>chunk24APKZAN_cjs.ya(g))}function is(e){if(!(e===null||e.start!==e.end))return e}var je={"text-local":0,"paragraph-local":1,"flow-structural":2,global:3};function ss(e){return Object.freeze({parts:new Map([[e.name,e]]),partBytes:new Map,relationships:new Map,externalTargets:[],contentTypes:{defaults:new Map,overrides:new Map([[e.name.toLowerCase(),e.contentType]])},mainDocumentPart:e.name})}var We=class{current;storyPartName;rev=0;commitCounter=0;undoStack=[];redoStack=[];subscribers=new Set;historyLimit;settingsPartOverride;storyRef=null;composition=null;constructor(t,n,r={}){let o="root"in t,i=typeof n=="string"?n:void 0,a=typeof n=="object"&&n!==null?n:r;this.current=o?ss(t):t,this.storyPartName=i??(o?t.name:t.mainDocumentPart),this.historyLimit=a.historyLimit??200,this.settingsPartOverride=a.settingsPart;}setStoryRef(t){this.storyRef=t;}get part(){let t=this.current.parts.get(this.storyPartName);if(!t)throw new Error(`story part missing: ${this.storyPartName}`);return t}get package(){return this.current}get revision(){return this.rev}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get historyDepth(){return this.undoStack.length}get compositionActive(){return this.composition!==null}graftPackage(t){this.current=t(this.current);}replacePart(t){let n=this.current.parts.get(t.name);t!==n&&(this.current=chunk24APKZAN_cjs.Yb(this.current,t),this.rev+=1);}checkpoint(){return {pkg:this.current,revision:this.rev,undoStack:this.undoStack.slice(),redoStack:this.redoStack.slice(),composition:this.composition?{entry:{...this.composition.entry},committed:this.composition.committed}:null}}restoreCheckpoint(t){this.current=t.pkg,this.rev=t.revision,this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack),this.composition=t.composition?{entry:{...t.composition.entry},committed:t.composition.committed}:null;}restoreHistoryStacks(t){this.undoStack.length=0,this.undoStack.push(...t.undoStack),this.redoStack.length=0,this.redoStack.push(...t.redoStack);}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}transact(t,n={}){return chunk24APKZAN_cjs.Eb(n.actorId,()=>this.commitTransaction(t,n))}commitTransaction(t,n){let r=n.origin??chunk24APKZAN_cjs.b.mutationHuman,o=this.current,i=this.rev,a=this.current,s=null,l=0,d=new Set,c=new Set,u=new Set,m=new Set,g=new Set,y=[],P=n.minimumImpact??"text-local",f=null,x=false,p=null,k=null,w=new Map,T=(A,B)=>{let L=chunk24APKZAN_cjs.Hg.get(A.op);if(L===void 0)return w.clear(),null;let X=`${B.name}\0${L}`,oe=w.get(X);oe||(oe={id:null},w.set(X,oe));let M=oe;return ()=>M.id??=chunk24APKZAN_cjs.cf(B)()},R=(A,B)=>{if(s)return false;let L=a.parts.get(A);if(!L)return s={reason:"unknown-part",detail:A},false;let X=chunk24APKZAN_cjs.Mg(L,this.settingsPartOverride?.()??chunk24APKZAN_cjs.ve(a),B);if(X)return s={reason:X},false;let oe=T(B,L),M=chunk24APKZAN_cjs.oh(L,B,{deferValidation:true,...oe?{revisionIds:oe}:{}});if(!M.ok)return s={reason:M.reason,...M.detail?{detail:M.detail}:{}},false;if(a=chunk24APKZAN_cjs.Yb(a,M.part),M.part===L&&M.effect.dirty.length===0&&M.effect.created.length===0&&M.effect.deleted.length===0&&M.effect.split===void 0&&(M.effect.splits===void 0||M.effect.splits.length===0)&&M.effect.join===void 0&&M.effect.caret===void 0)return true;d.add(A),l+=1;for(let J of M.effect.dirty)c.add(J);for(let J of M.effect.created)u.add(J);for(let J of M.effect.deleted)m.add(J);for(let J of M.effect.dependencyKeys)g.add(J);M.effect.split&&y.push({split:M.effect.split});for(let J of M.effect.splits??[])y.push({split:J});return M.effect.join&&y.push({join:M.effect.join}),je[M.effect.impact]>je[P]&&(P=M.effect.impact),M.effect.caret&&(k={paragraphId:M.effect.caret.paragraphId,start:0,end:0}),true};if(t({apply:A=>R(this.storyPartName,A),applyTo:(A,B)=>R(A,B),applyPackage:A=>{if(s)return false;w.clear();let B=A(a);if(B===a)return true;for(let[L,X]of B.parts)a.parts.get(L)!==X&&d.add(L);return a=B,l+=1,je["flow-structural"]>je[P]&&(P="flow-structural"),true},selectionBefore:A=>{f=A;},selectionAfter:A=>{x=true,p=A;}}),s){let A=s;return {ok:false,reason:A.reason,...A.detail?{detail:A.detail}:{}}}if(l===0)return {ok:true,change:null};let S=x?p:k,D=x?is(p):k??void 0;for(let A of d){let B=o.parts.get(A),L=a.parts.get(A);if(L===void 0)continue;let X=B?chunk24APKZAN_cjs.ra(B,L):chunk24APKZAN_cjs.ra(L,L);if(!X.ok)return {ok:false,reason:"tree-invariant",detail:JSON.stringify(X.issues)}}let V=chunk24APKZAN_cjs.gc(a);return V.ok?((n.recordsHistory??(r!==chunk24APKZAN_cjs.b.projection&&r!==chunk24APKZAN_cjs.b.awareness))&&(this.composition?(this.composition.committed=true,this.composition={...this.composition,entry:{...this.composition.entry,selectionAfter:S}}):(this.pushUndo({pkg:o,revision:i,selectionBefore:f,selectionAfter:S}),this.redoStack.length=0)),this.current=a,this.rev+=1,n.story&&(this.storyRef=n.story),n.minimumImpact&&je[n.minimumImpact]>je[P]&&(P=n.minimumImpact),{ok:true,change:this.publish(r,i,{dirty:c,created:u,deleted:m,dependencyKeys:g,splitJoin:y,impact:P,caret:D},n.story??this.storyRef??void 0,n.actorId,n.operationId)}):{ok:false,reason:"package-invariant",detail:JSON.stringify(V.issues)}}beginComposition(t=null){this.composition||(this.composition={entry:{pkg:this.current,revision:this.rev,selectionBefore:t,selectionAfter:null},committed:false});}endComposition(){let t=this.composition;this.composition=null,!(!t||!t.committed)&&(this.pushUndo(t.entry),this.redoStack.length=0);}cancelComposition(){this.composition=null;}undo(){let t=this.undoStack.pop();if(!t)return null;let n=this.rev;return this.redoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(chunk24APKZAN_cjs.b.mutationUndo,n,null,this.storyRef??void 0)}redo(){let t=this.redoStack.pop();if(!t)return null;let n=this.rev;return this.undoStack.push({pkg:this.current,revision:this.rev,selectionBefore:t.selectionBefore,selectionAfter:t.selectionAfter}),this.current=t.pkg,this.rev+=1,this.publish(chunk24APKZAN_cjs.b.mutationRedo,n,null,this.storyRef??void 0)}selectionForUndo(){return this.undoStack[this.undoStack.length-1]?.selectionBefore??null}selectionForRedo(){return this.redoStack[this.redoStack.length-1]?.selectionAfter??null}pushUndo(t){this.undoStack.push(t),this.undoStack.length>this.historyLimit&&this.undoStack.shift();}publish(t,n,r,o,i,a){this.commitCounter+=1;let s={change:"model-change",fromRevision:n,toRevision:this.rev,commitId:`commit-${this.commitCounter}`,origin:t,...i?{actorId:i}:{},...a?{operationId:a}:{},dirty:r?[...r.dirty]:[],created:r?[...r.created]:[],deleted:r?[...r.deleted]:[],splitJoin:r?r.splitJoin:[],dependencyKeys:r?[...r.dependencyKeys]:[],impact:r?r.impact:o?.kind==="headerFooter"?"global":"flow-structural",...r?.caret?{caret:r.caret}:{},...o?{story:o}:{}};for(let l of this.subscribers)l(s);return s}};function xn(e,t){return [...e.values()].map(n=>n.part).filter(n=>t.parts.has(n.name))}function Fo(e,t){return xn(e,t).map(n=>n.name).sort().join(",")}function Lo(e,t,n){if(e.relationships!==t.relationships||e.contentTypes!==t.contentTypes||e.partBytes!==t.partBytes||e.externalTargets!==t.externalTargets||e.mainDocumentPart!==t.mainDocumentPart)return true;if(e.parts===t.parts)return false;if(e.parts.size!==t.parts.size)return true;for(let[r,o]of t.parts)if(r!==n&&e.parts.get(r)!==o)return true;return false}var At="http://schemas.openxmlformats.org/wordprocessingml/2006/main",ls="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";function Ve(e,t){for(let n of e.children)if(n.kind!=="textValue"&&n.namespaceUri===At&&n.localName===t)return n;return null}function Dt(e,t){return e.attributes.find(n=>n.namespaceUri===At&&n.localName===t)?.value}function ds(e){let t=Dt(e,"val");return t===void 0||t==="1"||t==="true"||t==="on"}function Bo(e,t){return e.kind==="textValue"?Object.freeze({...e,id:t()}):Object.freeze({...e,id:t(),children:e.children.map(n=>Bo(n,t))})}function cs(e){let t=chunk24APKZAN_cjs.ta(`<w:styles xmlns:w="${At}"><w:style w:type="paragraph" w:styleId="ListParagraph"><w:pPr><w:contextualSpacing/></w:pPr></w:style></w:styles>`,{name:e.name,contentType:ls});if(!t.ok)return null;let n=Ve(t.part.root,"style"),r=n?Ve(n,"pPr"):null;return r?Bo(r,chunk24APKZAN_cjs.Aa(e)):null}var $o=["pStyle","keepNext","keepLines","pageBreakBefore","framePr","widowControl","numPr","suppressLineNumbers","pBdr","shd","tabs","suppressAutoHyphens","kinsoku","wordWrap","overflowPunct","topLinePunct","autoSpaceDE","autoSpaceDN","bidi","adjustRightInd","snapToGrid","spacing","ind","contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"];function ms(e,t){let n=$o.indexOf(t),r=0;return e.forEach((o,i)=>{if(o.kind==="textValue")return;let a=$o.indexOf(o.localName);a!==-1&&a<=n&&(r=i+1);}),r}function Ho(e,t){let n=chunk24APKZAN_cjs.Bd(e);if(!n)return null;let r=null;for(let d of n.root.children)if(d.kind!=="textValue"&&d.namespaceUri===At&&d.localName==="style"&&Dt(d,"type")==="paragraph"&&Dt(d,"styleId")===t){r=d;break}if(!r)return null;let o=Ve(r,"name");if(o&&Dt(o,"val")?.trim().toLowerCase()!=="list paragraph"&&t!=="ListParagraph")return null;let i=cs(n);if(!i)return null;let a=Ve(i,"contextualSpacing");if(!a)return null;let s=Ve(r,"pPr"),l;if(s){let d=Ve(s,"contextualSpacing");if(d&&ds(d))return e;l=d?chunk24APKZAN_cjs.Ha(n,d.id,a):chunk24APKZAN_cjs.Ga(n,s.id,ms(s.children,"contextualSpacing"),[a]);}else {let d=r.children.findIndex(c=>c.kind!=="textValue"&&["rPr","tblPr","tcPr","tblStylePr"].includes(c.localName));l=chunk24APKZAN_cjs.Ga(n,r.id,d===-1?r.children.length:d,[i]);}return l.ok?Object.freeze({...e,parts:new Map([...e.parts,[n.name,l.part]])}):null}var Ko="http://schemas.openxmlformats.org/package/2006/relationships",zo="application/vnd.openxmlformats-package.relationships+xml",fs="http://schemas.openxmlformats.org/package/2006/content-types",jo="/[Content_Types].xml",Ke="/word/numbering.xml",Wo="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",lt="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",gs=`<Override PartName="${Ke}" ContentType="${lt}"/>`;function _t(e){return `${e.ownerPart}\0${e.id}`}function Go(e,t,n){let r=new Set(t.externalTargets.filter(s=>s.type===chunk24APKZAN_cjs.Pa).map(_t)),o=n.externalTargets.filter(s=>s.type===chunk24APKZAN_cjs.Pa&&!r.has(_t(s)));if(o.length===0)return e;let i=new Set(e.map(_t)),a=o.filter(s=>!i.has(_t(s)));return a.length===0?e:Object.freeze([...e,...a])}function Xo(e,t,n){let r=e.filter(o=>o.ownerPart===n||t.has(o.ownerPart));return r.length===e.length?e:Object.freeze(r)}function Yo(e,t,n=[]){if(e===t)return e;let r=hs(e,t);return r=ys(r,t,n),r}function qo(e,t){let n=new Set;for(let o of e.externalTargets)o.type===chunk24APKZAN_cjs.Pa&&o.ownerPart!==e.mainDocumentPart&&(e.parts.has(o.ownerPart)||t.has(o.ownerPart)||n.add(o.ownerPart));for(let o of e.parts.keys()){let i=Os(o);!i||i===e.mainDocumentPart||e.parts.has(i)||t.has(i)||e.externalTargets.some(a=>a.ownerPart===i)||n.add(i);}if(n.size===0)return e;let r=e;for(let o of n)r=Is(r,o);return r}function hs(e,t){let n=t.parts.get(Ke);if(!n)return e;let r=chunk24APKZAN_cjs.Yb(e,n),o=(t.relationships.get(t.mainDocumentPart)??[]).find(a=>a.type===Wo),i=r.relationships.get(r.mainDocumentPart)??[];if(o&&!i.some(a=>a.type===Wo)&&!i.some(a=>a.id===o.id)){let a=ks(r,{...o,ownerPart:r.mainDocumentPart});a&&(r=a);}if(r.contentTypes.overrides.get(chunk24APKZAN_cjs.u(Ke))!==lt){let a=Rs(r);a&&(r=a);}return r}function ys(e,t,n){let r=n.filter(i=>i.type===chunk24APKZAN_cjs.Pa);if(r.length===0)return e;let o=e;for(let i of r){let a=xs(e,t,i.ownerPart);if(!a||o.externalTargets.some(d=>d.ownerPart===a&&d.id===i.id)||new Set((o.relationships.get(a)??[]).map(d=>d.id)).has(i.id))continue;let l=Ps(o,{ownerPart:a,id:i.id,type:chunk24APKZAN_cjs.Pa,rawTarget:i.rawTarget,sinkSafe:i.sinkSafe},a);l&&(o=l);}return o}function xs(e,t,n){return n===t.mainDocumentPart?e.mainDocumentPart:typeof n!="string"||n.length===0?null:n}function ks(e,t){let n=e.mainDocumentPart,r=kn(n),o=e.parts.get(r),i=chunk24APKZAN_cjs.ta(`<Relationships xmlns="${Ko}"><Relationship Id="${chunk24APKZAN_cjs.P(t.id,"relationship id")}" Type="${chunk24APKZAN_cjs.P(t.type,"relationship type")}" Target="${chunk24APKZAN_cjs.P(t.rawTarget,"relationship target")}"/></Relationships>`,{name:r,contentType:zo});if(!i.ok)return null;let a=e.relationships.get(n)??[];if(a.some(d=>d.id===t.id))return null;let s={...t,ownerPart:n,order:a.reduce((d,c)=>Math.max(d,c.order),-1)+1},l=new Map([...e.relationships,[n,[...a,s]]]);return o?Jo(e,o,i.part.root.children[0],l):Object.freeze({...e,parts:new Map([...e.parts,[r,i.part]]),relationships:l})}function Ps(e,t,n=e.mainDocumentPart){let r=n;if(typeof r!="string"||r.length===0)return null;let o=kn(r),i=e.parts.get(o),a=chunk24APKZAN_cjs.ta(`<Relationships xmlns="${Ko}"><Relationship Id="${chunk24APKZAN_cjs.P(t.id,"relationship id")}" Type="${chunk24APKZAN_cjs.Pa}" Target="${chunk24APKZAN_cjs.P(t.rawTarget,"relationship target")}" TargetMode="External"/></Relationships>`,{name:o,contentType:zo});if(!a.ok)return null;let s=[...e.externalTargets,t];if(!i)return Object.freeze({...e,parts:new Map([...e.parts,[o,a.part]]),externalTargets:s});let l=Jo(e,i,a.part.root.children[0],e.relationships);return l?Object.freeze({...l,externalTargets:s}):null}function Jo(e,t,n,r){if(!n)return null;let o=chunk24APKZAN_cjs.Aa(t),i=chunk24APKZAN_cjs.Ga(t,t.root.id,t.root.children.length,[Qo(n,o)]);return i.ok?Object.freeze({...e,parts:new Map([...e.parts,[t.name,i.part]]),relationships:r}):null}function Qo(e,t){return e.kind==="textValue"?{...e,id:t()}:{...e,id:t(),children:e.children.map(n=>Qo(n,t))}}function kn(e){let t=e.lastIndexOf("/");return `${e.slice(0,t)}/_rels/${e.slice(t+1)}.rels`}function Os(e){let t=/^(.*)\/_rels\/([^/]+)\.rels$/.exec(e);if(!t)return null;let n=t[1],r=t[2];return n===""||r===""?null:`${n}/${r}`}function Is(e,t){let n=kn(t),r=new Map(e.parts);r.delete(n);let o=new Map(e.partBytes);o.delete(n);let i=new Map(e.relationships);i.delete(t);let a=Object.freeze(e.externalTargets.filter(s=>s.ownerPart!==t));return Object.freeze({...e,parts:r,partBytes:o,relationships:i,externalTargets:a})}function Rs(e){let t=e.contentTypes.overrides.get(chunk24APKZAN_cjs.u(Ke));if(t===lt)return e;if(t!==void 0)return null;let n=e.partBytes.get(jo);if(!n)return null;let r=fflate.strFromU8(n),o=Vo(r);if(!o)return null;let i=r.lastIndexOf(`</${o.rootName}>`);if(i===-1)return null;let a=r.slice(0,i)+gs+r.slice(i),s=Vo(a);if(!s||s.rootName!==o.rootName)return null;let l=[...o.children,Zo("Override",{PartName:Ke,ContentType:lt})];return s.children.length!==l.length||s.children.some((d,c)=>d!==l[c])?null:Object.freeze({...e,partBytes:new Map([...e.partBytes,[jo,fflate.strToU8(a)]]),contentTypes:Object.freeze({defaults:e.contentTypes.defaults,overrides:new Map([...e.contentTypes.overrides,[chunk24APKZAN_cjs.u(Ke),lt]])})})}function Vo(e){let t=chunk24APKZAN_cjs.W(e);if(!t.ok)return null;let n=t.nodes.filter(s=>s.type==="element");if(n.length!==1)return null;let r=n[0],o=r.name.indexOf(":"),i=o===-1?"":r.name.slice(0,o);if(r.name.slice(o+1)!=="Types"||r.attributes[i?`xmlns:${i}`:"xmlns"]!==fs)return null;let a=[];for(let s of r.children)s.type==="element"&&a.push(Zo(s.name,s.attributes));return {rootName:r.name,children:a}}function Zo(e,t){let n=Object.entries(t).map(([r,o])=>`${r}=${o}`).sort();return [e,...n].join("")}var ea=4e3,ta=64;function na(e){return chunk24APKZAN_cjs.Xe(e,"footnote")!==null||chunk24APKZAN_cjs.Xe(e,"endnote")!==null}function ra(e,t,n,r){if(!na(e))return false;if(r.has(n.paragraphId))return true;r.add(n.paragraphId);let o=chunk24APKZAN_cjs.Ca(t,n.paragraphId);return !o||o.kind!=="paragraph"?true:chunk24APKZAN_cjs.Ne(o).some(i=>i.node.kind==="noteReference"&&i.start<n.end&&i.end>n.start)}function oa(e,t,n,r){if(!na(e))return false;if(r.has(n.blockId))return true;r.add(n.blockId);let o=chunk24APKZAN_cjs.Ca(t,n.blockId);if(!o||o.kind==="textValue")return true;let i=0,a=(s,l)=>{if(i>=ea||l>ta)return true;if(i+=1,s.kind==="textValue")return false;if(s.kind==="paragraph")return chunk24APKZAN_cjs.Ne(s).some(d=>d.node.kind==="noteReference");for(let d of s.children)if(a(d,l+1))return true;return false};return a(o,0)}function aa(e,t,n){if(n.count>=ea||t>ta)return true;if(n.count+=1,e.kind==="textValue")return false;if(e.kind==="commentRangeStart"||e.kind==="commentRangeEnd"||e.kind==="commentReference")return true;for(let r of e.children)if(aa(r,t+1,n))return true;return false}function ia(e,t,n,r){if(!chunk24APKZAN_cjs.yf(e))return false;let o=n.op==="deleteText"?n.paragraphId:n.blockId;if(r.has(o))return true;r.add(o);let i=chunk24APKZAN_cjs.Ca(t,o);return !i||i.kind==="textValue"?true:aa(i,0,{count:0})}var Pn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",On="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";function sa(e,t){let r=(e.relationships.get(e.mainDocumentPart)??[]).find(o=>o.id===t);return r?r.type!==Pn&&r.type!==On?{ok:false,reason:"wrong-relationship-type",detail:r.type}:bs(e,r):{ok:false,reason:"dangling-relationship",detail:t}}function bs(e,t){let n=chunk24APKZAN_cjs.E(t);if(n.mode==="External")return {ok:false,reason:"external-relationship",detail:t.id};if(!n.target.ok)return {ok:false,reason:"bad-relationship-target",detail:n.target.reason};let r=e.parts.get(n.target.partName);if(!r)return {ok:false,reason:"missing-part",detail:n.target.partName};let o=r.root.localName;return o!=="hdr"&&o!=="ftr"?{ok:false,reason:"not-a-story-part",detail:o||r.name}:{ok:true,partName:r.name,part:r}}function Ee(e,t){return t.compositionActive||e.compositionSessionOpen()?{ok:false,reason:"invalidArgs",detail:"ime-composition-active"}:null}function la(e,t){let n=chunk24APKZAN_cjs.Ca(e,t);return !n||n.kind!=="drawing"?null:n.children.find(o=>o.kind==="inlineDrawing"||o.kind==="anchoredDrawing")??null}function da(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=chunk24APKZAN_cjs.Ca(r,n);return !o||o.kind!=="drawing"?null:chunk24APKZAN_cjs.db(o,{ownerPartName:t,supportedMcRequires:chunk24APKZAN_cjs._a,limits:chunk24APKZAN_cjs.Za,resolveRelationship:chunk24APKZAN_cjs.ab(e,t)})}function ca(e,t,n){let r=chunk24APKZAN_cjs.F(e.relationships.get(t)??[],t,n);return r.mode==="internal"?r.partName:null}function ze(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=Ee(e,o.store);if(i)return i;let{store:a,story:s}=o;return chunk24APKZAN_cjs.xa(e,()=>vs(e,a,s,n,r),l=>chunk24APKZAN_cjs.ya(l))}function vs(e,t,n,r,o){let i=n.partName,a=e.currentPackage(),s=t.checkpoint(),l=t.historyDepth,d=null,c=false,u=false,m=t.transact(P=>{if(o?.commitGuard?.()===false){u=true;return}if(o?.expectedPackageRevision!==void 0&&e.packageRevision!==o.expectedPackageRevision){c=true;return}let f=r(P,i);if(f===null){P.apply({op:"insertText",paragraphId:"\0task12-abort",offset:0,text:"x"});return}d=f;},{story:n,...o?.actorId?{actorId:o.actorId}:{},...n.kind==="headerFooter"||n.kind==="notesPart"?{minimumImpact:"global"}:{}});if(u)return {ok:false,reason:"invalidArgs",detail:"stale drawing selection"};if(c)return {ok:false,reason:"invalidArgs",detail:"stale-package-epoch"};if(!m.ok)return {ok:false,reason:m.reason,...m.detail?{detail:m.detail}:{}};if(!m.change)return {ok:true,change:null};let g=m.change.created.find(P=>{let f=t.part;return chunk24APKZAN_cjs.Ca(f,P)?.kind==="drawing"});return g&&(d=g),{ok:true,change:e.promoteStoryTransactionToPackageUnit(a,t,s,l),...d?{drawingNodeId:d}:{}}}function ma(e,t,n){let r=e.parts.get(t);if(!r)return null;let o=la(r,n);return o?chunk24APKZAN_cjs.eh(o):null}function In(e,t,n,r){let o=false;return e.applyPackage(i=>{let a=i.parts.get(t);if(!a)return i;let s=chunk24APKZAN_cjs.Ca(a,n);if(!s||s.kind!=="drawing")return i;let l=la(a,n);if(!l)return i;let d=chunk24APKZAN_cjs.fh(l,r),c=Ns(s,d),u=chunk24APKZAN_cjs.Ha(a,s.id,c,{deferValidation:true});return u.ok?(o=true,chunk24APKZAN_cjs.Yb(i,u.part)):i}),o}function Ns(e,t){return {...e,children:e.children.map(n=>n.id===t.id?t:n)}}async function ua(e,t,n){let r=chunk24APKZAN_cjs.Qb(n.widthPoints),o=chunk24APKZAN_cjs.Qb(n.heightPoints);if(r===null||o===null)return {ok:false,reason:"invalidArgs",detail:"invalid-dimensions"};let i=e.resolveStory(t);if(!i.ok)return {ok:false,reason:i.reason,...i.detail?{detail:i.detail}:{}};let a=Ee(e,i.store);if(a)return a;let s=i.story.partName,l=await chunk24APKZAN_cjs.Mb(n.decodePort,n.bytes,n.mime);if(!l.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let d=l.bytes,c=chunk24APKZAN_cjs.Ob(e.currentPackage(),s,{bytes:d,mime:n.mime});if(!c.ok)return {ok:false,reason:"invalidArgs",detail:c.reason==="invalid-image"?"invalid-image":c.reason};let u=c.partName,m=ze(e,t,(g,y)=>{let P=e.currentPackage(),f=chunk24APKZAN_cjs.Ob(P,y,{bytes:d,mime:n.mime});if(!f.ok)return null;P=f.pkg,u=f.partName;let x;if(n.hyperlink){let k=chunk24APKZAN_cjs.Jd(P,n.hyperlink,y);if(!k)return null;P=k.pkg,x=k.relationshipId;}if(!g.applyPackage(()=>P))return null;let p=chunk24APKZAN_cjs.Rb({docPrId:f.docPrId,relationshipId:f.relationshipId,extentEmu:{cx:r,cy:o},...n.title!==void 0?{title:n.title}:{},...n.description!==void 0?{description:n.description}:{},...x?{hyperlinkRelationshipId:x}:{}});return g.apply({op:"insertDrawing",paragraphId:n.paragraphId,offset:n.offset,drawing:p,...n.revision?{revision:n.revision}:{}})?p.id:null},{expectedPackageRevision:n.expectedPackageRevision,...n.commitGuard?{commitGuard:n.commitGuard}:{},...n.actorId?{actorId:n.actorId}:{}});return m.ok?m.change?{...m,mediaPartName:u}:{ok:true,change:null,mediaPartName:u}:m}async function Rn(e,t,n,r,o,i,a){let s=e.resolveStory(t);if(!s.ok)return {ok:false,reason:s.reason,...s.detail?{detail:s.detail}:{}};let l=Ee(e,s.store);if(l)return l;let d=s.story.partName,c=await chunk24APKZAN_cjs.Mb(i,r,o);if(!c.ok)return {ok:false,reason:"invalidArgs",detail:"invalid-image"};let u=c.bytes,m=chunk24APKZAN_cjs.Ob(e.currentPackage(),d,{bytes:u,mime:o});return m.ok?ze(e,t,(g,y)=>{let P=e.currentPackage(),f=da(P,d,n),x=f?.picture?.embeddedRelationshipId??null,p=f?.picture?.linkedRelationshipId??null,k=x??p;if(!k)return null;let w=x!==null?ca(P,d,x):null,T=P,R=chunk24APKZAN_cjs.Ob(T,y,{bytes:u,mime:o});return !R.ok||(T=R.pkg,!g.applyPackage(()=>T))||!g.apply({op:"replaceDrawingResource",drawingNodeId:n,relationshipId:R.relationshipId})?null:(g.applyPackage(S=>chunk24APKZAN_cjs.Tb(S,y,w,k)),n)},{expectedPackageRevision:a.expectedPackageRevision,...a.commitGuard?{commitGuard:a.commitGuard}:{},...a.actorId?{actorId:a.actorId}:{}}):{ok:false,reason:"invalidArgs",detail:m.reason==="invalid-image"?"invalid-image":m.reason}}function pa(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=Ee(e,r.store);if(o)return o;let i=r.story.partName,a=e.currentPackage(),s=da(a,i,n);if(!s)return {ok:false,reason:"unknown-drawing"};let l=s.picture?.embeddedRelationshipId??null,d=s.picture?.linkedRelationshipId??null,c=l??d,u=l!==null?ca(a,i,l):null;return ze(e,t,(m,g)=>m.apply({op:"deleteDrawing",drawingNodeId:n})?(m.applyPackage(y=>chunk24APKZAN_cjs.Tb(y,g,u,c)),n):null)}function Ss(e,t){let n=null,r=i=>{let a=false,s=false,l=(d,c)=>{if(a||d.kind==="textValue")return;if(d.id===t){a=true,s=c;return}let u=c||d.kind==="revisionDelete"||d.kind==="revisionMoveFrom";for(let m of d.children)l(m,u);};return l(i,false),s},o=i=>{if(!(n!==null||i.kind==="textValue")){if(i.kind==="paragraph"){let a=chunk24APKZAN_cjs.Pe(i).spanOf(t);if(a!==null&&a.end>a.start){let s=chunk24APKZAN_cjs.Ca(e,t);if(!s||s.kind!=="drawing"&&!chunk24APKZAN_cjs.bb(s))return;n={paragraphId:i.id,start:a.start,end:a.end,alreadyDeleted:r(i)};}return}for(let a of i.children)o(a);}};return o(e.root),n}function fa(e,t,n,r){let o=e.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let i=Ee(e,o.store);if(i)return i;let a=e.currentPackage().parts.get(o.story.partName);if(!a)return {ok:false,reason:"unknown-drawing"};let s=Ss(a,n);return s?s.alreadyDeleted?{ok:true,change:null}:ze(e,t,l=>l.apply({op:"deleteText",paragraphId:s.paragraphId,start:s.start,end:s.end,revision:r})?n:null):{ok:false,reason:"unknown-drawing"}}async function ga(e,t,n,r,o,i,a,s){let l=await chunk24APKZAN_cjs.Ub(o,r,i,void 0,a);return l.ok?Rn(e,t,n,l.bytes,l.mime,a,{expectedPackageRevision:e.packageRevision,...s?{actorId:s}:{}}):{ok:false,reason:"invalidArgs",detail:`${l.reason}${l.detail?`:${l.detail}`:""}`}}function ha(e,t,n,r,o,i){let a=e.resolveStory(t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};let s=Ee(e,a.store);return s||ze(e,t,(l,d)=>{let c=ma(e.currentPackage(),d,n),u=null;if(i!==null){let g=chunk24APKZAN_cjs.Jd(e.currentPackage(),i,d);if(!g||!l.applyPackage(()=>g.pkg))return null;u=g.relationshipId;}if(!l.apply({op:"setDrawingMetadata",drawingNodeId:n,title:r,description:o,...i===null?{hyperlink:null}:{}}))return null;if(i!==null&&u!==null){if(!In(l,d,n,u))return null}else if(i===null&&!In(l,d,n,null))return null;let m=false;return l.applyPackage(g=>{let y=chunk24APKZAN_cjs.Ld(g,d,c);return y===null?(m=true,g):y}),m?null:n})}function ya(e,t,n){let r=e.resolveStory(t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};let o=Ee(e,r.store);return o||ze(e,t,(i,a)=>{let s=ma(e.currentPackage(),a,n.drawingNodeId),l=null;if(n.hyperlink!==null){let c=chunk24APKZAN_cjs.Jd(e.currentPackage(),n.hyperlink,a);if(!c||!i.applyPackage(()=>c.pkg))return null;l=c.relationshipId;}for(let c of n.ops)if(!i.apply(c))return null;if(!In(i,a,n.drawingNodeId,n.hyperlink===null?null:l))return null;let d=false;return i.applyPackage(c=>{let u=chunk24APKZAN_cjs.Ld(c,a,s);return u===null?(d=true,c):u}),d?null:n.drawingNodeId})}function Ts(e,t){if(e===t)return true;if(e.byteLength!==t.byteLength)return false;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return false;return true}function xa(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e)if(t.get(n)!==r)return false;return true}function ws(e,t){return e===t||e.ownerPart===t.ownerPart&&e.id===t.id&&e.type===t.type&&e.rawTarget===t.rawTarget&&e.targetMode===t.targetMode&&e.order===t.order}function Es(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||o.length!==r.length||o!==r&&r.some((i,a)=>!ws(i,o[a])))return false}return true}function Cs(e,t){return e===t?true:e.length!==t.length?false:e.every((n,r)=>{let o=t[r];return n===o||n.ownerPart===o.ownerPart&&n.id===o.id&&n.type===o.type&&n.rawTarget===o.rawTarget&&n.sinkSafe===o.sinkSafe})}function Ms(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let[n,r]of e){let o=t.get(n);if(!o||!Ts(r,o))return false}return true}function Ds(e,t){return e.contentTypes===t.contentTypes||xa(e.contentTypes.defaults,t.contentTypes.defaults)&&xa(e.contentTypes.overrides,t.contentTypes.overrides)}var Ut=Object.freeze({equal:true,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"}),Ft=Object.freeze({equal:false,dirty:Object.freeze([]),dependencyKeys:Object.freeze([]),impact:"global"});function ka(e){for(let[t,n]of e)if(!chunk24APKZAN_cjs.oa(t,n))return Ft;return Ut}function As(e,t){if(e===t)return Ut;if(e.mainDocumentPart!==t.mainDocumentPart||e.parts.size!==t.parts.size||!Ms(e.partBytes,t.partBytes)||!Es(e.relationships,t.relationships)||!Cs(e.externalTargets,t.externalTargets)||!Ds(e,t))return Ft;let n=[];for(let[a,s]of e.parts){let l=t.parts.get(a);if(!l)return Ft;s!==l&&n.push([s,l]);}if(n.length===0)return Ut;let[r,o]=n[0];if(n.length>1||r.name!==e.mainDocumentPart)return ka(n);let i=chunk24APKZAN_cjs.pa(o.root,r.root);return i.undecided?ka(n):i.equal?Ut:!i.idsPreserved||i.reach==="outside-paragraph"||i.paragraphIds.length===0?Ft:{equal:false,dirty:i.paragraphIds,dependencyKeys:[chunk24APKZAN_cjs.g.story],impact:i.reach==="paragraph-text"?"text-local":"flow-structural"}}function bn(e){return {ok:false,reason:"package-invariant",detail:e}}function _s(e,t){if(!e.parts.get(e.mainDocumentPart))return bn("no-main-document");for(let[r,o]of e.parts){let i=t?.parts.get(r);if(i===o)continue;let a=i?chunk24APKZAN_cjs.ra(i,o):chunk24APKZAN_cjs.qa(o);if(!a.ok)return bn(`invalid-part:${r}:${a.issues[0]?.code??"invalid"}`)}let n=chunk24APKZAN_cjs.gc(e);return n.ok?null:bn(n.issues[0]?.code??"package-invariant")}function Pa(e,t,n){let r=e.currentPackage(),o=As(t,r);if(o.equal)return {ok:true,change:null};let i=_s(t,r);if(i)return i;let a=e.bodyStore().part.name,s=o.impact!=="global"&&t.mainDocumentPart===a;return chunk24APKZAN_cjs.xa(e,()=>{let l=e.packageRevision;return e.installAuthoritativePackageSnapshot(t),{ok:true,change:e.publishStoryWrite({change:"model-change",fromRevision:l,toRevision:l+1,commitId:`pkg-remote-${l+1}`,origin:n.origin,...n.actorId?{actorId:n.actorId}:{},...n.operationId?{operationId:n.operationId}:{},dirty:s?o.dirty:[],created:[],deleted:[],splitJoin:[],dependencyKeys:s?o.dependencyKeys:[],impact:s?o.impact:"global",story:{kind:"body",partName:a}})}},()=>false)}function Ra(e,t,n,r){let o=[...t],i=new Set;for(let a of o)e.parts.has(a)&&i.add(a);for(let a of n)Oa(a,o,i);for(let a of r)Oa(a,o,i);return i}function ba(e,t,n,r,o){let i=new Set(e);i.add(t),i.add(n);for(let a of r)Ia(a,i);for(let a of o)Ia(a,i);return i}function Oa(e,t,n){if(e.kind==="story"){n.add(e.partName);return}for(let r of t)(e.before.parts.has(r)||e.after.parts.has(r))&&n.add(r);}function Ia(e,t){if(e.kind==="story"){t.add(e.partName);return}for(let n of e.before.parts.keys())t.add(n);for(let n of e.after.parts.keys())t.add(n);}var va=new Set(["acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions"]),Us=new Set(["deleteTableRow","deleteTableColumn","removeContentControl","removeRepeatingSectionItem"]),Fs=64,Na=class{pkg;packageRev=0;body;stories=new Map;rIdToPartName=new Map;undoOrder=[];redoOrder=[];subscribers=new Set;historyLimit;maxEditableStoryParts;cascadeNoteReferences;lastChange=null;shellHyperlinks=Object.freeze([]);compositionSession=null;commitCounter=0;currentPackageMemo=null;constructor(t,n,r={}){this.pkg=chunk24APKZAN_cjs.Yb(t,n),this.historyLimit=r.historyLimit??200,this.maxEditableStoryParts=r.maxEditableStoryParts??Fs,this.cascadeNoteReferences=r.cascadeDeletedNoteReferences??chunk24APKZAN_cjs.lf,this.body=new We(this.pkg,n.name,{historyLimit:this.historyLimit,settingsPart:()=>chunk24APKZAN_cjs.ve(this.pkg)}),this.body.setStoryRef({kind:"body",partName:n.name});}get packageRevision(){return this.packageRev}get canUndo(){return this.undoOrder.length>0}get canRedo(){return this.redoOrder.length>0}get lastModelChange(){return this.lastChange}bodyStore(){return this.body}currentPackage(){let t=this.currentPackageMemo;if(t&&t.pkg===this.pkg&&t.bodyPart===this.body.part){let o=0,i=true;for(let a of this.stories.values()){if(t.storyParts[o]!==a.part){i=false;break}o+=1;}if(i&&o===t.storyParts.length)return t.result}let n=chunk24APKZAN_cjs.Yb(this.pkg,this.body.part),r=[];for(let o of this.stories.values())r.push(o.part),this.pkg.parts.has(o.part.name)&&(n=chunk24APKZAN_cjs.Yb(n,o.part));return this.currentPackageMemo={pkg:this.pkg,bodyPart:this.body.part,storyParts:r,result:n},n}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}resolveStory(t){return t.kind==="body"?{ok:true,story:{kind:"body",partName:this.body.part.name},store:this.body}:t.kind==="notesPart"?t.noteKind!=="footnote"&&t.noteKind!=="endnote"?{ok:false,reason:"unknown-scope",detail:String(t.noteKind)}:this.openNotesPartStore(t.noteKind):t.kind!=="headerFooter"||typeof t.rId!="string"||t.rId.length===0?{ok:false,reason:"unknown-scope",detail:String(t.kind)}:this.openHeaderFooterStore(t.rId)}partFor(t){let n=this.resolveStory(t);return n.ok?n.store.part:null}revisionFor(t){let n=this.resolveStory(t);return n.ok?n.store.revision:null}transact(t,n,r={}){return chunk24APKZAN_cjs.xa(this,()=>this.commitStoryTransaction(t,n,r),chunk24APKZAN_cjs.ya)}commitStoryTransaction(t,n,r={}){let o=this.resolveStory(t);if(!o.ok)return {ok:false,reason:o.reason,...o.detail?{detail:o.detail}:{}};let{store:i,story:a}=o,s=this.currentPackage(),l=i.historyDepth,d=i.compositionActive,c=i.checkpoint(),u=false,m=new Set,g=false,y=new Set,P=false,f,x=false;i.graftPackage(()=>this.currentPackage());let p=i.transact(T=>{n({...T,applyTo:(R,S)=>{let D=T.applyTo(R,S);return D&&R!==a.partName&&(x=true),D},applyPackage:R=>T.applyPackage(S=>{let D=R(S);return D!==S&&!x&&(x=Lo(S,D,a.partName)),D}),apply:R=>(R.op==="setListNumbering"&&R.numId!==null&&(P=true),R.op==="setParagraphProperties"&&(f??=R.properties.find(S=>S.localName==="pStyle")?.attributes?.val),u||(R.op==="deleteText"&&ra(this.pkg,i.part,R,m)||R.op==="deleteBlock"&&oa(this.pkg,i.part,R,m)||va.has(R.op))&&(u=true),g||(R.op==="deleteText"||R.op==="deleteBlock"?g=ia(this.pkg,i.part,R,y):(va.has(R.op)||Us.has(R.op))&&(g=true)),T.apply(R)),selectionBefore:R=>T.selectionBefore(R),selectionAfter:R=>T.selectionAfter(R)});},{...r,story:a,...a.kind==="headerFooter"||a.kind==="notesPart"?{minimumImpact:"global"}:{}});if(!p.ok)return {ok:false,reason:p.reason,...p.detail?{detail:p.detail}:{}};this.syncPackageFromStore(i);let k=false;if(p.change&&x&&(this.installPackageSnapshotInternal(i.package),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),k=true),P&&f){let T=Ho(this.pkg,f);T&&this.replacePackageShell(T);}let w=false;if(p.change&&u){let T=this.currentPackage(),R=this.cascadeNoteReferences(s,T);if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"note-cascade-failed"};R!==T&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),w=true);}if(p.change&&g){let T=this.currentPackage(),R=chunk24APKZAN_cjs.Cf(s,T,{storyPartName:a.partName});if(R===null)return i.restoreCheckpoint(c),this.installPackageSnapshotInternal(s),{ok:false,reason:"invalidArgs",detail:"comment-cascade-failed"};R!==T&&(this.installPackageSnapshotInternal(R),d?this.compositionSession&&(this.compositionSession.packageWideEffects=true):i.restoreHistoryStacks(c),w=true);}if(p.change){this.packageRev+=1;let T=w||k;!d&&r.recordsHistory!==false&&(i.historyDepth>l||T)&&(T?this.pushUndoPointer({kind:"package",before:s,after:this.currentPackage()}):this.pushUndoPointer({kind:"story",partName:a.partName,story:a}));let R=T?this.publishSynthetic(p.change.origin,"global",a,p.change.created):p.change;return T||this.publish(R),{ok:true,change:R}}return {ok:true,change:p.change}}compositionSessionOpen(){return this.compositionSession!==null}beginComposition(t,n=null){let r=this.resolveStory(t);return !r.ok||this.compositionSession&&this.compositionSession.partName!==r.story.partName&&(this.endComposition(),r=this.resolveStory(t),!r.ok)?false:(this.compositionSession||(this.compositionSession={partName:r.story.partName,beforePackage:this.currentPackage(),storyCheckpoint:r.store.checkpoint(),packageWideEffects:false}),r.store.beginComposition(n),true)}endComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.endComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return;let r=n.historyDepth;if(n.endComposition(),t.packageWideEffects){n.restoreHistoryStacks(t.storyCheckpoint),this.syncPackageFromStore(n),this.pushUndoPointer({kind:"package",before:t.beforePackage,after:this.currentPackage()});return}if(n.historyDepth>r){let o=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);o&&this.pushUndoPointer({kind:"story",partName:t.partName,story:o});}this.syncPackageFromStore(n);}cancelComposition(){let t=this.compositionSession;if(this.compositionSession=null,!t){this.body.cancelComposition();return}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(t.packageWideEffects){n&&n.restoreCheckpoint(t.storyCheckpoint),this.installPackageSnapshotInternal(t.beforePackage),this.packageRev+=1;let r=t.partName===this.body.part.name?{kind:"body",partName:t.partName}:this.storyRefForPart(t.partName);this.publishSynthetic(chunk24APKZAN_cjs.b.mutationHuman,"global",r??{kind:"body",partName:this.body.part.name},[]);return}n?.cancelComposition();}applyLifecycleOp(t){return chunk24APKZAN_cjs.xa(this,()=>this.commitLifecycleOp(t),chunk24APKZAN_cjs.ya)}commitLifecycleOp(t){let n=this.currentPackage();if(chunk24APKZAN_cjs.jf(t)){let a=chunk24APKZAN_cjs.kf(n,t);if(!a.ok)return {ok:false,reason:a.reason,...a.detail?{detail:a.detail}:{}};if(a.package===n)return {ok:true,change:null};this.installPackageSnapshotInternal(a.package),this.pushUndoPointer({kind:"package",before:n,after:a.package}),this.packageRev+=1;let s={kind:"body",partName:this.body.part.name},l=this.publishSynthetic(chunk24APKZAN_cjs.b.mutationHuman,a.impact,s,a.createdPartName?[a.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:l}}if(!chunk24APKZAN_cjs.Md(t))return {ok:false,reason:"invalidArgs",detail:"not-lifecycle-op"};let r=chunk24APKZAN_cjs.Nd(n,t);if(!r.ok)return {ok:false,reason:r.reason,...r.detail?{detail:r.detail}:{}};this.installPackageSnapshotInternal(r.package),this.pushUndoPointer({kind:"package",before:n,after:r.package}),this.packageRev+=1;let o={kind:"body",partName:this.body.part.name},i=this.publishSynthetic(chunk24APKZAN_cjs.b.mutationHuman,r.impact,o,r.createdPartName?[r.createdPartName]:[]);return this.evictUnreachableStories(),{ok:true,change:i}}undo(){let t=this.undoOrder.pop();if(!t)return null;if(t.kind==="package"){this.installPackageSnapshotInternal(t.before),this.redoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(chunk24APKZAN_cjs.b.mutationUndo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.undo();return r?(this.redoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}redo(){let t=this.redoOrder.pop();if(!t)return null;if(t.kind==="package"){this.installPackageSnapshotInternal(t.after),this.undoOrder.push(t),this.packageRev+=1;let o=this.publishSynthetic(chunk24APKZAN_cjs.b.mutationRedo,"global",{kind:"body",partName:this.body.part.name},[]);return this.evictUnreachableStories(),o}let n=t.partName===this.body.part.name?this.body:this.stories.get(t.partName);if(!n)return null;let r=n.redo();return r?(this.undoOrder.push(t),this.syncPackageFromStore(n),this.packageRev+=1,this.publish(r),this.evictUnreachableStories(),r):null}selectionForUndo(){let t=this.undoOrder[this.undoOrder.length-1];return !t||t.kind==="package"?null:(t.partName===this.body.part.name?this.body:this.stories.get(t.partName))?.selectionForUndo()??null}selectionForRedo(){let t=this.redoOrder[this.redoOrder.length-1];return !t||t.kind==="package"?null:(t.partName===this.body.part.name?this.body:this.stories.get(t.partName))?.selectionForRedo()??null}openStoryParts(){return xn(this.stories,this.pkg)}openedStoryCount(){return 1+this.stories.size}openStoryToken(){return Fo(this.stories,this.pkg)}insertImage(t,n){return ua(this,t,n)}applyFragmentPaste(t,n){return Uo(this,t,n)}replaceImage(t,n,r,o,i,a){return Rn(this,t,n,r,o,i,a)}deleteImage(t,n){return pa(this,t,n)}deleteImageTracked(t,n,r){return fa(this,t,n,r)}embedExternalImage(t,n,r,o,i,a,s){return ga(this,t,n,r,o,i,a,s)}setDrawingMetadataWithHyperlink(t,n,r,o,i){return ha(this,t,n,r,o,i)}applyImageProperties(t,n){return ya(this,t,n)}promoteStoryTransactionToPackageUnit(t,n,r,o){this.installPackageSnapshotInternal(n.package),n.historyDepth>o&&n.restoreHistoryStacks(r),this.pushUndoPointer({kind:"package",before:t,after:this.currentPackage()}),this.packageRev+=1;let i=n.part.name===this.body.part.name?{kind:"body",partName:n.part.name}:this.storyRefForPart(n.part.name);return this.publishSynthetic(chunk24APKZAN_cjs.b.mutationHuman,i?.kind==="headerFooter"?"global":"flow-structural",i??{kind:"body",partName:this.body.part.name},[])}publishStoryWrite(t){return t?(this.packageRev+=1,this.publish(t),t):null}adoptPackageUnit(t){let n=this.currentPackage();t!==n&&this.pushUndoPointer({kind:"package",before:t,after:n});}installPackageSnapshot(t){this.installPackageSnapshotInternal(t);}installAuthoritativePackageSnapshot(t){this.installPackageSnapshotInternal(t,false);}publishRemotePackage(t,n){return Pa(this,t,n)}replacePackageShell(t){this.shellHyperlinks=Go(this.shellHyperlinks,this.pkg,t);let n=t;n=chunk24APKZAN_cjs.Yb(n,this.body.part);for(let r of this.stories.values())t.parts.has(r.part.name)&&(n=chunk24APKZAN_cjs.Yb(n,r.part));this.pkg=n;}installPackageSnapshotInternal(t,n=true){let r=n?Yo(t,this.pkg,this.shellHyperlinks):t,o=r.parts.get(r.mainDocumentPart);if(!o)return;this.body.replacePart(o);for(let[a,s]of this.stories){let l=r.parts.get(a);l&&s.replacePart(l);}this.rIdToPartName.clear();let i=r.relationships.get(r.mainDocumentPart)??[];for(let a of i){if(a.type!==Pn&&a.type!==On)continue;let s=chunk24APKZAN_cjs.E(a);s.mode!=="Internal"||!s.target.ok||this.stories.has(s.target.partName)&&r.parts.has(s.target.partName)&&this.rIdToPartName.set(a.id,s.target.partName);}this.pkg=r,this.pkg=chunk24APKZAN_cjs.Yb(this.pkg,this.body.part);for(let a of this.stories.values())this.pkg.parts.has(a.part.name)&&(this.pkg=chunk24APKZAN_cjs.Yb(this.pkg,a.part));}openNotesPartStore(t){let n=chunk24APKZAN_cjs.Xe(this.currentPackage(),t);if(!n)return {ok:false,reason:"missing-part",detail:t};let r=this.stories.get(n.name);if(r)return {ok:true,story:{kind:"notesPart",partName:n.name,noteKind:t},store:r};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let o=chunk24APKZAN_cjs.Cb(n),i=new We(o,{historyLimit:this.historyLimit,settingsPart:()=>chunk24APKZAN_cjs.ve(this.pkg)}),a={kind:"notesPart",partName:o.name,noteKind:t};return i.setStoryRef(a),this.stories.set(o.name,i),o!==n&&(this.pkg=chunk24APKZAN_cjs.Yb(this.pkg,o)),{ok:true,story:a,store:i}}openHeaderFooterStore(t){let n=this.rIdToPartName.get(t);if(n){let l=this.stories.get(n);if(l)return {ok:true,story:{kind:"headerFooter",partName:n,rId:t},store:l}}let r=sa(this.currentPackage(),t);if(!r.ok)return r;let o=this.stories.get(r.partName);if(o)return this.rIdToPartName.set(t,r.partName),{ok:true,story:{kind:"headerFooter",partName:r.partName,rId:t},store:o};if(this.openedStoryCount()>=this.maxEditableStoryParts&&this.evictUnreachableStories(),this.openedStoryCount()>=this.maxEditableStoryParts)return {ok:false,reason:"too-many-story-stores",detail:String(this.maxEditableStoryParts)};let i=chunk24APKZAN_cjs.Cb(r.part),a=new We(i,{historyLimit:this.historyLimit,settingsPart:()=>chunk24APKZAN_cjs.ve(this.pkg)}),s={kind:"headerFooter",partName:i.name,rId:t};return a.setStoryRef(s),this.stories.set(i.name,a),this.rIdToPartName.set(t,i.name),i!==r.part&&(this.pkg=chunk24APKZAN_cjs.Yb(this.pkg,i)),{ok:true,story:s,store:a}}storyRefForPart(t){if(t===this.body.part.name)return {kind:"body",partName:t};for(let[r,o]of this.rIdToPartName)if(o===t)return {kind:"headerFooter",partName:t,rId:r};let n=this.currentPackage().parts.get(t);return n?.root.localName==="footnotes"?{kind:"notesPart",partName:t,noteKind:"footnote"}:n?.root.localName==="endnotes"?{kind:"notesPart",partName:t,noteKind:"endnote"}:null}syncPackageFromStore(t){this.pkg=chunk24APKZAN_cjs.Yb(this.pkg,t.part);}pushUndoPointer(t){this.undoOrder.push(t),this.redoOrder.length=0,this.undoOrder.length>this.historyLimit&&this.undoOrder.shift(),this.evictUnreachableStories();}evictUnreachableStories(){let t=Ra(this.pkg,this.stories.keys(),this.undoOrder,this.redoOrder);for(let[o]of [...this.stories])if(!t.has(o)){this.stories.delete(o);for(let[i,a]of [...this.rIdToPartName])a===o&&this.rIdToPartName.delete(i);}let n=ba(t,this.pkg.mainDocumentPart,this.body.part.name,this.undoOrder,this.redoOrder),r=qo(this.pkg,n);r!==this.pkg&&(this.pkg=r),this.shellHyperlinks=Xo(this.shellHyperlinks,n,this.pkg.mainDocumentPart);}publish(t){this.lastChange=t;for(let n of this.subscribers)n(t);}publishSynthetic(t,n,r,o){this.commitCounter+=1;let i=this.packageRev-1,a={change:"model-change",fromRevision:i<0?0:i,toRevision:this.packageRev,commitId:`pkg-commit-${this.commitCounter}`,origin:t,dirty:[],created:[...o],deleted:[],splitJoin:[],dependencyKeys:[],impact:n,story:r};return this.publish(a),a}};function Ls(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Sa(e,t){if(!e){let a=chunk24APKZAN_cjs.Fb(t);return a?chunk24APKZAN_cjs.Gb(new Set,a,chunk24APKZAN_cjs.Db):"0"}let n=-1,r=new Set,o=a=>{if(a.kind!=="textValue"){if(a.kind==="comment"){let s=Ls(a,chunk24APKZAN_cjs.ca,"id");if(s!==void 0&&/^\d{1,10}$/.test(s)){let l=Number(s);Number.isSafeInteger(l)&&l<=chunk24APKZAN_cjs.Db&&(r.add(String(l)),l>n&&(n=l));}}for(let s of a.children)o(s);}};o(e.root);let i=chunk24APKZAN_cjs.Fb(t);return i?chunk24APKZAN_cjs.Gb(r,i,chunk24APKZAN_cjs.Db):String(n+1)}var $s=256,Bs=65535,Ta=64;function Lt(e,t){return e.length>t}function wa(e){return typeof e!="string"||e.trim().length===0?"invalid-author":Lt(e,$s)?"resource-limit":chunk24APKZAN_cjs.O(e)?null:"invalid-author"}function Ea(e){return typeof e!="string"||e.length===0?"invalid-text":Lt(e,Bs)?"resource-limit":chunk24APKZAN_cjs.O(e)?null:"invalid-text"}function vn(e){if(typeof e!="string")return {ok:false,rejection:"invalid-date"};let t=e.trim();if(Lt(t,Ta))return {ok:false,rejection:"resource-limit"};if(!chunk24APKZAN_cjs.O(t))return {ok:false,rejection:"invalid-date"};let n=chunk24APKZAN_cjs.He(t);return n===null?{ok:false,rejection:"invalid-date"}:Lt(n,Ta)?{ok:false,rejection:"resource-limit"}:{ok:true,value:n}}function Fm(e){if(e===void 0)return null;let t=vn(e);return t.ok?null:t.rejection}function Nn(e){switch(e){case "invalid-author":return "invalid-author";case "invalid-text":return "invalid-text";case "invalid-date":return "invalid-property-value";case "resource-limit":return "resource-limit"}}function Ca(e,t){if(e.kind==="textValue")return e;let n=t.get(e.id);if(n!==void 0)return n;let r=false,o=[];for(let i of e.children){let a=Ca(i,t);a!==i&&(r=true),o.push(a);}return r?{...e,children:o}:e}function Ws(e,t,n){let r=Ca(e.root,t);if(r.kind==="textValue")return {ok:false,issues:[{code:"known-node-invariant",path:e.root.id,nodeId:e.root.id}]};let o=n===null?r:{...r,namespaceBindings:[...r.namespaceBindings,{prefix:n,namespaceUri:chunk24APKZAN_cjs.fa}]};return chunk24APKZAN_cjs.Ha(e,e.root.id,o,{deferValidation:true})}function Ma(e,t,n){let r=new Map;for(let i of t){if(i.stampParagraph===null)continue;let a=r.get(i.commentsPartName);a||(a=new Map,r.set(i.commentsPartName,a)),a.set(i.stampParagraph.id,{paragraph:i.stampParagraph,paraId:i.paraId});}let o=e;for(let[i,a]of r){let s=o.parts.get(i);if(!s)return null;let l=chunk24APKZAN_cjs.Ab(s.root),d=l??"w14",c=new Map;for(let m of a.values())c.set(m.paragraph.id,n(m.paragraph,m.paraId,d));let u=Ws(s,c,l===null?d:null);if(!u.ok)return null;o=chunk24APKZAN_cjs.Yb(o,u.part);}return o}function Da(e,t,n){let r=e.root.children.map(o=>o.kind==="textValue"?o:t.get(o.id)??o);return chunk24APKZAN_cjs.Fa(e,e.root.id,[...r,...n],{deferValidation:true})}var Ua="/word/comments.xml",Fa="/word/commentsExtended.xml",Cn="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",Mn="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",Vs=[Mn,"application/vnd.ms-word.commentsExtended+xml"],La="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",Dn="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",Ie="http://schemas.microsoft.com/office/word/2012/wordml";function ct(e,t,n){for(let r of e.attributes)if(r.localName===n&&r.namespaceUri===t)return r.value}function Ge(e,t){return {kind:"genericExtension",namespaceUri:chunk24APKZAN_cjs.ca,localName:e,prefix:"w",value:t}}function ke(e,t,n,r,o,i,a,s=[]){return {id:e,kind:t,namespaceUri:n,localName:o,prefix:r,namespaceBindings:s,attributes:i,children:a}}function $a(e,t,n,r,o){let i=t===e.mainDocumentPart?[t]:[t,e.mainDocumentPart];for(let a of i)for(let s of chunk24APKZAN_cjs._b(e,a)){if(s.type!==n)continue;let l=chunk24APKZAN_cjs.w(a,s.rawTarget);if(!l.ok)continue;if(!e.parts.has(l.partName))return l.partName;let d=chunk24APKZAN_cjs.$b(e,l.partName);if(d!==null&&(typeof r=="string"?d===r:r.includes(d)))return l.partName}return o}function Sn(e,t,n){let r=e.mainDocumentPart;for(let i of chunk24APKZAN_cjs._b(e,r)){if(i.type!==t)continue;let a=chunk24APKZAN_cjs.w(r,i.rawTarget);if(a.ok&&a.partName===n)return e}let o=chunk24APKZAN_cjs.dc(e,r);return chunk24APKZAN_cjs.ec(o,r,t,chunk24APKZAN_cjs.pg(r,n)).pkg}function An(e,t){return $a(e,t,La,Cn,Ua)}function Ba(e,t){let n=chunk24APKZAN_cjs.of(e,t),r=chunk24APKZAN_cjs.pf(e,t,n).extended;return r!==null?r:$a(e,t,Dn,Vs,Fa)}function Aa(e){let t=new Set;for(let n of e.parts.values())for(let r of chunk24APKZAN_cjs.zb(n.root))t.add(r);return t}function Ks(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&ct(o,chunk24APKZAN_cjs.ca,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind!=="paragraph")continue;let s=ct(a,chunk24APKZAN_cjs.fa,"paraId");s!==void 0&&chunk24APKZAN_cjs.vb(s)&&(n=s.toUpperCase());return}return}for(let i of o.children)r(i);}};return r(e.root),n}function zs(e,t){if(!e)return null;let n=null,r=o=>{if(!(n!==null||o.kind==="textValue")){if(o.kind==="comment"&&ct(o,chunk24APKZAN_cjs.ca,"id")===t){for(let i=o.children.length-1;i>=0;i-=1){let a=o.children[i];if(a.kind==="paragraph"){n=a;return}}return}for(let i of o.children)r(i);}};return r(e.root),n}function Ha(e){let t=chunk24APKZAN_cjs.Ab(e.root);if(t!==null)return {part:e,prefix:t};let n={...e.root,namespaceBindings:[...e.root.namespaceBindings,{prefix:"w14",namespaceUri:chunk24APKZAN_cjs.fa}]},r=chunk24APKZAN_cjs.Ha(e,e.root.id,n,{deferValidation:true});return r.ok?{part:r.part,prefix:"w14"}:(chunk24APKZAN_cjs.Ea(e.root,n),{part:{...e,root:n},prefix:"w14"})}function ja(e,t,n){return ke(e.id,"paragraph",e.namespaceUri,e.prefix??"w",e.localName,[...e.attributes.filter(r=>!(r.namespaceUri===chunk24APKZAN_cjs.fa&&r.localName==="paraId")),{kind:"genericExtension",namespaceUri:chunk24APKZAN_cjs.fa,localName:"paraId",prefix:n,value:t}],e.children,e.namespaceBindings)}function Gs(e,t,n,r){let o=e.parts.get(t);if(!o)return e;let i=Ha(o),a=chunk24APKZAN_cjs.Ca(i.part,n);if(!a||a.kind!=="paragraph")return chunk24APKZAN_cjs.Yb(e,i.part);let s=chunk24APKZAN_cjs.Ha(i.part,a.id,ja(a,r,i.prefix),{deferValidation:true});return chunk24APKZAN_cjs.Yb(e,s.ok?s.part:i.part)}function Xs(e,t,n,r){let o=`${Ua}#comment-${e}`,i=n.text!==n.text.trim(),a=ke(`${o}.t`,"text",chunk24APKZAN_cjs.ca,"w","t",i?[{kind:"xmlSpace",namespaceUri:chunk24APKZAN_cjs.da,localName:"space",prefix:"xml",value:"preserve"}]:[],[{id:`${o}.tv`,kind:"textValue",value:n.text}]),s=ke(`${o}.rPr`,"runProperties",chunk24APKZAN_cjs.ca,"w","rPr",[],[ke(`${o}.rStyle`,"generic",chunk24APKZAN_cjs.ca,"w","rStyle",[Ge("val","CommentReference")],[])]),l=ke(`${o}.r`,"run",chunk24APKZAN_cjs.ca,"w","r",[],[s,a]),d=ke(`${o}.pPr`,"paragraphProperties",chunk24APKZAN_cjs.ca,"w","pPr",[],[ke(`${o}.pStyle`,"generic",chunk24APKZAN_cjs.ca,"w","pStyle",[Ge("val","CommentText")],[])]),c=ke(`${o}.p`,"paragraph",chunk24APKZAN_cjs.ca,"w","p",[{kind:"genericExtension",namespaceUri:chunk24APKZAN_cjs.fa,localName:"paraId",prefix:r,value:t}],[d,l]);return ke(o,"comment",chunk24APKZAN_cjs.ca,"w","comment",[Ge("id",e),Ge("author",n.author),...n.initials===void 0?[]:[Ge("initials",n.initials)],...n.date===void 0?[]:[Ge("date",n.date)]],[c])}function Tn(e,t){let n=chunk24APKZAN_cjs.ta(t,{name:e,contentType:"application/xml"});return n.ok?n.part.root:null}function Wa(e,t){for(let x of [wa(t.author),Ea(t.text)])if(x)return {ok:false,reason:Nn(x)};let n;if(t.date!==void 0){let x=vn(t.date);if(!x.ok)return {ok:false,reason:Nn(x.rejection)};n=x.value;}let r={...t,...n===void 0?{}:{date:n}},o=e.package,i=e.part.name,a=An(o,i),s=Ba(o,i),l=o.parts.get(a),d=Sa(l,r.actorId),c=chunk24APKZAN_cjs.yb(`${a}#${d}`,Aa(o)),u=t.replyToCommentId===void 0?null:Ks(l,t.replyToCommentId),m=t.replyToCommentId!==void 0&&u===null?zs(l,t.replyToCommentId):null;if(t.replyToCommentId!==void 0&&u===null&&!m)return {ok:false,reason:"unknown-revision"};let g=m?chunk24APKZAN_cjs.yb(`${a}#parent-${t.replyToCommentId}`,new Set([...Aa(o),c])):null,y=u??g,P=t.anchor.endParagraphId??t.anchor.paragraphId,f=e.transact(x=>{x.applyPackage(p=>{let k=p.parts.has(a)?p:(()=>{let w=Tn(a,`<w:comments xmlns:w="${chunk24APKZAN_cjs.ca}"/>`);return w?chunk24APKZAN_cjs.fc(p,a,w,Cn):null})();return k===null?p:Sn(k,La,a)}),m&&g&&x.applyPackage(p=>Gs(p,a,m.id,g)),x.applyPackage(p=>{let k=p.parts.get(a);if(!k)return p;let w=Ha(k),T=chunk24APKZAN_cjs.Ga(w.part,w.part.root.id,w.part.root.children.length,[Xs(d,c,r,w.prefix)],{deferValidation:true});return T.ok?chunk24APKZAN_cjs.Yb(p,T.part):p}),y!==null&&(x.applyPackage(p=>{let k=p.parts.has(s)?p:(()=>{let w=Tn(s,`<w15:commentsEx xmlns:w15="${Ie}"/>`);return w?chunk24APKZAN_cjs.fc(p,s,w,Mn):null})();return k===null?p:Sn(k,Dn,s)}),x.applyPackage(p=>{let k=p.parts.get(s);if(!k)return p;let T=[...Ys(k).has(y.toUpperCase())?[]:[En(`${s}#ex-${y}`,y,void 0,false)],En(`${s}#ex-${c}`,c,y,false)],R=chunk24APKZAN_cjs.Ga(k,k.root.id,k.root.children.length,T,{deferValidation:true});return R.ok?chunk24APKZAN_cjs.Yb(p,R.part):p})),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:t.anchor.end,commentId:d,marker:"reference"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:P,offset:t.anchor.end,commentId:d,marker:"end"}),x.applyTo(i,{op:"insertCommentMarker",paragraphId:t.anchor.paragraphId,offset:t.anchor.start,commentId:d,marker:"start"});},r.actorId===void 0?{}:{actorId:r.actorId});return f.ok?{ok:true,commentId:d,change:f.change}:{ok:false,reason:f.reason}}function wn(e){for(let t=e.children.length-1;t>=0;t-=1){let n=e.children[t];if(n.kind==="paragraph")return n}return null}function _a(e){let t=wn(e);if(!t)return null;let n=ct(t,chunk24APKZAN_cjs.fa,"paraId");return n!==void 0&&chunk24APKZAN_cjs.vb(n)?n.toUpperCase():null}function Ys(e){let t=new Map;if(!e)return t;let n=r=>{if(r.kind!=="textValue"){if(r.namespaceUri===Ie&&r.localName==="commentEx"){let o=ct(r,Ie,"paraId");o!==void 0&&chunk24APKZAN_cjs.vb(o)&&t.set(o.toUpperCase(),r);}for(let o of r.children)n(o);}};return n(e.root),t}function dt(e,t){return {kind:"genericExtension",namespaceUri:Ie,localName:e,prefix:"w15",value:t}}function qs(e,t){return {id:e.id,kind:"generic",namespaceUri:e.namespaceUri,localName:e.localName,...e.prefix===void 0?{}:{prefix:e.prefix},namespaceBindings:e.namespaceBindings,attributes:t,children:e.children}}function Js(e,t,n){let r=[],o=false,i=false;for(let a of e.attributes){if(a.namespaceUri===Ie&&a.localName==="done"){o=true,r.push({kind:"genericExtension",namespaceUri:a.namespaceUri,localName:a.localName,...a.prefix===void 0?{}:{prefix:a.prefix},value:n?"1":"0"});continue}a.namespaceUri===Ie&&a.localName==="paraIdParent"&&(i=true),r.push(a);}return !i&&t!==void 0&&r.push(dt("paraIdParent",t)),o||r.push(dt("done",n?"1":"0")),qs(e,r)}function En(e,t,n,r){return {id:e,kind:"generic",namespaceUri:Ie,localName:"commentEx",prefix:"w15",namespaceBindings:[],attributes:[dt("paraId",t),...n===void 0?[]:[dt("paraIdParent",n)],dt("done",r?"1":"0")],children:[]}}function Va(e,t,n){return Qs(e,t,n,chunk24APKZAN_cjs.nf())}function Qs(e,t,n,r){let o=e.package,i=e.part.name;if(chunk24APKZAN_cjs.of(o,i)===null)return {ok:false,reason:"unknown-comment"};let s=chunk24APKZAN_cjs.rf(o,t,{storyPartName:i},r);if(!s.ok)return {ok:false,reason:"unknown-comment"};let l=chunk24APKZAN_cjs.qf(o,r);if(l.truncated||r.truncated)return {ok:false,reason:"unknown-comment"};let d=l.used,c=new Map,u=[];for(let P of s.ids){let f=s.records.get(P);if(!f)return {ok:false,reason:"unknown-comment"};if(!wn(f.node))return {ok:false,reason:"unknown-comment"};let p=_a(f.node),k=p??chunk24APKZAN_cjs.yb(`${f.partName}#done-${P}`,d);p===null&&d.add(k),c.set(P,k);}for(let P of s.ids){let f=s.records.get(P),x=wn(f.node),p=c.get(P),k=_a(f.node),w=s.parentCommentIdByChildId.get(P),T=s.parentParaIdByCommentId.get(P)??(w===void 0?void 0:c.get(w)),R=s.commentExByParaId.get(p);u.push({paraId:p,stampParagraph:k===null?x:null,commentsPartName:f.partName,parentParaId:T,existing:R?.node,existingParentParaId:R?.parentParaId,existingDone:R?.done??false});}if(u.length===0)return {ok:false,reason:"unknown-comment"};if(u.every(P=>P.existingDone===n))return {ok:true,changed:false,change:null};let m=s.extendedPartName??Fa,g=s.extendedPartName===null,y=e.transact(P=>{P.applyPackage(f=>{let x=Ma(f,u,ja);if(x===null)return f;let p=x;if(!p.parts.has(m)){let S=Tn(m,`<w15:commentsEx xmlns:w15="${Ie}"/>`);if(!S)return f;let D=chunk24APKZAN_cjs.fc(p,m,S,Mn);p=g?Sn(D,Dn,m):D;}let k=p.parts.get(m);if(!k)return f;let w=new Map,T=[];for(let S of u){let D=S.existingParentParaId??S.parentParaId;S.existing?w.set(S.existing.id,Js(S.existing,D,n)):T.push(En(`${m}#done-${S.paraId}`,S.paraId,D,n));}let R=Da(k,w,T);return R.ok?chunk24APKZAN_cjs.Yb(p,R.part):f});});return y.ok?{ok:true,changed:true,change:y.change}:{ok:false,reason:y.reason}}function au(e,t){let n=An(e,t);return e.parts.has(n)&&chunk24APKZAN_cjs.$b(e,n)===Cn}function iu(e,t){return An(e,t)}function su(e,t){return Ba(e,t)}var Ka={kind:"body"};function pu(e,t,n=Ka){let r=n.kind==="body"?null:e.resolveStory(n),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),chunk24APKZAN_cjs.xa(e,()=>{let s=Wa(o,t);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>chunk24APKZAN_cjs.ya(s))}function fu(e,t,n){let r=e.bodyStore(),o=e.currentPackage(),i=r.checkpoint();return r.graftPackage(()=>e.currentPackage()),chunk24APKZAN_cjs.xa(e,()=>{let a=Va(r,t,n);return !a.ok||!a.changed||(r.restoreHistoryStacks(i),e.replacePackageShell(r.package),e.adoptPackageUnit(o),e.publishStoryWrite(a.change)),a},a=>a.ok&&a.changed)}function gu(e,t,n=Ka,r){if(t.length===0)return false;let o=n.kind==="body"?e.bodyStore().part:e.partFor(n);if(!o)return false;let i={storyPartName:o.name,...r===void 0?{}:{noteId:r}},a=e.bodyStore(),s=e.currentPackage(),l=a.checkpoint();return a.graftPackage(()=>e.currentPackage()),chunk24APKZAN_cjs.xa(e,()=>{let d=false,c=false,u=a.transact(m=>{m.applyPackage(g=>{let y=g;for(let P of t){let f=P.parentCommentId===void 0?chunk24APKZAN_cjs.Af(y,P.commentId,i):chunk24APKZAN_cjs.Bf(y,P.commentId,P.parentCommentId,i);if(f===null)return d=true,g;c||=f!==y,y=f;}return y});});return d||!u.ok||!c?false:(a.restoreHistoryStacks(l),e.installPackageSnapshot(a.package),e.adoptPackageUnit(s),e.publishStoryWrite(u.change),true)},d=>d)}var Zs=256*1024,el=4096;function Ga(e,t,n){let r=t.payload,o=e.part.name,i=n??o;if(r){if(r.data.length>Zs)return {ok:false,reason:"payload-too-large",detail:"data"};if(r.label.length>el)return {ok:false,reason:"payload-too-large",detail:"label"}}let a=new Set(chunk24APKZAN_cjs.Xf(e.part.root).map(m=>m.node.id)),s=t.replaceControlId===void 0?[]:Xa(e,o,t.replaceControlId),l=null,d,c=e.transact(m=>{if(t.replaceControlId!==void 0){m.apply({op:"removeContentControl",controlId:t.replaceControlId,keepContent:false});for(let P of s)m.applyPackage(f=>chunk24APKZAN_cjs.xg(f,P.partName,P.nodeId));}let g=t.replaceUntil;if(g!==void 0&&g<=t.offset){l="invalid-range",d="replaceUntil must be past offset";return}if(g!==void 0&&m.apply({op:"deleteText",paragraphId:t.paragraphId,start:t.offset,end:g}),!r){m.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock}});return}let y=null;m.applyPackage(P=>{let f=chunk24APKZAN_cjs.sg(P,i,r.namespaceUri,r.rootLocalName);if(!f.part)return l="store-not-authored",d=`no customXml store could be created for ${r.namespaceUri}. The namespace must be free of control characters and quotes, the root name must be an XML name, and a store this document already carries for that namespace must use the same root name (${r.rootLocalName})`,P;if(y=chunk24APKZAN_cjs.Cg(f.part,r.rootLocalName,r.nodeId),!y)return l="unaddressable-payload",d=`the node id ${JSON.stringify(r.nodeId)} or the namespace ${JSON.stringify(r.namespaceUri)} cannot be written into an XPath. Ids and root names must match [A-Za-z_][\\w.-]{0,127}; a namespace may not contain a quote, an angle bracket or an ampersand`,P;let x=chunk24APKZAN_cjs.wg(f.pkg,f.part.partName,{id:r.nodeId,label:r.label,data:r.data});return chunk24APKZAN_cjs.vg(x,f.part.partName,r.nodeId)?x:(l="store-not-authored",d="the payload node could not be written into the store",P)}),!(l!==null||!y)&&m.apply({op:"insertInlineContentControl",paragraphId:t.paragraphId,offset:t.offset,tag:t.tag,text:t.text,...t.alias===void 0?{}:{alias:t.alias},...t.lock===void 0?{}:{lock:t.lock},dataBinding:y});});if(l!==null)return {ok:false,reason:l,...d===void 0?{}:{detail:d}};if(!c.ok)return {ok:false,reason:c.reason,...c.detail===void 0?{}:{detail:c.detail}};let u=tl(e,a);return {ok:true,change:c.change,...u===void 0?{}:{nodeId:u}}}function tl(e,t){for(let n of chunk24APKZAN_cjs.Xf(e.part.root))if(!t.has(n.node.id))return n.node.id}function Xa(e,t,n){let r=chunk24APKZAN_cjs.Xf(e.part.root).find(i=>i.node.id===n);if(!r)return [];let o=[];for(let i of chunk24APKZAN_cjs.qg(e.package,t)){let a=chunk24APKZAN_cjs.Fg(r.node,i.itemId);a!==null&&o.push({partName:i.partName,nodeId:a});}return o}function Ya(e,t){let n=e.part.name,r=Xa(e,n,t),o=e.transact(i=>{i.apply({op:"removeContentControl",controlId:t,keepContent:false});for(let a of r)i.applyPackage(s=>chunk24APKZAN_cjs.xg(s,a.partName,a.nodeId));});return o.ok?{ok:true,change:o.change}:{ok:false,reason:o.reason,...o.detail===void 0?{}:{detail:o.detail}}}function Ou(e,t,n){if(!e.parts.has(t)||n.length===0)return {ok:true,pkg:e,removed:[]};let r=e,o=[];for(let i of n){let a=chunk24APKZAN_cjs.rg(r,t,i);if(!a)continue;let s=chunk24APKZAN_cjs.Eg(r,a.itemId),l=chunk24APKZAN_cjs.yg(r,a.partName,s);if(l.pkg===r&&chunk24APKZAN_cjs.ug(r,a.partName).some(d=>!s.has(d.id)))return {ok:false,reason:`the payload store for ${i} refused the sweep`};r=l.pkg,o.push(...l.removed);}return {ok:true,pkg:r,removed:o}}var za=new WeakMap;function nl(e,t){let n=za.get(e);n||(n=new Map,za.set(e,n));let r=n.get(t);if(r)return r;let o=chunk24APKZAN_cjs.qg(e,t).map(i=>({itemId:i.itemId,nodes:new Map(chunk24APKZAN_cjs.ug(e,i.partName).map(a=>[a.id,a]))}));return n.set(t,o),o}function Iu(e,t,n=t){let r=new Map,o=e.parts.get(t);if(!o)return r;let i=nl(e,n);if(i.length===0)return r;for(let a of chunk24APKZAN_cjs.Xf(o.root))for(let s of i){let l=chunk24APKZAN_cjs.Fg(a.node,s.itemId);if(l===null)continue;let d=s.nodes.get(l);if(d){r.set(a.node.id,{nodeId:l,label:d.label,data:d.data});break}}return r}function Ru(e,t,n){let r=new Map,o=chunk24APKZAN_cjs.rg(e,t,n);if(!o)return r;for(let i of chunk24APKZAN_cjs.ug(e,o.partName))r.set(i.id,{label:i.label,data:i.data});return r}var qa={kind:"body"};function Ja(e,t,n){let r=t.kind==="body"?null:e.resolveStory(t),o=r?.ok?r.store:e.bodyStore(),i=e.currentPackage(),a=o.checkpoint();return o.graftPackage(()=>e.currentPackage()),chunk24APKZAN_cjs.xa(e,()=>{let s=n(o);return s.ok&&(o.restoreHistoryStacks(a),e.replacePackageShell(o.package),e.adoptPackageUnit(i),e.publishStoryWrite(s.change)),s},s=>chunk24APKZAN_cjs.ya(s))}function Su(e,t,n=qa){return Ja(e,n,r=>Ga(r,t,e.bodyStore().part.name))}function Tu(e,t,n=qa){return Ja(e,n,r=>Ya(r,t))}var Xe="proposed";function rl(e,t){switch(e){case "revisionInsert":case "revisionMoveTo":return t!=="original";case "revisionDelete":case "revisionMoveFrom":return t!=="proposed";default:return false}}var ol=32;function _n(e,t=Xe,n){let r=[];return mt(e.children,t,n,0,r),r}function Un(e,t,n,r,o=Xe,i){let a=[];for(let s of _n(e,o,i)){let l=t.get(s.id);if(!l||l.end<=l.start)continue;let d=Math.max(l.start,n),c=Math.min(l.end,r);d>=c||a.push({run:s,start:d,end:c});}return a}function mt(e,t,n,r,o){if(!(r>=ol)){for(let i of e)if(!(i.kind==="textValue"||i.kind==="paragraphProperties")){if(i.kind==="run"){o.push(i);continue}if(i.kind==="hyperlink"){mt(i.children,t,n,r+1,o);continue}if(chunk24APKZAN_cjs.ja(i.kind)){let a=chunk24APKZAN_cjs.Fe(i,"author")??"",s=n?.includesNode?.(i.id,a)??!n?.hiddenAuthors.has(a),l=n&&!s?n.excludedNodeMode?.(i.id,a)??"proposed":t;if(!rl(i.kind,l))continue;mt(i.children,t,n,r+1,o);continue}if(chunk24APKZAN_cjs.Rc(i)){mt(i.children,t,n,r+1,o);continue}if(chunk24APKZAN_cjs.De(i)){let a=chunk24APKZAN_cjs.Ee(i);a&&mt(a.children,t,n,r+1,o);continue}}}}var al=new Set(chunk24APKZAN_cjs.hf),Ln=new Set(chunk24APKZAN_cjs.gf);function Bu(e){return Ln.has(e)}function $t(e,t,n){return !e||e.kind==="textValue"?void 0:e.children.find(o=>o.kind===t||o.kind==="generic"&&o.localName===n&&o.namespaceUri===chunk24APKZAN_cjs.ca)}function $n(e,t){if(!e||e.kind==="textValue")return [];let n=[];for(let r of e.children){if(r.kind==="textValue"||!t.has(r.localName))continue;let o=chunk24APKZAN_cjs.J();for(let i of r.attributes)o[i.localName]=i.value;n.push(Object.keys(o).length>0?{localName:r.localName,attributes:o}:{localName:r.localName});}return n}function Hu(e,t){let n=chunk24APKZAN_cjs.Ca(e,t);return $n($t(n,"paragraphProperties","pPr"),al)}function il(e,t){let n=chunk24APKZAN_cjs.Ca(e,t),r=$t(n,"paragraphProperties","pPr");return $n($t(r,"runProperties","rPr"),Ln)}function Qa(e,t){let n=Array.isArray(t)?t:[t],r=new Set(n.map(i=>i.localName));return [...e.filter(i=>!r.has(i.localName)),...n]}var sl=new Map([["ascii","asciiTheme"],["hAnsi","hAnsiTheme"],["eastAsia","eastAsiaTheme"],["cs","cstheme"]]);function ll(e,t){let n=e.find(o=>o.localName==="rFonts")?.attributes;if(!n)return t;let r={...n,...t.attributes??{}};for(let o of Object.keys(t.attributes??{})){let i=sl.get(o);i&&delete r[i];}return {localName:"rFonts",attributes:r}}function Bn(e){let t=new Map;for(let n of chunk24APKZAN_cjs.Ne(e)){let r=n.formatRunIds&&n.formatRunIds.length>0?n.formatRunIds:n.runId?[n.runId]:[];for(let o of r){let i=t.get(o);i?(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end)):t.set(o,{start:n.start,end:n.end});}}return t}function dl(e){let t=new Set;for(let n of chunk24APKZAN_cjs.Ne(e))if(n.formatRunIds)for(let r of n.formatRunIds)t.add(r);return t}function Fn(e,t){if(t.localName==="rFonts")return ll(e,t);if(t.localName!=="u")return t;let n=e.find(r=>r.localName==="u")?.attributes;return n?{localName:"u",attributes:{...n,...t.attributes??{}}}:t}function ju(e,t,n){let r=il(e,t),o=Array.isArray(n)?n:[n];return Qa(r,o.map(i=>Fn(r,i)))}function cl(e,t){return Array.isArray(t)?t.map(n=>Fn(e,n)):Fn(e,t)}function Wu(e,t,n,r,o,i=Xe,a){let s=chunk24APKZAN_cjs.Ca(e,t);if(!s||s.kind!=="paragraph")return [];let l=[],d=dl(s);for(let c of Un(s,Bn(s),n,r,i,a)){let u=$n($t(c.run,"runProperties","rPr"),Ln);l.push({start:c.start,end:c.end,properties:Qa(u,cl(u,o)),...d.has(c.run.id)?{targetRunIds:[c.run.id]}:{}});}return l}function Vu(e,t,n,r,o=Xe,i){let a=chunk24APKZAN_cjs.Ca(e,t);if(!a||a.kind!=="paragraph"||r<=n)return [];let s=[];for(let l of Un(a,Bn(a),n,r,o,i)){let d=s[s.length-1];d&&l.start<=d.end?d.end=Math.max(d.end,l.end):s.push({start:l.start,end:l.end});}return s}function Ku(e,t,n,r,o=Xe,i){let a=chunk24APKZAN_cjs.Ca(e,t);if(!a||a.kind!=="paragraph")return [];let s=Bn(a),l=[];for(let d of _n(a,o,i)){let c=s.get(d.id);if(!c||c.end<=c.start)continue;(r>n?Math.max(c.start,n)<Math.min(c.end,r):c.start<=n&&n<c.end)&&l.push(d);}return l}function Hn(e){return ni(e,true)}function Yu(e){return ni(e,false)}function ni(e,t){let n=t?ei.get(e.root):void 0;if(n)return n;let r=new Map,o=s=>{let l=t?Za.get(s):void 0;if(l){for(let[c,u]of l)r.set(c,u);return}let d=new Map;ul(s,d,t),t&&Za.set(s,d);for(let[c,u]of d)r.set(c,u);},i=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){o(s);return}for(let d of s.children)i(d,l+1);}};i(e.root,0);let a=(s,l)=>{if(!(s.kind==="textValue"||l>64)){if(s.kind==="paragraph"){let d=t?ti.get(s):void 0;if(!d){let c=[];ri(s,0,c,t),d=c,t&&ti.set(s,d);}for(let[c,u]of d)r.set(c,u);return}if(s.kind==="tableRow"){let d=t?Bt.get(s):void 0;d||(d=oi(s),t&&Bt.set(s,d));for(let[c,u]of d)r.set(c,u);}for(let d of s.children)a(d,l+1);}};return a(e.root,0),t&&ei.set(e.root,r),r}function ri(e,t,n,r){if(!(e.kind==="textValue"||t>64)){if(e.kind==="tableRow"){let o=r?Bt.get(e):void 0;o||(o=oi(e),r&&Bt.set(e,o));for(let i of o)n.push(i);}for(let o of e.children)ri(o,t+1,n,r);}}function oi(e){let t=null,n=(a,s)=>{if(!(t||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){t=a;return}for(let l of a.children)n(l,s+1);}};if(n(e,0),!t)return ml;let r={paragraphId:t.id,start:0,end:0},o=[],i=(a,s,l)=>{if(a.kind==="textValue"||l>64||a.kind==="paragraph")return;let d=s==="trPr"&&(a.localName==="ins"||a.localName==="del"),c=s==="tcPr"&&(a.localName==="cellIns"||a.localName==="cellDel");(d||c)&&o.push([a.id,r]);for(let u of a.children)i(u,a.localName,l+1);};return i(e,void 0,0),o}var ml=[],Za=new WeakMap,ei=chunk24APKZAN_cjs.sf(8),Bt=new WeakMap,ti=new WeakMap;function ul(e,t,n){let r=n?chunk24APKZAN_cjs.Pe(e):chunk24APKZAN_cjs.Qe(e),o=(s,l,d,c)=>{if(!(s.kind==="textValue"||c>64)){t.set(s.id,{paragraphId:e.id,start:l,end:d});for(let u of s.children)o(u,l,d,c+1);}},i=(s,l)=>{if(s.kind==="textValue"||l>64)return;let d=r.spanOf(s);if(s.kind==="run"){if(!d)return;t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)c.kind==="runProperties"&&o(c,d.start,d.end,l+1);return}d&&t.set(s.id,{paragraphId:e.id,start:d.start,end:d.end});for(let c of s.children)i(c,l+1);};for(let s of e.children)s.kind!=="paragraphProperties"&&i(s,0);let a=e.children.find(s=>s.kind==="paragraphProperties");a&&o(a,r.length,r.length,0);}function pl(e){let t=ai.get(e.root);if(t)return t;let n=new Map,r=(o,i)=>{if(!(o.kind==="textValue"||i>64)){if(o.kind==="paragraph"){n.has(o.id)||n.set(o.id,n.size);return}if(o.kind==="table"){let a=di.get(o);if(!a){let s=[],l=(d,c)=>{if(!(d.kind==="textValue"||c>64)){if(d.kind==="paragraph"){s.push(d.id);return}for(let u of d.children)l(u,c+1);}};for(let d of o.children)l(d,0);a=s,di.set(o,a);}for(let s of a)n.has(s)||n.set(s,n.size);return}for(let a of o.children)r(a,i+1);}};return r(e.root,0),ai.set(e.root,n),n}var ai=chunk24APKZAN_cjs.sf(8);function jn(e){let t=li.get(e.root);if(t)return t;let n=new Map;for(let r of ci(e.root,0))n.has(r)||n.set(r,n.size);return li.set(e.root,n),n}var ii=Object.freeze([]),si=new WeakMap;function ci(e,t){if(e.kind==="textValue"||t>64)return ii;let n=si.get(e);if(n&&n.depth===t)return n.ids;let r=null;e.kind==="paragraph"&&(r??=[]).push(e.id);for(let i of e.children){let a=ci(i,t+1);if(a.length!==0){r??=[];for(let s of a)r.push(s);}}let o=r??ii;return si.set(e,{depth:t,ids:o}),o}var li=chunk24APKZAN_cjs.sf(8),di=new WeakMap;var ui=new WeakMap;function ut(e,t){return ui.set(e,t),e}function Ye(e){return ui.get(e)??[]}function Zu(e){return `${e.kind}-${e.id}`}function pi(e){return e.kind==="revision"?e.ranges:e.range?[e.range]:[]}function fl(e){return pi(e)[0]??null}function Wn(e,t){let n=fl(e);if(!n)return Number.MAX_SAFE_INTEGER;let r=t.get(n.start.paragraphId);return r===void 0?Number.MAX_SAFE_INTEGER:r*1e6+Math.min(n.start.offset,999999)}function gl(e,t){let n=t.get(e.start.paragraphId),r=t.get(e.end.paragraphId);return n===void 0||r===void 0?Number.MAX_SAFE_INTEGER:(r-n)*1e6+(e.end.offset-e.start.offset)}var hl=0,yl=1,xl=2;function kl(e,t,n){let r=n.get(t.paragraphId),o=n.get(e.start.paragraphId),i=n.get(e.end.paragraphId);return r===void 0||o===void 0||i===void 0||r<o||r>i||r===o&&t.offset<e.start.offset||r===i&&t.offset>e.end.offset?null:o===i&&e.start.offset===e.end.offset?hl:r===i&&t.offset===e.end.offset?xl:yl}function Pl(e,t,n){let r=null;for(let o of pi(e)){let i=kl(o,t,n);if(i===null)continue;let a=gl(o,n);(r===null||i<r.grip||i===r.grip&&a<r.width)&&(r={grip:i,width:a});}return r}var mi={comment:0,custom:1,revision:2};function Ol(e,t,n){let r=[];for(let o of e){let i=Pl(o,t,n);i!==null&&r.push({item:o,grip:i.grip,width:i.width});}return r.sort((o,i)=>o.grip!==i.grip?o.grip-i.grip:o.width!==i.width?o.width-i.width:o.item.kind!==i.item.kind?mi[o.item.kind]-mi[i.item.kind]:o.item.kind==="revision"&&i.item.kind==="revision"?i.item.nesting-o.item.nesting:0).map(o=>o.item)}function ep(e,t,n){let o=Ol(e,t,n).filter(i=>!(i.kind==="comment"&&i.resolved))[0];return o?o.kind==="comment"?fi(e,o):o:null}function tp(e,t){return fi(e,t)}function fi(e,t){let n=new Map,r=new Map;for(let a of e)a.kind==="comment"?n.set(a.id,a):a.kind==="revision"&&r.set(a.id,a);let o=new Set([t.id]),i=t;for(;i.parentId!==void 0;){let a=n.get(i.parentId);if(!a||o.has(a.id))break;o.add(a.id),i=a;}if(i.parentRevisionId!==void 0){let a=r.get(i.parentRevisionId);if(a)return a}return i}var Il={ins:"insert",del:"delete",moveFrom:"moveFrom",moveTo:"moveTo"};function up(e){let t=[],n=r=>{if(r.kind==="textValue"){t.push(r.value);return}for(let o of r.children)n(o);};for(let r of e.blocks)n(r);return t.join("")}function pp(e){if(e.initials&&e.initials.trim().length>0)return e.initials.trim();let t=e.author.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function Ht(e,t){for(let n of e.attributes)if(n.localName===t&&n.namespaceUri===chunk24APKZAN_cjs.ca)return n.value}function pt(e){if(e.kind==="textValue")return e.value;if(e.kind==="tab")return " ";if(e.kind==="hardBreak")return chunk24APKZAN_cjs.Hc(e);if(chunk24APKZAN_cjs.Pc(e))return "";let t="";for(let n of e.children)t+=pt(n);return t}function Vn(e){return `${e.id}\0${e.author}\0${e.date??""}`}var Rl={revisionInsert:"insert",revisionDelete:"delete",revisionMoveFrom:"moveFrom",revisionMoveTo:"moveTo"},yi={retainRevisionItems:true,revisionSites:chunk24APKZAN_cjs.Jg,locations:Hn,commentAnchors:chunk24APKZAN_cjs.uf,deepOrder:jn};function fp(e){return xi(e,yi)}function xi(e,t){let n=e.root.kind!=="paragraph";if(n&&t.retainRevisionItems){let o=gi.get(e.root);if(o&&o.name===e.name)return o.items}let r=bl(e,t);return n&&t.retainRevisionItems&&gi.set(e.root,{name:e.name,items:r}),r}var gi=chunk24APKZAN_cjs.sf(8);function bl(e,t){let n=t.revisionSites(e);if(n.length===0)return [];let r=t.locations(e),o=new Map;for(let a of n){let s=Ht(a.node,"id");if(s===void 0)continue;let l=Ht(a.node,"author")??"",d=Ht(a.node,"author")===void 0,c=Ht(a.node,"date"),u=c===void 0?{id:s,author:l}:{id:s,author:l,date:c},m=a.propertyChange?"format":a.paragraphMark?"paragraphMark":Rl[a.node.kind]??"structural",g=a.paragraphMark?Il[a.node.localName]:void 0,y=r.get(a.node.id),P=y?{partName:e.name,start:{paragraphId:y.paragraphId,offset:y.start},end:{paragraphId:y.paragraphId,offset:y.end}}:null,f=m==="structural"?`structural\0${Vn(u)}`:`${a.node.localName}\0${Vn(u)}`,x=o.get(f);if(x){x.siteNodeIds.push(a.node.id),P&&!x.ranges.some(p=>p.partName===P.partName&&p.start.paragraphId===P.start.paragraphId&&p.start.offset===P.start.offset&&p.end.paragraphId===P.end.paragraphId&&p.end.offset===P.end.offset)&&x.ranges.push(P),m!=="structural"&&x.revisionKind==="structural"&&(x.revisionKind=m),(m==="insert"&&x.revisionKind==="delete"||m==="delete"&&x.revisionKind==="insert"||x.revisionKind==="replace")&&(x.revisionKind="replace"),x.readOnly||=a.refused||d,a.nesting>x.nesting&&(x.nesting=a.nesting),m==="delete"||m==="moveFrom"?x.deletedText+=pt(a.node):m!=="format"&&m!=="paragraphMark"&&(x.text+=pt(a.node));continue}o.set(f,{address:u,revisionKind:m,...g?{markDirection:g}:{},author:l,...c===void 0?{}:{date:c},text:m==="format"||m==="paragraphMark"||m==="delete"||m==="moveFrom"?"":pt(a.node),deletedText:m==="delete"||m==="moveFrom"?pt(a.node):"",ranges:P?[P]:[],siteNodeIds:[a.node.id],nesting:a.nesting,readOnly:a.refused||d});}let i=[...o.values()].map(a=>ut({kind:"revision",id:`${a.revisionKind}-${e.name}\0${Vn(a.address)}`,address:a.address,addresses:[a.address],revisionKind:a.revisionKind,...a.markDirection?{markDirection:a.markDirection}:{},author:a.author,...a.date===void 0?{}:{date:a.date},text:a.revisionKind==="replace"?a.text:a.text||a.deletedText,replacedText:a.revisionKind==="replace"?a.deletedText:"",ranges:a.ranges,nesting:a.nesting,readOnly:a.readOnly,replyIds:[]},a.siteNodeIds));return vl(i,t.deepOrder(e))}function vl(e,t){let n=Nl(e,t),r=n.filter(l=>(l.revisionKind==="insert"||l.revisionKind==="delete")&&!l.readOnly&&l.ranges.length>0),o=new Set,i=new Map,a=new Map;for(let l of r){if(l.revisionKind!=="insert")continue;let d=l.ranges[0].start,c=`${d.paragraphId}\0${d.offset}`,u=a.get(c);u?u.push(l):a.set(c,[l]);}for(let l of r){if(l.revisionKind!=="delete"||o.has(l.id))continue;let d=l.ranges[l.ranges.length-1].end,c=a.get(`${d.paragraphId}\0${d.offset}`)??[],u=c.length>1?[...c].sort((m,g)=>(m.text.length>0?0:1)-(g.text.length>0?0:1)):c;for(let m of u){if(o.has(m.id)||m.author!==l.author)continue;o.add(l.id),o.add(m.id);let g=Ml(l.ranges[0],m.ranges[0],t)?l:m,y=Cl(l.date,m.date);i.set(l.id,ut({...g,id:`replace-${l.id}-${m.id}`,revisionKind:"replace",...y===void 0?{}:{date:y},addresses:El([...l.addresses,...m.addresses]),text:m.text,replacedText:l.text,ranges:[...l.ranges,...m.ranges],replacedRangeCount:l.ranges.length,readOnly:l.readOnly||m.readOnly},[...Ye(l),...Ye(m)]));break}}let s=[];for(let l of n){let d=i.get(l.id);if(d){s.push(d);continue}o.has(l.id)||s.push(l);}return s}function Nl(e,t){let n=e.filter(d=>(d.revisionKind==="insert"||d.revisionKind==="delete")&&!d.readOnly&&d.ranges.length>0);if(n.length<2)return e;let r=d=>`${d.paragraphId}\0${d.offset}`,o=new Map;for(let d of n){let c=`${d.revisionKind}\0${d.author}`,u=o.get(c);u?u.push(d):o.set(c,[d]);}let i=(d,c)=>{let u=d.ranges[0].start,m=c.ranges[0].start,g=(t.get(u.paragraphId)??0)-(t.get(m.paragraphId)??0);return g!==0?g:u.offset-m.offset};for(let d of o.values()){let c=true;for(let u=1;u<d.length&&c;u+=1)c=i(d[u-1],d[u])<=0;c||d.sort(i);}let a=new Set,s=new Map;for(let d of o.values()){let c=[],u="",m=()=>{if(c.length>1){s.set(c[0].id,Tl(c));for(let g=1;g<c.length;g+=1)a.add(c[g].id);}c=[];};for(let g of d){let y=r(g.ranges[0].start);c.length>0&&y!==u&&m();let P=c.length===0;c.push(g),(P||Sl(g))&&(u=r(g.ranges[g.ranges.length-1].end));}m();}if(s.size===0)return e;let l=[];for(let d of e)a.has(d.id)||l.push(s.get(d.id)??d);return l}function Sl(e){return e.ranges.some(t=>t.start.paragraphId!==t.end.paragraphId||t.start.offset!==t.end.offset)}function Tl(e){let t=e[0],n=[...t.addresses],r=[...t.ranges],o=[...Ye(t)],i=t.text,a=t.date;for(let s of e.slice(1)){for(let l of s.addresses)n.some(d=>ki(d,l))||n.push(l);for(let l of s.ranges)r.push(l);for(let l of Ye(s))o.push(l);i+=s.text,a=wl(a,s.date);}return ut({...t,id:e.map(s=>s.id).join("+"),addresses:n,ranges:r,text:i,...a===void 0?{}:{date:a}},o)}function wl(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?e:r>n?t:e}function El(e){let t=[];for(let n of e)t.some(r=>ki(r,n))||t.push(n);return t}function ki(e,t){return e.id===t.id&&e.author===t.author&&(e.date??"")===(t.date??"")}function Cl(e,t){if(t===void 0)return e;if(e===void 0)return t;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?t:n>r?e:t}function Ml(e,t,n){let r=n.get(e.start.paragraphId)??0,o=n.get(t.start.paragraphId)??0;return r!==o?r<o:e.start.offset<=t.start.offset}function Dl(e,t,n){let r=new Map(t.map(c=>[c.commentId,c])),o=new Map,i=new Map;for(let c of e)c.paraId&&o.set(c.paraId.toUpperCase(),c),i.set(c.id,c);let a=new Map,s=new Map;for(let c of e){let u=r.get(c.id);if(!u||u.orphaned||u.start.paragraphId===u.end.paragraphId&&u.start.offset===u.end.offset)continue;let m=`${u.start.paragraphId}:${u.start.offset}|${u.end.paragraphId}:${u.end.offset}`;a.has(m)?s.set(c.id,a.get(m)):a.set(m,c.id);}let l=new Map;for(let c of e){let u=c.paraId?n.get(c.paraId.toUpperCase()):void 0,m=u?.parentParaId?o.get(u.parentParaId):void 0,g=c.parentCommentId?i.get(c.parentCommentId):void 0,y=u===void 0?s.get(c.id):void 0,P=y?i.get(y):void 0,f=m??g??P;f&&f.id!==c.id&&l.set(c.id,f.id);}for(let c of [...l.keys()]){let u=new Set([c]),m=l.get(c);for(;m!==void 0;){if(u.has(m)){l.delete(c);break}u.add(m),m=l.get(m);}}let d=new Map;for(let[c,u]of l){let m=d.get(u);m?m.push(c):d.set(u,[c]);}return e.map(c=>{let u=r.get(c.id),m=c.paraId?n.get(c.paraId.toUpperCase()):void 0,g=l.get(c.id);return {kind:"comment",id:c.id,comment:c,range:u?{partName:u.partName,start:u.start,end:u.end}:null,resolved:m?.done??false,...g===void 0?{}:{parentId:g},replyIds:d.get(c.id)??[],orphaned:u===void 0||u.orphaned}})}function gp(e){return Al(e,yi)}function Al(e,t){let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let c of e.furnitureParts??[])r.has(c.name)||(r.add(c.name),n.push(c));let o=e.commentsPart?chunk24APKZAN_cjs.wf(e.commentsPart):[],i=e.commentsExtendedPart?chunk24APKZAN_cjs.xf(e.commentsExtendedPart):new Map,a=[],s=[],l=n.length===1?t.deepOrder(n[0]):new Map;for(let c of n){for(let g of xi(c,t))a.push(g);for(let g of t.commentAnchors(c))s.push(g);if(n.length===1)continue;let u=l,m=u.size;for(let[g,y]of t.deepOrder(c))u.has(g)||u.set(g,m+y);}return Ul([...a,...Dl(o,s,i)]).sort((c,u)=>Wn(c,l)-Wn(u,l))}function _l(e,t){if(e.kind!=="comment")return e;let n=e.replyIds??[],r=n.filter(i=>t.has(i)),o=e.parentId!==void 0&&!t.has(e.parentId);if(!o&&r.length===n.length)return e;if(o){let{parentId:i,parentRevisionId:a,...s}=e;return r.length===n.length?s:{...s,replyIds:r}}return {...e,replyIds:r}}function hi(e){return `${e.partName}\0${e.start.paragraphId}:${e.start.offset}|${e.end.paragraphId}:${e.end.offset}`}function Ul(e){let t=new Set;for(let l of e)l.kind==="comment"&&t.add(l.id);let n=e.map(l=>_l(l,t)),r=new Map;for(let l of n)if(l.kind==="revision")for(let d of l.ranges??[]){if(d.start.paragraphId===d.end.paragraphId&&d.start.offset===d.end.offset)continue;let c=hi(d),u=l.nesting??0,m=r.get(c);(m===void 0||u>m.nesting)&&r.set(c,{id:l.id,nesting:u});}let o=new Map;for(let l of n)l.kind==="comment"&&l.replyIds&&l.replyIds.length>0&&o.set(l.id,l.replyIds);let i=l=>{let d=[],c=new Set([l]),u=[...o.get(l)??[]];for(;u.length>0;){let m=u.shift();c.has(m)||(c.add(m),d.push(m),u.push(...o.get(m)??[]));}return d},a=new Map,s=new Map;for(let l of n){if(l.kind!=="comment"||l.parentId!==void 0||l.orphaned||!l.range)continue;let d=r.get(hi(l.range))?.id;if(d===void 0)continue;let c=[l.id,...i(l.id)];for(let m of c)s.set(m,d);let u=a.get(d);u?u.push(...c):a.set(d,c);}return n.map(l=>{if(l.kind==="revision"){let d=a.get(l.id)??[];return d.length===0&&(l.replyIds??[]).length===0?l:ut({...l,replyIds:d},Ye(l))}if(l.kind==="comment"){let d=s.get(l.id);if(d===void 0){if(l.parentRevisionId===void 0)return l;let{parentRevisionId:c,...u}=l;return u}return l.parentRevisionId===d?l:{...l,parentRevisionId:d}}return l})}var kp=256,Pp=2e3,Pi=/[\p{L}\p{N}_]/u;function Oi(e){let t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(let r=0;r<e.length;r+=1){let o=e[r],i=o.toLowerCase();n+=i.length===1?i:o;}return n}function Fl(e,t,n){let r=t>0?e[t-1]:void 0,o=n<e.length?e[n]:void 0;return !(r!==void 0&&Pi.test(r)||o!==void 0&&Pi.test(o))}function Ll(e){return typeof e=="string"&&e.length>0&&e.length<=256}function Op(e,t,n,r={}){let o={matches:[],truncated:false};if(!Ll(t)||e.length===0||n<=0)return o;let i=r.matchCase===true,a=r.wholeWord===true,s=i?t:Oi(t),l=i?e:Oi(e),d=Math.max(0,r.from??0),c=Math.min(e.length,r.to??e.length),u=[],m=l.indexOf(s,d);for(;m>=0;){let g=m+s.length;if(g>c)return {matches:u,truncated:false};if(!a||Fl(e,m,g)){if(u.length>=n)return {matches:u,truncated:true};u.push({start:m,length:s.length});}m=l.indexOf(s,g);}return {matches:u,truncated:false}}
|
|
2
|
+
exports.$=Su;exports.A=Cd;exports.Aa=pi;exports.B=_o;exports.Ba=fl;exports.C=os;exports.Ca=Wn;exports.D=Uo;exports.Da=Ol;exports.E=We;exports.Ea=ep;exports.F=Fs;exports.Fa=tp;exports.G=Na;exports.Ga=up;exports.H=wa;exports.Ha=pp;exports.I=Ea;exports.Ia=fp;exports.J=vn;exports.Ja=Dl;exports.K=Fm;exports.Ka=gp;exports.L=Sa;exports.La=Al;exports.M=Wa;exports.Ma=Ul;exports.N=Va;exports.Na=kp;exports.O=au;exports.Oa=Pp;exports.P=iu;exports.Pa=Oi;exports.Q=su;exports.Qa=Fl;exports.R=pu;exports.Ra=Ll;exports.S=fu;exports.Sa=Op;exports.T=gu;exports.U=Zs;exports.V=el;exports.W=Ga;exports.X=Ya;exports.Y=Ou;exports.Z=Iu;exports._=Ru;exports.a=md;exports.aa=Tu;exports.b=ud;exports.ba=Xe;exports.c=pd;exports.ca=_n;exports.d=fd;exports.da=Un;exports.e=gd;exports.ea=al;exports.f=hd;exports.fa=Ln;exports.g=Hi;exports.ga=Bu;exports.h=ji;exports.ha=$t;exports.i=yd;exports.ia=$n;exports.j=xd;exports.ja=Hu;exports.k=kd;exports.ka=il;exports.l=Be;exports.la=Qa;exports.m=Pd;exports.ma=ll;exports.n=Od;exports.na=Bn;exports.o=Id;exports.oa=dl;exports.p=ye;exports.pa=Fn;exports.q=Oo;exports.qa=ju;exports.r=Rd;exports.ra=Wu;exports.s=bd;exports.sa=Vu;exports.t=vd;exports.ta=Ku;exports.u=Nd;exports.ua=Hn;exports.v=Yi;exports.va=Yu;exports.w=Sd;exports.wa=pl;exports.x=Td;exports.xa=jn;exports.y=wd;exports.ya=Ye;exports.z=Ed;exports.za=Zu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,c,a}from'./chunk-QJYH6AYD.js';import {ba,V,U,H,I as I$1,K as K$1,J,la,ja,ra,qa,ta,Ra as Ra$1,Ia,P,Q,Ja,Ga}from'./chunk-KFELX7CN.js';import {Vf,Ca,Xe,be,ee,ce as ce$1,le as le$1,zc,xc,Pe,Zf,Tf,Xf,Id,Ta,Kd,Ra,Ke,Me,Le,O,Bd,Ad,hg,pe as pe$1,Xg,jg,jh,Lg,ca,Da,wf,xf,uf,qd,od,ig,wb,Qa,rd,pd,ph}from'./chunk-AREFLNUP.js';var Ft=Object.freeze(["default","first","even"]),ct=Object.freeze({kind:"body"});function B(n){switch(n.kind){case "body":return "body";case "note":return `note:${n.noteKind}:${String(n.noteId)}`;default:return `${n.kind}:${String(n.sectionIndex)}:${n.variant}`}}function un(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="body"?true:e.kind==="note"?(e.noteKind==="footnote"||e.noteKind==="endnote")&&Number.isInteger(e.noteId):e.kind!=="header"&&e.kind!=="footer"?false:Number.isInteger(e.sectionIndex)&&e.sectionIndex>=0&&Ft.includes(e.variant)}var Ar=["getDocument","getBody","getParagraphs","getSpanParagraphs","getText","getSpanText","getParagraphId","search","getFont","getParagraphFormat","getStyle","getSections","getPageSetup","getFurniture","getNotes","getNoteBody","getNoteText","getNoteKind","getLists","getListId","getListById","getListParagraphs","getParagraphList","getListLevel","getHyperlink","getBookmarks","getBookmarkName","getBookmarkRange","getComments","getCommentReplies","getCommentId","getCommentAuthor","getCommentDate","getCommentText","getCommentRange","getCommentResolved","getRevisions","getRevisionType","getRevisionAuthor","getRevisionDate","getRevisionRange","getContentControls","getContentControlById","getContentControlsByTag","getContentControlsByTitle","getContentControlTag","getContentControlTitle","getContentControlFileId","getContentControlSubtype","getContentControlLock","getContentControlIsBound","getContentControlPlaceholderShown","getContentControlTemporary","getContentControlText","getContentControlParagraphs","getContentControlRange"],po=["insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],mo=["deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],fo=new Set(mo);function ne(n){return fo.has(n.op)}var yo=new Set(po);function oe(n){return yo.has(n.op)}function go(){let n=globalThis.crypto,e=n?.getRandomValues;if(typeof e!="function")throw new Error("automation: no secure random source. globalThis.crypto.getRandomValues is required to scope document handles to one host.");let i=e.call(n,new Uint8Array(16)),a="";for(let s of i)a+=s.toString(16).padStart(2,"0");return a}function ho(n){return typeof n=="object"&&n!==null&&"kind"in n&&"ref"in n}function cn(){let n=new Map,e=new Map,i=new Map,a=new Map,s=go(),u=null,m=(p,y)=>{let v=(a.get(p)??0)+1;a.set(p,v);let k=`${p}:${s}:${String(v)}`;return n.set(k,y),Object.freeze({kind:p,ref:k})},g=(p,y,v)=>{let k=`${p}\0${y}`,S=i.get(k);if(S)return Object.freeze({kind:p,ref:S});let A=m(p,v);return i.set(k,A.ref),A};return {document(){return u??=m("document",{kind:"document"}),u},body(p){return g("body",B(p),{kind:"body",story:p})},paragraph(p,y){let v=e.get(p);if(v)return Object.freeze({kind:"paragraph",ref:v});let k=m("paragraph",{kind:"paragraph",paragraphId:p,story:y});return e.set(p,k.ref),k},section(p){return g("section",String(p),{kind:"section",index:p})},note(p,y){return g("note",`${p}:${String(y)}`,{kind:"note",noteKind:p,noteId:y})},comment(p,y){return g("comment",`${B(y)}\0${p}`,{kind:"comment",commentId:p,story:y})},revision(p,y){return g("revision",`${B(y)}\0${p}`,{kind:"revision",revisionId:p,story:y})},bookmark(p,y){return g("bookmark",`${B(y)}\0${p}`,{kind:"bookmark",name:p,story:y})},list(p,y){return g("list",`${B(y)}\0${p}`,{kind:"list",numId:p,story:y})},contentControl(p,y){return g("contentControl",`${B(y)}\0${p}`,{kind:"contentControl",nodeId:p,story:y})},retarget(p,y){let v=e.get(p);if(!v||p===y)return;let k=n.get(v);!k||k.kind!=="paragraph"||(e.delete(p),n.set(v,{kind:"paragraph",paragraphId:y,story:k.story}),e.has(y)||e.set(y,v));},resolve(p,y){if(!ho(p)||p.kind!==y||typeof p.ref!="string")return null;let v=n.get(p.ref);return !v||v.kind!==y?null:v}}}var ko=255,Ao=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function pn(n){let e=Bd(n);if(!e)return Ao;let i=new Map,a=new Map,s=null;for(let u of Ad(e).values())if(u.type==="paragraph"){if(i.set(u.styleId,u.name),u.name!==null){let m=u.name.trim().toLowerCase();a.has(m)||a.set(m,u.styleId);}u.isDefault&&s===null&&(s=u.styleId);}return Object.freeze({nameOf:u=>i.get(u)??null,idOf:u=>a.get(u.trim().toLowerCase())??null,defaultId:s,present:true})}function _t(n,e,i){let a=Ca(n,e);if(!a||a.kind!=="paragraph")return null;let s=vo(Me(Ke(a),"pStyle"));return s!==null?i.nameOf(s):i.defaultId===null?null:i.nameOf(i.defaultId)}function vo(n){if(!n)return null;for(let e of n.attributes)if(e.localName==="val")return e.value;return null}function Dt(n,e){if(typeof n!="string"||n.trim().length===0)return {ok:false,detail:"style: not a name"};if(n.length>ko)return {ok:false,detail:"style: name too long"};if(!O(n))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let i=e.idOf(n);return i===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:i}}var bo=31680,xo=1999,Io=Object.freeze({bold:null,italic:null,name:null,size:null,color:null});function Y(n,e){if(!n)return null;for(let i of n.attributes)if(i.localName===e)return i.value;return null}function re(n){if(!n)return null;let e=Y(n,"val");if(e===null)return true;let i=e.trim().toLowerCase();return !(i==="0"||i==="false"||i==="off"||i==="none")}function So(n){if(n===null)return null;let e=n.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function Ro(n){if(n===null)return null;let e=Number(n.trim());return !Number.isFinite(e)||e<=0?null:e/2}function yt(n){if(n===null)return null;let e=Number(n.trim());return Number.isFinite(e)?qd(od(e)):null}function Ct(n){if(n.length===0)return null;let e=n[0];if(e===null)return null;for(let i of n)if(i!==e)return null;return e}function fn(n,e,i=ba){let a=[];for(let s of e)for(let u of ta(n,s.paragraphId,s.start,s.end,i))a.push(Le(u));return a.length===0?Io:{bold:Ct(a.map(s=>re(Me(s,"b")))),italic:Ct(a.map(s=>re(Me(s,"i")))),name:Ct(a.map(s=>{let u=Me(s,"rFonts"),m=Y(u,"ascii");return m===null||m.length===0?null:m})),size:Ct(a.map(s=>Ro(Y(Me(s,"sz"),"val")))),color:Ct(a.map(s=>So(Y(Me(s,"color"),"val"))))}}var Co=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),Po=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function Oo(n){let e=Y(Me(n,"jc"),"val");return e===null?"Unknown":Co[e.trim().toLowerCase()]??"Unknown"}function yn(n,e,i){let a=Ca(n,e);if(!a||a.kind!=="paragraph")return null;let s=Ke(a),u=Me(s,"spacing"),m=Me(s,"ind");return {alignment:Oo(s),style:_t(n,e,i),firstLineIndent:wo(m),leftIndent:yt(Y(m,"left")??Y(m,"start")),rightIndent:yt(Y(m,"right")??Y(m,"end")),lineSpacing:yt(Y(u,"line")),spaceBefore:yt(Y(u,"before")),spaceAfter:yt(Y(u,"after")),widowControl:re(Me(s,"widowControl"))}}function wo(n){let e=yt(Y(n,"hanging"));if(e!==null&&e>0)return -e;let i=yt(Y(n,"firstLine"));return i!==null?i:e===null?null:-e}function Wt(n,e){if(typeof n!="number"||!Number.isFinite(n))return {ok:false,detail:`${e}: not a measurement`};let i=rd(pd(n));return Math.abs(i)>bo?{ok:false,detail:`${e}: out of range`}:{ok:true,value:i}}function gn(n){let e=[];if(n.bold!==void 0){if(typeof n.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};e.push({localName:"b",...n.bold?{}:{attributes:{val:"0"}}});}if(n.italic!==void 0){if(typeof n.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};e.push({localName:"i",...n.italic?{}:{attributes:{val:"0"}}});}if(n.name!==void 0){let i=n.name;if(typeof i!="string"||i.length===0||i.length>128)return {ok:false,detail:"name: not a font name"};if(!O(i))return {ok:false,detail:"name: not valid XML text"};e.push({localName:"rFonts",attributes:{ascii:i,hAnsi:i}});}if(n.size!==void 0){let i=n.size;if(typeof i!="number"||!Number.isFinite(i)||i<=0)return {ok:false,detail:"size: not a positive number of points"};let a=Math.round(i*2);if(a<1||a>xo)return {ok:false,detail:"size: out of range"};e.push({localName:"sz",attributes:{val:String(a)}}),e.push({localName:"szCs",attributes:{val:String(a)}});}if(n.color!==void 0){let i=n.color;if(typeof i!="string"||!/^#[0-9a-fA-F]{6}$/.test(i.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};e.push({localName:"color",attributes:{val:i.trim().slice(1).toUpperCase()}});}return e.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:e}}function hn(n,e,i,a){let s=Ca(n,e);if(!s||s.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let u=Ke(s),m=[];if(i.style!==void 0){let A=Dt(i.style,a);if(!A.ok)return {ok:false,detail:A.detail};m.push({localName:"pStyle",attributes:{val:A.styleId}});}if(i.alignment!==void 0){let A=Po[i.alignment];if(A===void 0)return {ok:false,detail:`alignment: ${String(i.alignment)}`};m.push({localName:"jc",attributes:{val:A}});}let g=Me(u,"ind"),p=mn(g),y=false;if(i.firstLineIndent!==void 0){let A=Wt(i.firstLineIndent,"firstLineIndent");if(!A.ok)return A;delete p.firstLine,delete p.hanging,A.value<0?p.hanging=String(-A.value):p.firstLine=String(A.value),y=true;}for(let[A,b,C]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let O=i[A];if(O===void 0)continue;let T=Wt(O,A);if(!T.ok)return T;delete p[C],p[b]=String(T.value),y=true;}y&&m.push({localName:"ind",attributes:p});let v=Me(u,"spacing"),k=mn(v),S=false;for(let[A,b]of [["spaceBefore","before"],["spaceAfter","after"]]){let C=i[A];if(C===void 0)continue;let O=Wt(C,A);if(!O.ok)return O;if(O.value<0)return {ok:false,detail:`${A}: out of range`};k[b]=String(O.value),S=true;}if(i.lineSpacing!==void 0){let A=Wt(i.lineSpacing,"lineSpacing");if(!A.ok)return A;if(A.value<=0)return {ok:false,detail:"lineSpacing: out of range"};k.line=String(A.value),k.lineRule??="auto",S=true;}if(S&&m.push({localName:"spacing",attributes:k}),i.widowControl!==void 0){if(typeof i.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};m.push({localName:"widowControl",...i.widowControl?{}:{attributes:{val:"0"}}});}return m.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:la(ja(n,e),m)}}function mn(n){let e=Object.create(null);if(!n)return e;for(let i of n.attributes)e[i.localName]=i.value;return e}function kn(){let n=false,e=false,i=false;return {conflict(a){let s=oe(a),u=ne(a),m=a.op==="deleteComment";return u&&n||e&&s?{message:"that command commits on its own and cannot share a batch",detail:a.op}:m&&n&&!i||i&&s&&!m?{message:"comment deletions may share a batch only with other comment deletions",detail:a.op}:null},note(a){oe(a)&&(n=true,ne(a)&&(e=true),a.op==="deleteComment"&&(i=true));},get hasCommands(){return n}}}var To=63360;function lt(n){return Math.round(qd(od(n))*100)/100}function No(n,e){if(typeof n!="number"||!Number.isFinite(n))return null;let i=rd(pd(n));return i>To||i<0||i===0&&!e?null:i}var Ho=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function An(n){if(typeof n!="object"||n===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=n,i={},a=0;for(let[u,m,g]of Ho){let p=e[u];if(p===void 0)continue;let y=No(p,g);if(y===null)return {ok:false,reason:`that is not a value for ${u}`,detail:String(p)};i[m]=y,a+=1;}let s=e.orientation;if(s!==void 0){if(s!=="portrait"&&s!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(s)};i.orientation=s,a+=1;}return a===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:i}}function jo(n){let e=Xg(n),i=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:lt(e.widthTwips),pageHeight:lt(e.heightTwips),orientation:i,topMargin:lt(e.topTwips),rightMargin:lt(e.rightTwips),bottomMargin:lt(e.bottomTwips),leftMargin:lt(e.leftTwips),headerDistance:lt(e.headerTwips),footerDistance:lt(e.footerTwips),gutter:lt(e.gutterTwips)})}function Mo(n,e){if(!e)return null;let i=null,a=(s,u,m)=>{if(i!==null||s.kind==="textValue"||m>64)return;let g=s.kind==="paragraph"?s.id:u;if(s.id===e.id){i=g;return}for(let p of s.children)a(p,g,m+1);};return a(n.root,null,0),i}function vn(n,e,i){let a=xc(e.root);return Object.freeze(a.map((s,u)=>{let m=i[u];return Object.freeze({index:u,markParagraphId:Mo(e,s),pageSetup:jo(s),titlePage:m?.titlePage??false,evenAndOddHeaders:m?.evenAndOddHeaders??false})}))}function bn(n,e,i){return e>=i?null:{text:n.text.slice(e-n.rawStart,i-n.rawStart),rawStart:e,rawEnd:i}}function Lo(n,e){let i=[],a=0;for(let s of n){for(;a<e.length&&e[a].end<=s.rawStart;)a+=1;let u=s.rawEnd-s.rawStart;if(s.text.length!==u){let p=e[a];(!p||p.start>=s.rawEnd)&&i.push(s);continue}let m=s.rawStart;for(;a<e.length;){let p=e[a];if(p.end<=m){a+=1;continue}if(p.start>=s.rawEnd)break;let y=bn(s,m,Math.min(p.start,s.rawEnd));if(y&&i.push(y),m=Math.max(m,p.end),p.end<=s.rawEnd&&(a+=1),m>=s.rawEnd)break}let g=bn(s,m,s.rawEnd);g&&i.push(g);}return i}function zt(n,e,i){if(i==="model")return b(e);let a$1=c(n,e,i);if(i==="allMarkup")return a(a$1);let s=Eo(n);if(s.length===0)return a(a$1);let u=Lo(a$1,s);return a(u)}function Eo(n){let e=Pe(n),i=[],a=(u,m)=>{if(!(m>64||u.kind==="textValue")){if(u.kind==="revisionInsert"||u.kind==="revisionMoveTo"){let g=e.spanOf(u);g&&g.end>g.start&&i.push({start:g.start,end:g.end});return}for(let g of u.children)a(g,m+1);}};a(n,0),i.sort((u,m)=>u.start-m.start||m.end-u.end);let s=[];for(let u of i){let m=s[s.length-1];m&&u.start<=m.end?m.end=Math.max(m.end,u.end):s.push({...u});}return s}var ie="\r",Bo=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),Fo=Object.freeze([]),_o=Object.freeze([]),xn=Object.freeze([]),Do=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>_o,furniture:()=>xn,noteIds:()=>({ok:true,ids:Sn}),styles:()=>Bo});function Wo(n){return n.kind==="textValue"?Fo:Object.freeze(n.children.filter(e=>e.kind!=="textValue").map(e=>{let i=[];jg([e],i,0);let a=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",s=e.kind==="paragraph"&&Me(Ke(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:a,paragraphIds:Object.freeze(i.map(u=>u.id)),removable:a!=="other"&&!s})}))}function ae(n,e,i,a,s){let u=ig(a),m=Object.freeze(u.map(A=>A.id)),g=new Map,p=new Map;u.forEach((A,b)=>{g.set(A.id,b),p.set(A.id,A);});let y=new Map,v=A=>{if(!g.has(A))return null;let b=y.get(A);if(b!==void 0)return b;let C=ph(e,A)??"";return y.set(A,C),C},k=new Map,S=(A,b="allMarkup")=>{let C=p.get(A);if(!C||C.kind!=="paragraph")return null;let O=`${A}:${b}`,T=k.get(O);if(T)return T;let L=zt(C,v(A)??"",b);return k.set(O,L),L};return {story:n,part:e,root:a,scope:i,paragraphIds:m,blocks:Wo(a),has:A=>g.has(A),indexOf:A=>g.get(A)??-1,paragraph(A){let b=p.get(A);return b?{nodeId:A,paraId:wb(b),text:S(A)?.text??""}:null},node:A=>p.get(A)??null,rawText:v,paragraphText:(A,b)=>S(A,b)?.text??null,projectedText:S,text:A=>m.map(b=>S(b,A)?.text??"").join(ie),styles:s}}function In(n){let e=n.parts.get(n.mainDocumentPart);if(!e)return Do;let i,a=()=>i??=pn(n),s,u=()=>s??=zc(n),m,g=new Map,p=new Map,y=b=>{let C=p.get(b);if(C)return C;let O=Xe(n,b);if(!O){let V={ok:true,ids:Sn};return p.set(b,V),V}let T=[],L=new Set,F=new Set,J=0,X=false;for(let V of O.root.children){if(be(V)!==b)continue;if(J+=1,V.kind!=="note"){X=true;continue}if(!ee(V))continue;let nt=ce$1(V);if(nt===null){X=true;continue}L.has(nt)?F.add(nt):(L.add(nt),T.push(nt));}let M=J>le$1?{ok:false,reason:"truncated"}:X?{ok:false,reason:"malformed"}:F.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...F])}:{ok:true,ids:Object.freeze(T)};return p.set(b,M),M},v=b=>{let C=u()[b.sectionIndex];return C?(b.kind==="header"?C.headers:C.footers).get(b.variant)??null:null},k=b=>{if(b.kind==="body"){let O=hg(e);return O?ae(b,e,{kind:"body"},O,a):null}if(b.kind==="note"){let O=y(b.noteKind);if(!O.ok||!O.ids.includes(b.noteId))return null;let T=Xe(n,b.noteKind);if(!T)return null;let L=pe$1(T.root,b.noteId);return !L||!ee(L)?null:ae(b,T,{kind:"notesPart",noteKind:b.noteKind},L,a)}let C=v(b);return C?ae(b,C.part,{kind:"headerFooter",rId:C.rId},C.part.root,a):null},S=b=>{let C=B(b);if(g.has(C))return g.get(C)??null;let O=k(b);return g.set(C,O),O};return {package:n,get body(){return S(ct)},story:S,storyOf:b=>{if(S(ct)?.has(b))return ct;for(let[O]of u().entries())for(let T of ["header","footer"])for(let L of Ft){let F={kind:T,sectionIndex:O,variant:L};if(S(F)?.has(b))return F}for(let O of ["footnote","endnote"]){let T=y(O);if(T.ok)for(let L of T.ids){let F={kind:"note",noteKind:O,noteId:L};if(S(F)?.has(b))return F}}return null},sections:()=>m??=vn(n,e,u()),furniture(b){let C=u()[b];if(!C)return xn;let O=[];for(let T of ["header","footer"]){let L=T==="header"?C.headers:C.footers;for(let F of Ft){let J=L.get(F);J&&O.push(Object.freeze({kind:T,variant:F,declared:!J.inherited}));}}return Object.freeze(O)},noteIds:y,styles:a}}var Sn=Object.freeze([]);function rt(n,e){return {ok:false,code:n,detail:e}}function at(n){return {ok:true,value:n}}function K(n,e,i,a){let s=i.resolve(n,e);if(!s||s.kind!=="body"&&s.kind!=="paragraph")return rt("invalid-handle",`not-a-${e}-handle`);let u=a.story(s.story);return u?at(u):rt("invalid-handle",`no-such-story:${B(s.story)}`)}function Z(n,e,i){let a=e.resolve(n,"paragraph");if(!a||a.kind!=="paragraph")return rt("invalid-handle","not-a-paragraph-handle");let s=i.story(a.story);if(!s)return rt("invalid-handle",`no-such-story:${B(a.story)}`);let u=s.indexOf(a.paragraphId);return u<0?rt("invalid-handle","paragraph-not-in-body"):at({story:a.story,paragraphId:a.paragraphId,index:u,offset:0})}function zo(n,e,i){let a=Z(n.paragraph,e,i);if(!a.ok)return a;let u=(i.story(a.value.story)?.rawText(a.value.paragraphId)??"").length,{offset:m}=n;return !Number.isInteger(m)||m<0||m>u?rt("invalid-offset",`offset ${String(m)} outside 0..${String(u)}`):at({...a.value,offset:m})}function At(n,e,i){if("paragraph"in n){if(!("at"in n))return zo(n,e,i);let g=Z(n.paragraph,e,i);if(!g.ok||n.at==="start")return g;let y=(i.story(g.value.story)?.rawText(g.value.paragraphId)??"").length;return at({...g.value,offset:y})}let a=K(n.body,"body",e,i);if(!a.ok)return a;let s=a.value.paragraphIds;if(s.length===0)return rt("invalid-offset","empty-story");if(n.at==="start")return at({story:a.value.story,paragraphId:s[0],index:0,offset:0});let u=s.length-1,m=s[u];return at({story:a.value.story,paragraphId:m,index:u,offset:(a.value.rawText(m)??"").length})}function Ko(n,e){return n.index<e.index||n.index===e.index&&n.offset<=e.offset}function Vo(n){let e=n.paragraphIds;if(e.length===0)return null;let i=e.length-1,a=e[i];return {start:{story:n.story,paragraphId:e[0],index:0,offset:0},end:{story:n.story,paragraphId:a,index:i,offset:(n.rawText(a)??"").length}}}function W(n,e,i){if("body"in n){let u=K(n.body,"body",e,i);return u.ok?at(Vo(u.value)):u}if("paragraph"in n){let u=Z(n.paragraph,e,i);if(!u.ok)return u;let g=(i.story(u.value.story)?.rawText(u.value.paragraphId)??"").length;return at({start:u.value,end:{...u.value,offset:g}})}let a=At(n.start,e,i);if(!a.ok)return a;let s=At(n.end,e,i);return s.ok?B(a.value.story)!==B(s.value.story)?rt("invalid-handle","span-crosses-stories"):Ko(a.value,s.value)?at({start:a.value,end:s.value}):rt("invalid-offset","span-start-after-end"):s}function q(n,e,i){if("body"in n)return K(n.body,"body",e,i);if("paragraph"in n)return K(n.paragraph,"paragraph",e,i);let a=n.start;return "paragraph"in a?K(a.paragraph,"paragraph",e,i):K(a.body,"body",e,i)}function Kt(n,e,i){if("paragraph"in n)return Z(n.paragraph,e,i);let a=K(n.body,"body",e,i);if(!a.ok)return a;let s=a.value.paragraphIds;if(s.length===0)return rt("invalid-offset","empty-story");let u=n.at==="first"?0:s.length-1;return at({story:a.value.story,paragraphId:s[u],index:u,offset:0})}function tt(n,e){return n?e.paragraphIds.slice(n.start.index,n.end.index+1):[]}function se(n,e){if(!n)return [];let i=tt(n,e),a=i.length-1;return i.map((s,u)=>{let m=(e.rawText(s)??"").length,g=u===0?n.start.offset:0,p=u===a?n.end.offset:m;return {paragraphId:s,start:g,end:p,whole:g===0&&p===m}})}function Rn(n,e,i,a="allMarkup"){if(!n)return "";let s=tt(n,e);return s.length===1?e.projectedText(n.start.paragraphId,a)?.sliceRaw(n.start.offset,n.end.offset)??"":s.map((u,m)=>{let g=e.projectedText(u,a);if(!g)return "";let p=(e.rawText(u)??"").length;return m===0?g.sliceRaw(n.start.offset,p):m===s.length-1?g.sliceRaw(0,n.end.offset):g.text}).join(i)}function de(n,e){return {start:{paragraph:e.paragraph(n.start.paragraphId,n.start.story),offset:n.start.offset},end:{paragraph:e.paragraph(n.end.paragraphId,n.end.story),offset:n.end.offset}}}var $o=256,Cn=1e4;function le(n,e){if(n.kind!=="textValue"){for(let i of n.attributes)if(i.namespaceUri===ca&&i.localName===e)return i.value}}function Uo(n){return n.startsWith("_")}function ue(n){let e=new Map,i=[],a=new Set;for(let s of n.paragraphIds){let u=n.node(s);if(u?.kind!=="paragraph")continue;let m=Pe(u),g=p=>{if(p.kind!=="textValue"){if(p.kind==="bookmarkStart"){if(i.length>=Cn||e.size>=Cn)return;let y=le(p,"id"),v=le(p,"name");if(y===void 0||v===void 0||v.length===0||v.length>$o||Uo(v)||a.has(v)||e.has(y))return;let k=m.spanOf(p)?.start??0;e.set(y,{name:v,start:{paragraphId:s,offset:k}});return}if(p.kind==="bookmarkEnd"){let y=le(p,"id");if(y===void 0)return;let v=e.get(y);if(!v)return;e.delete(y),a.add(v.name);let k=m.spanOf(p)?.start??0;i.push(Object.freeze({name:v.name,start:v.start,end:{paragraphId:s,offset:k}}));return}for(let y of p.children)g(y);}};for(let p of u.children)g(p);}return Object.freeze(i)}function ce(n,e){return ue(n).find(i=>i.name===e)??null}function Pn(n,e){let i=n.node(e);if(i?.kind!=="paragraph")return Object.freeze([]);let a=Pe(i),s=[],u=(m,g)=>{if(!(m.kind==="textValue"||g>32)){if(Qa(m)){let p=a.spanOf(m);p&&s.push(Object.freeze({id:m.id,paragraphId:e,start:p.start,end:p.end}));return}for(let p of m.children)u(p,g+1);}};for(let m of i.children)u(m,0);return Object.freeze(s)}function On(n,e,i){let a=Ta(i,s=>Kd(n,e,s));if(a.kind==="external")return a.href;if(a.kind==="internal"){let s=Ra(i);return s===void 0||s.length===0?null:`#${s}`}return null}var vt=8;function wn(n){if(!n||n.kind==="textValue")return null;for(let e of n.attributes)if(e.namespaceUri===ca&&e.localName==="val")return e.value;return null}function Tn(n){let e=Me(Ke(n),"numPr");if(!e)return null;let i=wn(Me(e,"numId"));if(i===null||!/^\d{1,10}$/.test(i)||i==="0")return null;let a=wn(Me(e,"ilvl")),s=a===null?0:Number(a);return !Number.isInteger(s)||s<0||s>vt?null:{numId:i,level:s}}function Vt(n){let e=new Map;for(let i of n.paragraphIds){let a=n.node(i);if(!a)continue;let s=Tn(a);if(!s)continue;let u=e.get(s.numId);u?u.push(i):e.set(s.numId,[i]);}return Object.freeze([...e].map(([i,a])=>Object.freeze({numId:i,paragraphIds:Object.freeze(a)})))}function Pt(n,e){let i=n.node(e);return i?Tn(i):null}function Nn(n,e,i,a,s){let u=Math.min(s?.limit??2e3,2e3),m=[],g=tt(e,n),p=g.length-1;for(let[y,v]of g.entries()){if(u<=0)break;let k=n.projectedText(v,s?.projection??"allMarkup");if(!k)continue;let S=k.findOccurrences(a,u,{matchCase:s?.matchCase===true,wholeWord:s?.matchWholeWord===true,...y===0&&e?{from:k.projectedOffset(e.start.offset)}:{},...y===p&&e?{to:k.projectedOffset(e.end.offset)}:{}});for(let A of S.matches){if(y===0&&e&&A.rawStart<e.start.offset||y===p&&e&&A.rawEnd>e.end.offset)continue;let b=i.paragraph(v,n.story);m.push({start:{paragraph:b,offset:A.rawStart},end:{paragraph:b,offset:A.rawEnd}}),u-=1;}}return {ok:true,spans:m}}var Xo={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Yo(n){return n.kind==="note"}function Go(n,e){return e.length===0?!Yo(n.story):e.every(i=>n.has(i.start.paragraphId))}function Jo(n){return Object.freeze(Ia(n.part).filter(e=>Go(n,e.ranges)))}function pe(n){let e=[];for(let i of Jo(n)){if(i.readOnly||i.revisionKind==="structural")continue;let a=Xo[i.revisionKind];a!==void 0&&e.push(Object.freeze({id:i.id,type:a,author:i.author,date:i.date??"",item:i}));}return Object.freeze(e)}function Qo(n,e){let i=n;for(let a=0;i!==void 0&&a<=64;a+=1){if(i.parentId===void 0)return i.range!==null;i=e.get(i.parentId);}return false}var Zo=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function Hn(n,e){let i=n.parts.get(P(n,e.part.name));if(!i)return Zo;let a=n.parts.get(Q(n,e.part.name)),s=wf(i),u=a?xf(a):new Map,m=uf(e.part).filter(k=>e.has(k.start.paragraphId)),g=Ja(s,m,u),p=new Map(g.map(k=>[k.id,k])),y=g.filter(k=>Qo(k,p)),v=new Map(y.map(k=>[k.id,k]));return Object.freeze({items:Object.freeze(y),roots:Object.freeze(y.filter(k=>k.parentId===void 0)),byId:k=>v.get(k)??null,textOf:k=>{let S=v.get(k);return S?Ga(S.comment):""}})}function jn(n,e,i){if("body"in n){let a=K(n.body,"body",e,i);return a.ok?{ok:true,reads:a.value}:{ok:false,code:a.code,message:"that handle does not name a body",detail:a.detail}}return e.resolve(n.document,"document")?i.body?{ok:true,reads:i.body}:{ok:false,code:"document-unavailable",message:"this host holds no document"}:{ok:false,code:"invalid-handle",message:"that handle does not name a document",detail:"document"}}function Mn(n,e){let i=n.op==="acceptAllRevisions",a=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [i?{op:"acceptAllRevisions",...a}:{op:"rejectAllRevisions",...a}]}var qo=/[\r\n\u2028\u2029]/u,En=Object.freeze({kind:"applied"});function bt(n,e,i){return {ok:false,error:Object.freeze(i===void 0?{code:n,message:e}:{code:n,message:e,detail:i})}}function me(n,e){return bt("unsupported-content",n==="author"?"a comment records who wrote it":n==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",n)}function fe(n){return H(n.author)?me("author",n.kind):I$1(n.text)?me("text",n.kind):typeof n.text=="string"&&qo.test(n.text)?bt("unsupported-content",n.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):K$1(n.date)?me("date",n.kind):null}function ye(n){if(n===void 0)return;let e=J(n);return e.ok?e.value:void 0}function Ln(n,e){let i=Ca(n.part,e);for(;i;){if(i.kind==="tableCell"||i.kind!=="textValue"&&i.namespaceUri===ca&&i.localName==="tc")return i.id;i=Da(n.part,i.id);}return null}function Bn(n,e,i,a){let s=fe({author:n.author,text:n.text,date:n.date,kind:"comment"});if(s)return s;let u=W(n.span,e,i);if(!u.ok)return bt(u.code,"that span is not a place",u.detail);if(u.value===null)return bt("invalid-handle","an empty story has no comment anchor");let m=q(n.span,e,i);if(!m.ok)return bt(m.code,"that span is not a place",m.detail);let g=u.value;if(Ln(m.value,g.start.paragraphId)!==Ln(m.value,g.end.paragraphId))return bt("unsupported-content","a comment range cannot cross a table-cell boundary");let p=a(m.value);if(p)return p;let y=ye(n.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:g.start.paragraphId,start:g.start.offset,end:g.end.offset,...g.end.paragraphId===g.start.paragraphId?{}:{endParagraphId:g.end.paragraphId}},text:n.text,author:n.author,...y===void 0?{}:{date:y}},story:m.value.story,answer:(k,S)=>S===void 0?En:{kind:"handle",handle:e.comment(S,m.value.story)}}}function Fn(n,e,i){let a=i(e);if(a)return a;let s=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:n.id,...n.parentId===void 0?{}:{parentCommentId:n.parentId},...s.kind==="note"?{noteId:s.noteId}:{}},story:s,answer:()=>En}}var tr=1e4;function _n(n,e){let i=[],a=e.kind==="contentControl"?Tf(e):e;if(!a)return i;for(let s of Xf(a))if(!(s.ancestors.length>0)){if(i.length>=tr)break;i.push(Vn(n,s.node));}return i}function Dn(n,e){for(let i of Xf(n.root))if(i.node.id===e)return Vn(n,i.node);return null}function Wn(n,e){for(let i of Xf(n.root))if(i.node.id===e)return i.node;return null}function zn(n,e){for(let i of n.paragraphIds){let a=n.node(i);if(!(!a||a.kind!=="paragraph")&&Xf(a).some(s=>s.node.id===e))return a}return null}function $t(n,e){let i=$n(e);if(i.length>0){let u=i[0],m=i[i.length-1],g=n.rawText(m);return g===null||!n.has(u)?null:{start:{paragraphId:u,offset:0},end:{paragraphId:m,offset:g.length}}}let a=zn(n,e.id);if(!a)return null;let s=Pe(a).spanOf(e);return s?{start:{paragraphId:a.id,offset:s.start},end:{paragraphId:a.id,offset:s.end}}:null}function er(n,e,i){let a=zn(n,e.id),s=Tf(e);if(!a||!s)return null;let u={...a,children:s.children},m=jh(u);return zt(u,m,i).text}function Kn(n,e,i="allMarkup"){if(i==="allMarkup")return Zf(e);let a=er(n,e,i);if(a!==null)return a;let s=$t(n,e);if(!s)return "";let u=n.indexOf(s.start.paragraphId),m=n.indexOf(s.end.paragraphId);if(u<0||m<u)return "";let g=[];for(let p=u;p<=m;p+=1){let y=n.paragraphIds[p],v=n.projectedText(y,i),k=n.rawText(y);if(!v||k===null)return "";g.push(v.sliceRaw(p===u?s.start.offset:0,p===m?s.end.offset:k.length));}return g.join("\r")}function Vn(n,e){return {nodeId:e.id,properties:Vf(e),lock:Lg(n.part,e.id),paragraphIds:$n(e)}}function $n(n){let e=Tf(n);if(!e)return [];let i=[];return jg(e.children,i,0),i.map(a=>a.id)}var nr=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),or=4096,Un=64;function Xn(n){if(n===void 0)return {ok:true,value:null};if(typeof n!="object"||n===null)return {ok:false,field:"payload"};let e=n;for(let i of ["namespaceUri","rootLocalName","nodeId"]){let a=e[i];if(typeof a!="string"||a.length===0||a.length>or)return {ok:false,field:i}}return typeof e.label!="string"||e.label.length>V?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>U?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function Yn(n){let e=n.at!==void 0,i=n.span!==void 0;return e===i?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof n.tag!="string"||n.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:n.tag.length>Un?{message:`w:tag caps at ${String(Un)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof n.text!="string"||n.text.length===0?{message:"a custom node shows some text",detail:"text"}:n.lock!==void 0&&!nr.has(n.lock)?{message:"that is not a lock",detail:String(n.lock)}:null}function Gn(n,e,i,a){return {paragraphId:e.paragraphId,offset:e.offset,...i.offset>e.offset?{replaceUntil:i.offset}:{},tag:n.tag,text:n.text,...n.title===void 0?{}:{alias:n.title},...n.lock===void 0||n.lock==="unlocked"?{}:{lock:n.lock},...a===null?{}:{payload:a}}}function Jn(n,e,i){if(n.span){let s=W(n.span,e,i);return s.ok?s.value?s.value.start.paragraphId!==s.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:s.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:s.code,message:"that span is not a place",detail:s.detail}}let a=At(n.at,e,i);return a.ok?{range:{start:a.value,end:a.value}}:{code:a.code,message:"that is not a place",detail:a.detail}}var Ot=/[\r\n\v\f\u2028\u2029]/,rr=16,ar=64,Qn=/\s/;function ir(n,e,i){return Object.freeze(i===void 0?{code:n,message:e}:{code:n,message:e,detail:i})}function l(n,e,i){return {ok:false,error:ir(n,e,i)}}var E=Object.freeze({kind:"applied"});function I(n){return {ok:true,kind:"query",value:n}}function Zn(n){let e=n.kind==="contentControl"?Tf(n):n;return e?Xf(e).map(i=>i.node):[]}var sr=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),dr=new Set(["whole","content","start","end","before","after"]),lr=new Set(["richText","plainText","dropDownList","comboBox","date"]),ur=4096;function cr(n){let e=(s,u)=>({ok:false,code:"unsupported-content",message:s,detail:u});if(typeof n!="object"||n===null||!("kind"in n))return e("a control value states its kind","value");let i=n,a=i.kind;if(a==="text"||a==="listItem"){let s=a==="text"?i.text:i.value;return typeof s!="string"?e("that value is not a string",String(a)):s.length>ur?e("that value is too long",String(s.length)):{ok:true,value:a==="text"?{kind:"text",text:s}:{kind:"listItem",value:s}}}if(a==="checkbox"){let s=i.checked;return typeof s!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:s}}}if(a==="date"){let s=i.iso;return typeof s!="string"?e("a date is an ISO-8601 string","iso"):s.length>64?e("that is not a date",String(s.length)):{ok:true,value:{kind:"date",iso:s}}}return e("that is not a value any control accepts",String(a))}function pr(n,e){let i=[],a=0;for(;a<n.length;){let s=null;for(let u of e){let m=n.indexOf(u,a);m<0||(!s||m<s.start||m===s.start&&u.length>s.length)&&(s={start:m,length:u.length});}if(!s)break;i.push(s),a=s.start+s.length;}return i}function mr(n,e,i){let a=e[i]?.markParagraphId??null;if(a!==null)return a;let s=n.paragraphIds,u=s[s.length-1];return u===void 0||new Set(e.map(g=>g.markParagraphId).filter(g=>g!==null)).has(u)?null:u}function fr(n,e){for(let i of [n.start,n.end]){let a=e.rawText(i.paragraphId);if(a===null||i.offset>a.length)return false}return true}function yr(n,e,i){let a=e,s=i;for(;a<s&&Qn.test(n[a]);)a+=1;for(;s>a&&Qn.test(n[s-1]);)s-=1;return [a,s]}function qn(n){let{handles:e,capabilities:i}=n,a=n.reads,s=new Map,u=o=>{let t=B(o.story),r=s.get(t);if(r)return r;let d=new Map,c=o.paragraphIds.map(h=>{let x={id:h};return d.set(h,x),x}),f={reads:o,order:c,slotById:d,created:[],restructured:new Set,touched:new Set,formatted:new Set,selected:new Set,retargets:[]};return s.set(t,f),f},m=[],g=kn(),p=null,y=o=>p===null?(p=o,null):p===o?null:l("conflicting-operations","one batch writes into one story",`${B(p.reads.story)} then ${B(o.reads.story)}`),v=o=>y(u(o)),k=o=>{let t=a.package;return t===null?null:Hn(t,o)},S=o=>{let t=e.resolve(o,"comment");if(!t||t.kind!=="comment")return {ok:false,planned:l("invalid-handle","that handle does not name a comment","comment")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let c=k(r)?.byId(t.commentId)??null;return c?{ok:true,reads:r,item:c}:{ok:false,planned:l("invalid-handle","this document no longer holds that comment",t.commentId)}},A=o=>{let t=e.resolve(o,"revision");if(!t||t.kind!=="revision")return {ok:false,planned:l("invalid-handle","that handle does not name a tracked change","revision")};let r=a.story(t.story);if(!r)return {ok:false,planned:l("invalid-handle","that story is not in this document")};let d=pe(r).find(c=>c.id===t.revisionId)??null;return d?{ok:true,reads:r,item:d}:{ok:false,planned:l("invalid-handle","this document no longer holds that tracked change",t.revisionId)}},b=(o,t)=>{let r=o.rawText(t.start.paragraphId),d=o.rawText(t.end.paragraphId);if(r===null||d===null)return null;let c={story:o.story,paragraphId:t.start.paragraphId,index:o.indexOf(t.start.paragraphId),offset:Math.min(t.start.offset,r.length)},f={story:o.story,paragraphId:t.end.paragraphId,index:o.indexOf(t.end.paragraphId),offset:Math.min(t.end.offset,d.length)};return X({start:c,end:f})},C=(o,t)=>o.order.indexOf(t),O$1=(o,t)=>o.selected.has(t)?l("conflicting-operations","this batch selects a paragraph it also edits",t):null,T=(o,t)=>{let r=O$1(o,t);return r||(o.restructured.has(t)||o.touched.has(t)?l("conflicting-operations","another operation in this batch already changes that paragraph",t):(o.restructured.add(t),o.touched.add(t),null))},L=(o,t)=>{let r=O$1(o,t);return r||(o.restructured.has(t)?l("conflicting-operations","another operation in this batch restructures that paragraph",t):(o.touched.add(t),null))},F=(o,t,r)=>{let d=`${r}:${t}`;if(o.formatted.has(d))return l("conflicting-operations","another operation in this batch already writes that formatting",t);let c=L(o,t);return c||(o.formatted.add(d),null)},J=(o,t)=>{let r={id:null};return o.order.splice(t,0,r),o.created.push(r),r},X=o=>de(o,e),M=o=>o===null?null:a.story(o.start.story),V=o=>o===void 0||o==="allMarkup"||o==="original"||o==="model",nt=(o,t,r,d)=>{if(!V(d?.projection))return l("unsupported-content","unknown text projection","projection");if(d?.matchWildcards===true)return l("unsupported-capability","wildcard search is not implemented","matchWildcards");if(d?.ignorePunct===true)return l("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(d?.ignoreSpace===true)return l("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!Ra$1(r))return l("unsupported-content","that is not a query this host will scan for","text");let c=d?.limit;if(c!==void 0&&(!Number.isInteger(c)||c<0))return l("invalid-offset","limit must be a non-negative integer",String(c));let f=Nn(o,t,e,r,d);return I({kind:"spans",spans:f.spans})},xt=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","insertText needs text","text");if(Ot.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=y(o);if(d)return d;let c=L(o,t.paragraphId);if(c)return c;let f=r.length===0?[]:[{op:"insertText",paragraphId:t.paragraphId,offset:t.offset,text:r}],h=()=>({kind:"span",span:X({start:t,end:{...t,offset:t.offset+r.length}})});return {ok:true,kind:"command",ops:f,story:o.reads.story,answer:h}},wt=(o,t,r)=>{let d=o.reads;if(typeof r!="string")return l("unsupported-content","replaceSpan needs text","text");if(Ot.test(r))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let c=tt(t,d),f=t.start.paragraphId,h=[],x=y(o);if(x)return x;if(c.length===1){let j=L(o,f);if(j)return j;t.end.offset>t.start.offset&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:t.end.offset});}else {for(let w of c){let P=T(o,w);if(P)return P}let j=t.end.paragraphId,D=(d.rawText(f)??"").length;t.start.offset<D&&h.push({op:"deleteText",paragraphId:f,start:t.start.offset,end:D}),t.end.offset>0&&h.push({op:"deleteText",paragraphId:j,start:0,end:t.end.offset});for(let w of c.slice(1,-1))h.push({op:"deleteBlock",blockId:w});h.push({op:"joinParagraphs",firstId:f,secondId:j});for(let w of c.slice(1)){let P=o.slotById.get(w);P&&o.order.splice(C(o,P),1);}}r.length>0&&h.push({op:"insertText",paragraphId:f,offset:t.start.offset,text:r});let R={...t.start,paragraphId:f},H=()=>({kind:"span",span:X({start:R,end:{...R,offset:R.offset+r.length}})});return {ok:true,kind:"command",ops:h,story:o.reads.story,answer:H}},ge=(o,t)=>{let r=o.reads;if(typeof t!="string")return l("unsupported-content","replaceSpan needs text","text");if(Ot.test(t))return l("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let d=r.blocks,c=d.filter(P=>P.removable),f=d.filter(P=>!P.removable).flatMap(P=>P.paragraphIds),h=f.length===0?c.find(P=>P.kind==="paragraph"):void 0;if(!h&&f.length===0)return l("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let x=y(o);if(x)return x;for(let P of r.paragraphIds){let Q=T(o,P);if(Q)return Q}let R=[],H=(h?[h.id]:[...f]).sort((P,Q)=>r.indexOf(P)-r.indexOf(Q)),j=H[0];for(let P of H){let Q=(r.rawText(P)??"").length;Q>0&&R.push({op:"deleteText",paragraphId:P,start:0,end:Q});}for(let P of c)P.id!==h?.id&&R.push({op:"deleteBlock",blockId:P.id});t.length>0&&R.push({op:"insertText",paragraphId:j,offset:0,text:t});for(let P of c)if(P.id!==h?.id)for(let Q of P.paragraphIds){let Tt=o.slotById.get(Q);Tt&&o.order.splice(C(o,Tt),1);}let D={story:r.story,paragraphId:j,index:r.indexOf(j),offset:0},w=()=>({kind:"span",span:X({start:D,end:{...D,offset:t.length}})});return {ok:true,kind:"command",ops:R,story:r.story,answer:w}},N=(o,t)=>{if(!Array.isArray(t)||t.length<1||t.length>1e4||t.some(d=>typeof d!="string"||Ot.test(d)||!O(d)))return l("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let r=y(o);if(r)return r;for(let d of o.reads.paragraphIds){let c=T(o,d);if(c)return c}o.order.splice(0,o.order.length);for(let d=0;d<t.length;d+=1)J(o,d);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:o.reads.root.id,paragraphs:t}],story:o.reads.story,answer:()=>E}},z=(o,t,r,d)=>{let c=o.reads;if(typeof d!="string")return l("unsupported-content","insertParagraph needs text","text");if(Ot.test(d))return l("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let f=y(o);if(f)return f;let h=T(o,t.paragraphId);if(h)return h;let x=o.slotById.get(t.paragraphId);if(!x)return l("invalid-handle","that paragraph is not in the body");let R=(c.rawText(t.paragraphId)??"").length,H=[];r==="after"?(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:R,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:R})):(d.length>0&&H.push({op:"insertText",paragraphId:t.paragraphId,offset:0,text:d}),H.push({op:"splitParagraph",paragraphId:t.paragraphId,offset:d.length}));let j=J(o,C(o,x)+1);r==="before"&&o.retargets.push({from:t.paragraphId,slot:j});let D=()=>{let w=r==="after"?j.id:t.paragraphId;return w===null?E:{kind:"handle",handle:e.paragraph(w,c.story)}};return {ok:true,kind:"command",ops:H,story:c.story,answer:D}},it=(o,t,r,d,c)=>{let f=o.reads;if(!Array.isArray(r)||r.length===0)return l("unsupported-content","split needs at least one delimiter","delimiters");if(r.length>rr)return l("unsupported-content","too many delimiters",String(r.length));for(let $ of r){if(typeof $!="string"||$.length===0)return l("unsupported-content","a delimiter must be a non-empty string","delimiters");if($.length>ar)return l("unsupported-content","that delimiter is too long","delimiters")}let h=y(o);if(h)return h;let x=T(o,t.paragraphId);if(x)return x;let R=o.slotById.get(t.paragraphId);if(!R)return l("invalid-handle","that paragraph is not in the body");let H=f.rawText(t.paragraphId)??"",j=pr(H,r),D=[],w=[],P=[];if(j.length===0)P.push(H);else if(d){for(let U of [...j].reverse())D.push({op:"deleteText",paragraphId:t.paragraphId,start:U.start,end:U.start+U.length});let $=0,ut=0;for(let U of j){let Yt=U.start-$;w.push(Yt),P.push(H.slice(ut,U.start)),ut=U.start+U.length,$+=U.length;}P.push(H.slice(ut));}else {let $=0;for(let ut of j){let U=ut.start+ut.length;w.push(U),P.push(H.slice($,U)),$=U;}P.push(H.slice($));}w.length>0&&D.push({op:"splitParagraphMany",paragraphId:t.paragraphId,offsets:w});let Q=[R];for(let $=0;$<w.length;$+=1)Q.push(J(o,C(o,R)+1+$));let Tt=$=>{let ut=$.story(f.story),U=[];return Q.forEach((Yt,lo)=>{let Gt=Yt.id;if(Gt===null)return;let Jt=ut?.rawText(Gt)??P[lo]??"",[uo,co]=c?yr(Jt,0,Jt.length):[0,Jt.length],ve=e.paragraph(Gt,f.story);U.push({start:{paragraph:ve,offset:uo},end:{paragraph:ve,offset:co}});}),{kind:"spans",spans:U}};return {ok:true,kind:"command",ops:D,story:f.story,answer:Tt}},It=(o,t)=>{let r=y(o);if(r)return r;let d=T(o,t.paragraphId);if(d)return d;let c=o.slotById.get(t.paragraphId);return c&&o.order.splice(C(o,c),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:t.paragraphId}],story:o.reads.story,answer:()=>E}},pt=(o,t,r)=>{let d=o.reads,c=d.part,f=y(o);if(f)return f;let h=gn(r??{});if(!h.ok)return l("unsupported-content","that is not formatting this host writes",h.detail);let x=[];for(let R of se(t,d)){if(R.end<=R.start&&!R.whole)continue;let H=F(o,R.paragraphId,"runs");if(H)return H;for(let j of ra(c,R.paragraphId,R.start,R.end,h.value,n.displayMode))x.push({op:"setRunProperties",paragraphId:R.paragraphId,start:j.start,end:j.end,properties:j.properties,...j.targetRunIds?{targetRunIds:j.targetRunIds}:{}});R.whole&&x.push({op:"setParagraphMarkProperties",paragraphId:R.paragraphId,properties:qa(c,R.paragraphId,h.value)});}return x.length===0?l("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:x,story:d.story,answer:()=>E}},to=(o,t,r)=>{let d=o.reads,c=d.part,f=y(o);if(f)return f;let h=Dt(r,d.styles());if(!h.ok)return l("unsupported-content","that is not a style this document has",h.detail);let x={localName:"pStyle",attributes:{val:h.styleId}},R=[];for(let H of tt(t,d)){let j=F(o,H,"paragraph");if(j)return j;R.push({op:"setParagraphProperties",paragraphId:H,properties:la(ja(c,H),x)});}return R.length===0?l("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:R,story:d.story,answer:()=>E}},eo=(o,t,r)=>{let d=o.reads,c=d.part,f=y(o);if(f)return f;let h=hn(c,t.paragraphId,r??{},d.styles());if(!h.ok)return l("unsupported-content","that is not paragraph formatting this host writes",h.detail);let x=F(o,t.paragraphId,"paragraph");return x||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:t.paragraphId,properties:h.value}],story:d.story,answer:()=>E}},no=(o,t)=>{let r=a.body;if(!r)return l("document-unavailable","this host holds no document right now");let d=a.sections();if(!d[o])return l("invalid-handle","that section is not in this document");let f=An(t);if(!f.ok)return l("unsupported-content",f.reason,f.detail);let h=mr(r,d,o);if(h===null)return l("unsupported-content","that section holds no paragraph to address it by","no-anchor");let x=u(r),R=y(x);return R||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...f.value,anchorParagraphId:h}],story:ct,answer:()=>E}},oo=(o,t)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:o,noteId:t}],story:ct,lifecycle:true,answer:()=>E}),Ut=o=>{let t=e.resolve(o,"list");if(!t||t.kind!=="list")return l("invalid-handle","that handle does not name a list","list");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Vt(r).find(c=>c.numId===t.numId);return d?{ok:true,plan:u(r),list:d}:l("invalid-handle","this story numbers nothing with that list",t.numId)},Xt=o=>{if(typeof o!="object"||o===null)return l("invalid-handle","that is not a scope a control lives in","scope");let t=o;if("body"in o){let r=K(t.body,"body",e,a);return r.ok?{reads:r.value,node:r.value.root}:l(r.code,"that handle does not name a body",r.detail)}if("contentControl"in o){let r=ot(t.contentControl);return "control"in r?{reads:r.reads,node:r.node}:r}return l("invalid-handle","that is not a scope a control lives in","scope")},ot=o=>{let t=e.resolve(o,"contentControl");if(!t||t.kind!=="contentControl")return l("invalid-handle","that handle does not name a content control","contentControl");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Dn(r,t.nodeId),c=Wn(r,t.nodeId);return !d||!c?l("invalid-handle","this document no longer holds that content control"):{reads:r,control:d,node:c}},ro=(o,t,r)=>{if(!Number.isInteger(r)||r<0||r>vt)return l("invalid-offset",`a list level is 0 to ${String(vt)}`,String(r));if(!Pt(o.reads,t))return l("unsupported-content","that paragraph is not in a list",t);let d=y(o);if(d)return d;let c=F(o,t,"paragraph");return c||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:t,level:r}],story:o.reads.story,answer:()=>E}},ao=(o,t,r,d)=>{if(r!=="start"&&r!=="end")return l("unknown-operation","a list takes an item at its start or its end",String(r));let c=o.reads,f=r==="start"?t.paragraphIds[0]:t.paragraphIds[t.paragraphIds.length-1];if(f===void 0)return l("invalid-handle","that list holds no paragraph");let h={story:c.story,paragraphId:f,index:c.indexOf(f)};return z(o,h,r==="start"?"before":"after",d)},he=(o,t)=>{if(t.start.paragraphId!==t.end.paragraphId)return null;for(let r of Pn(o,t.start.paragraphId))if(r.start<=t.start.offset&&r.end>=t.end.offset)return r;return null},io=(o,t,r)=>{if(typeof r!="string")return l("unsupported-content","a hyperlink target is a string","target");let d=o.reads,c=he(d,t),f=t.start.paragraphId===t.end.paragraphId&&t.start.offset===t.end.offset;if(r.length===0){if(!c)return l("unsupported-content","that text is not a link","no-link");let w=y(o);if(w)return w;let P=L(o,c.paragraphId);return P||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:c.id}],story:d.story,answer:()=>E}}let h={},x=null;if(r.startsWith("#")){let w=r.slice(1);if(w.length===0||!ce(d,w))return l("unsupported-content","this document declares no such bookmark",r);h={anchor:w};}else {if(Id(r)===null)return l("unsupported-content","this engine will not author that target","target");x=r;}let R=y(o);if(R)return R;let H=w=>x===null?{ok:true,kind:"command",ops:[w(h)],story:d.story,answer:()=>E}:{ok:true,kind:"command",ops:[],relate:{url:x,ops:P=>[w({relationshipId:P})]},story:d.story,answer:()=>E};if(c){let w=L(o,c.paragraphId);return w||H(P=>({op:"setHyperlinkTarget",linkId:c.id,...P}))}if(f)return l("unsupported-content","a link with no text has nothing to click","collapsed");if(t.start.paragraphId!==t.end.paragraphId)return l("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let j=L(o,t.start.paragraphId);if(j)return j;let D=d.styles().idOf("hyperlink");return H(w=>({op:"insertHyperlink",paragraphId:t.start.paragraphId,start:t.start.offset,end:t.end.offset,...w,...D===null?{}:{styleId:D}}))},ke=(o,t,r)=>{let d=o.reads;if(!i.selection||!n.select)return l("unsupported-capability","this host has no reader to move","selection");if(r!=="select"&&r!=="start"&&r!=="end")return l("unknown-operation","that is not a selection mode",String(r));let c=tt(t,d);for(let f of c)if(o.touched.has(f))return l("conflicting-operations","this batch edits a paragraph the selection covers",f);for(let f of c)o.selected.add(f);return m.push({range:t,mode:r}),{ok:true,kind:"command",ops:[],story:d.story,answer:()=>E}},Ae=o=>{let t=e.resolve(o,"bookmark");if(!t||t.kind!=="bookmark")return l("invalid-handle","that handle does not name a bookmark","bookmark");let r=a.story(t.story);if(!r)return l("invalid-handle","that story is not in this document");let d=ce(r,t.name);if(!d)return l("invalid-handle","this document no longer declares that bookmark",t.name);let c=f=>({story:r.story,paragraphId:f.paragraphId,index:r.indexOf(f.paragraphId),offset:f.offset});return {reads:r,range:{start:c(d.start),end:c(d.end)}}},so=o=>{switch(o.op){case "getDocument":return I({kind:"handle",handle:e.document()});case "getBody":return e.resolve(o.document,"document")?a.body?I({kind:"handle",handle:e.body(ct)}):l("document-unavailable","this host holds no document right now"):l("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:t.value.paragraphIds.map(r=>e.paragraph(r,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getSpanParagraphs":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"handles",handles:tt(t.value,r.value).map(d=>e.paragraph(d,r.value.story))}):l(r.code,"that span is not a place",r.detail)}case "getText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");if(e.resolve(o.target,"body")){let c=K(o.target,"body",e,a);return c.ok?I({kind:"text",text:c.value.text(o.projection??"allMarkup")}):l(c.code,"that handle does not name a body",c.detail)}let r=Z(o.target,e,a);if(!r.ok)return l(r.code,"that handle does not name a body or a paragraph",r.detail);let d=a.story(r.value.story);return I({kind:"text",text:d?.paragraphText(r.value.paragraphId,o.projection??"allMarkup")??""})}case "getSpanText":{if(!V(o.projection))return l("unsupported-content","unknown text projection","projection");let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);return r.ok?I({kind:"text",text:Rn(t.value,r.value,ie,o.projection??"allMarkup")}):l(r.code,"that span is not a place",r.detail)}case "getParagraphId":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let d=a.story(t.value.story)?.paragraph(t.value.paragraphId);return I({kind:"text",text:d?.paraId??""})}case "search":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that is not a scope to search",t.detail);let r=q(o.scope,e,a);return r.ok?nt(r.value,t.value,o.text,o.options):l(r.code,"that is not a scope to search",r.detail)}case "insertText":{let t=At(o.at,e,a);if(!t.ok)return l(t.code,"that is not a place to insert at",t.detail);let r=a.story(t.value.story);return r?xt(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in o.span){let d=K(o.span.body,"body",e,a);return d.ok?ge(u(d.value),o.text):l(d.code,"that handle does not name a body",d.detail)}let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to write into","empty-story");let r=M(t.value);return r?wt(u(r),t.value,o.text):l("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let t=K(o.body,"body",e,a);return t.ok?N(u(t.value),o.paragraphs):l(t.code,"that handle does not name a body",t.detail)}case "insertParagraph":{let t=Kt(o.anchor,e,a);if(!t.ok)return l(t.code,"that is not a paragraph to insert beside",t.detail);if(o.where!=="before"&&o.where!=="after")return l("unknown-operation","that is not a place to insert",String(o.where));let r=a.story(t.value.story);return r?z(u(r),t.value,o.where,o.text):l("invalid-handle","that story is not in this document")}case "splitParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?it(u(r),t.value,o.delimiters,o.trimDelimiters===true,o.trimSpacing===true):l("invalid-handle","that story is not in this document")}case "getFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=se(t.value,r.value);return I({kind:"font",font:fn(r.value.part,d,n.displayMode)})}case "setFont":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to format","empty-story");let r=M(t.value);return r?pt(u(r),t.value,o.font):l("invalid-handle","that story is not in this document")}case "getStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value.part,c=r.value.styles(),f=tt(t.value,r.value).map(x=>_t(d,x,c)),h=f.length>0&&f.every(x=>x!==null&&x===f[0])?f[0]:null;return I({kind:"style",name:h})}case "setStyle":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to style","empty-story");let r=M(t.value);return r?to(u(r),t.value,o.name):l("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let t=Kt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("document-unavailable","this host holds no document right now");let d=yn(r.part,t.value.paragraphId,r.styles());return d?I({kind:"paragraphFormat",format:d}):l("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let t=Kt(o.paragraph,e,a);if(!t.ok)return l(t.code,"that is not a paragraph",t.detail);let r=a.story(t.value.story);return r?eo(u(r),t.value,o.format):l("invalid-handle","that story is not in this document")}case "deleteParagraph":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?It(u(r),t.value):l("invalid-handle","that story is not in this document")}case "getSections":return e.resolve(o.document,"document")?I({kind:"handles",handles:a.sections().map(t=>e.section(t.index))}):l("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");let r=a.sections()[t.index];return r?I({kind:"pageSetup",setup:r.pageSetup}):l("invalid-handle","that section is not in this document")}case "setPageSetup":{let t=e.resolve(o.section,"section");return !t||t.kind!=="section"?l("invalid-handle","that handle does not name a section","section"):no(t.index,o.setup)}case "getFurniture":{let t=e.resolve(o.section,"section");if(!t||t.kind!=="section")return l("invalid-handle","that handle does not name a section","section");if(o.kind!=="header"&&o.kind!=="footer")return l("unknown-operation","that is not furniture",String(o.kind));let r={kind:o.kind,sectionIndex:t.index,variant:o.variant};return un(r)?a.story(r)?I({kind:"handle",handle:e.body(r)}):l("invalid-handle","this document declares no such header or footer",B(r)):l("unknown-operation","that is not a furniture variant",String(o.variant))}case "getNotes":{if(!e.resolve(o.document,"document"))return l("invalid-handle","that handle does not name a document","document");if(o.noteKind!=="footnote"&&o.noteKind!=="endnote")return l("unknown-operation","that is not a kind of note",String(o.noteKind));let t=o.noteKind,r=a.noteIds(t);return r.ok?I({kind:"handles",handles:r.ids.map(d=>e.note(t,d))}):l("ambiguous-document",`${t} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getNoteBody":case "getNoteText":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=t,d=a.story(r);return d?o.op==="getNoteText"?I({kind:"text",text:d.text(o.projection)}):I({kind:"handle",handle:e.body(r)}):l("invalid-handle","that note is not in this document",B(r))}case "getNoteKind":{let t=e.resolve(o.note,"note");return !t||t.kind!=="note"?l("invalid-handle","that handle does not name a note","note"):I({kind:"text",text:t.noteKind})}case "deleteNote":{let t=e.resolve(o.note,"note");if(!t||t.kind!=="note")return l("invalid-handle","that handle does not name a note","note");let r=a.noteIds(t.noteKind);return r.ok?r.ids.includes(t.noteId)?oo(t.noteKind,t.noteId):l("invalid-handle","that note is not in this document"):l("ambiguous-document",`${t.noteKind} identities are not completely and unambiguously enumerable`,r.reason==="duplicates"?r.duplicateIds.join(","):r.reason)}case "getLists":{let t=K(o.body,"body",e,a);return t.ok?I({kind:"handles",handles:Vt(t.value).map(r=>e.list(r.numId,t.value.story))}):l(t.code,"that handle does not name a body",t.detail)}case "getListId":{let t=Ut(o.list);return "list"in t?I({kind:"number",value:Number(t.list.numId)}):t}case "getListById":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);if(!Number.isInteger(o.id)||o.id<=0)return l("unsupported-content","a list is numbered from one",String(o.id));let r=String(o.id),d=Vt(t.value).find(c=>c.numId===r);return d?I({kind:"handle",handle:e.list(d.numId,t.value.story)}):l("invalid-handle","no list in that story carries that number",r)}case "getListParagraphs":{let t=Ut(o.list);if(!("list"in t))return t;let r=o.level;if(r!==void 0&&(!Number.isInteger(r)||r<0||r>vt))return l("invalid-offset",`a list level is 0 to ${String(vt)}`,String(r));let d=t.plan.reads,c=r===void 0?t.list.paragraphIds:t.list.paragraphIds.filter(f=>Pt(d,f)?.level===r);return I({kind:"handles",handles:c.map(f=>e.paragraph(f,d.story))})}case "getParagraphList":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Pt(r,t.value.paragraphId);return d?I({kind:"handle",handle:e.list(d.numId,r.story)}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "getListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);if(!r)return l("invalid-handle","that story is not in this document");let d=Pt(r,t.value.paragraphId);return d?I({kind:"number",value:d.level}):l("unsupported-content","that paragraph is not in a list",t.value.paragraphId)}case "setListLevel":{let t=Z(o.paragraph,e,a);if(!t.ok)return l(t.code,"that handle does not name a paragraph",t.detail);let r=a.story(t.value.story);return r?ro(u(r),t.value.paragraphId,o.level):l("invalid-handle","that story is not in this document")}case "insertListParagraph":{let t=Ut(o.list);return "list"in t?ao(t.plan,t.list,o.where,o.text):t}case "getHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.span,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=a.package;if(!d||!t.value)return I({kind:"text",text:""});let c=he(r.value,t.value);if(!c)return I({kind:"text",text:""});let f=Ca(r.value.part,c.id),h=f?On(d,r.value.part.name,f):null;return I({kind:"text",text:h??""})}case "setHyperlink":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no text to link","empty-story");let r=M(t.value);return r?io(u(r),t.value,o.target):l("invalid-handle","that story is not in this document")}case "getBookmarks":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that span is not a place",r.detail);let d=r.value,c=t.value,f=c===null?null:new Set(tt(c,d)),h=ue(d).filter(x=>{if(!f||!f.has(x.start.paragraphId)&&!f.has(x.end.paragraphId)||c===null)return false;let R=x.start.paragraphId===c.end.paragraphId&&x.start.offset>c.end.offset,H=x.end.paragraphId===c.start.paragraphId&&x.end.offset<c.start.offset;return !R&&!H});return I({kind:"handles",handles:h.map(x=>e.bookmark(x.name,d.story))})}case "getBookmarkName":{let t=e.resolve(o.bookmark,"bookmark");return !t||t.kind!=="bookmark"?l("invalid-handle","that handle does not name a bookmark","bookmark"):I({kind:"text",text:t.name})}case "getBookmarkRange":{let t=Ae(o.bookmark);return "reads"in t?I({kind:"span",span:X(t.range)}):t}case "getComments":{let t=W(o.scope,e,a);if(!t.ok)return l(t.code,"that scope is not a place",t.detail);let r=q(o.scope,e,a);if(!r.ok)return l(r.code,"that scope names no story",r.detail);let d=r.value,c=k(d);if(!c)return l("document-unavailable","this host holds no document");let f=t.value,h=c.roots.filter(x=>{if(!f)return true;let R=x.range;if(!R)return false;let H=d.indexOf(R.start.paragraphId),j=d.indexOf(R.end.paragraphId),D=d.indexOf(f.start.paragraphId),w=d.indexOf(f.end.paragraphId);return j<D||H>w?false:j===D&&H===D&&w===D?R.end.offset>f.start.offset&&R.start.offset<f.end.offset:true});return I({kind:"handles",handles:h.map(x=>e.comment(x.id,d.story))})}case "getCommentReplies":{let t=S(o.comment);return t.ok?I({kind:"handles",handles:t.item.replyIds.map(r=>e.comment(r,t.reads.story))}):t.planned}case "getCommentId":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.id}):t.planned}case "getCommentAuthor":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.author}):t.planned}case "getCommentDate":{let t=S(o.comment);return t.ok?I({kind:"text",text:t.item.comment.date??""}):t.planned}case "getCommentText":{let t=S(o.comment);if(!t.ok)return t.planned;let r=k(t.reads);return I({kind:"text",text:r?.textOf(t.item.id)??""})}case "getCommentRange":{let t=S(o.comment);if(!t.ok)return t.planned;let r=t.item.range;if(!r||t.item.orphaned)return l("invalid-handle","that comment has no range in this document");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let t=S(o.comment);return t.ok?I({kind:"flag",value:t.item.resolved}):t.planned}case "insertComment":return Bn(o,e,a,v);case "setCommentResolved":{let t=S(o.comment);if(!t.ok)return t.planned;if(typeof o.resolved!="boolean")return l("unsupported-content","resolved is a yes or a no",String(o.resolved));let r=y(u(t.reads));return r||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:t.item.id,resolved:o.resolved},story:t.reads.story,answer:()=>E}}case "replyToComment":{let t=S(o.comment);if(!t.ok)return t.planned;let r=fe({author:o.author,text:o.text,date:o.date,kind:"reply"});if(r)return r;let d=t.item.range;if(!d||t.item.orphaned)return l("invalid-handle","that comment has no range to reply over");let c=y(u(t.reads));if(c)return c;let f=t.reads.story,h=ye(o.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:t.item.id,anchor:{paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,...d.end.paragraphId===d.start.paragraphId?{}:{endParagraphId:d.end.paragraphId}},text:o.text,author:o.author,...h===void 0?{}:{date:h}},story:t.reads.story,answer:(x,R)=>R===void 0?E:{kind:"handle",handle:e.comment(R,f)}}}case "deleteComment":{let t=S(o.comment);return t.ok?Fn(t.item,t.reads,r=>y(u(r))):t.planned}case "getRevisions":{let t=K(o.body,"body",e,a);if(!t.ok)return l(t.code,"that handle does not name a body",t.detail);let r=t.value;return I({kind:"handles",handles:pe(r).map(d=>e.revision(d.id,r.story))})}case "getRevisionType":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.type}):t.planned}case "getRevisionAuthor":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.author}):t.planned}case "getRevisionDate":{let t=A(o.revision);return t.ok?I({kind:"text",text:t.item.date}):t.planned}case "getRevisionRange":{let t=A(o.revision);if(!t.ok)return t.planned;let[r]=t.item.item.ranges;if(!r)return l("invalid-handle","that change covers no characters");let d=b(t.reads,r);return d?I({kind:"span",span:d}):l("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let t=A(o.revision);if(!t.ok)return t.planned;let r=u(t.reads),d=y(r);if(d)return d;let c=o.op==="acceptRevision";return {ok:true,kind:"command",story:t.reads.story,ops:t.item.item.addresses.map(f=>c?{op:"acceptRevision",revision:f}:{op:"rejectRevision",revision:f}),answer:()=>E}}case "acceptAllRevisions":case "rejectAllRevisions":{let t=jn(o,e,a);if(!t.ok)return l(t.code,t.message,t.detail);let r=u(t.reads),d=y(r);if(d)return d;let c=Mn(o,t.reads);return {ok:true,kind:"command",story:t.reads.story,ops:c,answer:()=>E}}case "selectSpan":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds no paragraph to select","empty-story");let r=M(t.value);return r?ke(u(r),t.value,o.mode):l("invalid-handle","that story is not in this document")}case "selectBookmark":{let t=Ae(o.bookmark);return "reads"in t?ke(u(t.reads),t.range,o.mode):t}case "getContentControls":{let t=Xt(o.scope);return "reads"in t?I({kind:"handles",handles:_n(t.reads,t.node).map(r=>e.contentControl(r.nodeId,t.reads.story))}):t}case "getContentControlById":{let t=Xt(o.scope);if(!("reads"in t))return t;if(!Number.isInteger(o.id))return l("unsupported-content","a control id is a whole number",String(o.id));let r=Zn(t.node).find(d=>Vf(d).id===o.id);return r?I({kind:"handle",handle:e.contentControl(r.id,t.reads.story)}):l("invalid-handle","no control in that scope carries that id",String(o.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let t=Xt(o.scope);if(!("reads"in t))return t;let r=o.op==="getContentControlsByTag"?o.tag:o.title;if(typeof r!="string"||r.length===0)return l("unsupported-content","a tag or title to match is required",o.op);let d=Zn(t.node).filter(c=>{let f=Vf(c);return o.op==="getContentControlsByTag"?f.tag===r:f.alias===r});return I({kind:"handles",handles:d.map(c=>e.contentControl(c.id,t.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=t.control.properties;if(o.op==="getContentControlLock")return I({kind:"text",text:t.control.lock});if(o.op==="getContentControlSubtype")return I({kind:"text",text:r.type});if(o.op==="getContentControlFileId")return I({kind:"text",text:r.id===void 0?"":String(r.id)});let d=o.op==="getContentControlTag"?r.tag:r.alias;return I({kind:"text",text:d??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.op==="getContentControlIsBound"?t.control.properties.dataBinding!==void 0:o.op==="getContentControlPlaceholderShown"?t.control.properties.showingPlaceholder:t.control.properties.temporary;return I({kind:"flag",value:r})}case "getContentControlText":{let t=ot(o.contentControl);return "control"in t?I({kind:"text",text:Kn(t.reads,t.node,o.projection)}):t}case "getContentControlParagraphs":{let t=ot(o.contentControl);return "control"in t?I({kind:"handles",handles:t.control.paragraphIds.map(r=>e.paragraph(r,t.reads.story))}):t}case "getContentControlRange":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=o.location??"whole";if(!dr.has(r))return l("unsupported-content","that is not a place in a control",r);let d=$t(t.reads,t.node);if(!d)return l("unsupported-content","that control holds nothing addressable","empty");let c=r==="start"||r==="before"?d.start:d.end,f=r!=="whole"&&r!=="content",h=x=>({story:t.reads.story,paragraphId:x.paragraphId,index:t.reads.indexOf(x.paragraphId),offset:x.offset});return I({kind:"span",span:de(f?{start:h(c),end:h(c)}:{start:h(d.start),end:h(d.end)},e)})}case "setContentControlValue":{let t=ot(o.contentControl);if(!("control"in t))return t;let r=cr(o.value);if(!r.ok)return l(r.code,r.message,r.detail);let d=u(t.reads),c=y(d);return c||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:r.value}],answer:()=>E}}case "setContentControlProperties":{let t=ot(o.contentControl);if(!("control"in t))return t;if(o.tag===void 0&&o.title===void 0&&o.lock===void 0)return l("unsupported-content","nothing to write","no-properties");if(o.lock!==void 0&&!sr.has(o.lock))return l("unsupported-content","that is not a lock this schema declares",o.lock);let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlProperties",controlId:t.control.nodeId,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title},...o.lock===void 0?{}:{lock:o.lock}}],answer:()=>E}}case "insertContentControlText":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.text!="string")return l("unsupported-content","text is required","text");if(o.at!=="replace"&&o.at!=="start"&&o.at!=="end")return l("unsupported-content","that is not a place to insert at",String(o.at));let r=u(t.reads),d=y(r);if(d)return d;let c=$t(t.reads,t.node);if(!c)return l("unsupported-content","that control holds nothing addressable","empty");let f=o.at==="end"?c.end:c.start,h=()=>({kind:"span",span:X({start:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset},end:{story:t.reads.story,paragraphId:f.paragraphId,index:t.reads.indexOf(f.paragraphId),offset:f.offset+o.text.length}})});return o.at==="replace"?{ok:true,kind:"command",story:t.reads.story,ops:[{op:"setContentControlValue",controlId:t.control.nodeId,value:{kind:"text",text:o.text}}],answer:h}:{ok:true,kind:"command",story:t.reads.story,ops:o.text.length===0?[]:[{op:"insertText",paragraphId:f.paragraphId,offset:f.offset,text:o.text,inside:t.node.id}],answer:h}}case "deleteContentControl":{let t=ot(o.contentControl);if(!("control"in t))return t;if(typeof o.keepContent!="boolean")return l("unsupported-content","keepContent is required","keepContent");let r=u(t.reads),d=y(r);return d||{ok:true,kind:"command",story:t.reads.story,ops:[{op:"removeContentControl",controlId:t.control.nodeId,keepContent:o.keepContent}],answer:()=>E}}case "insertContentControl":{let t=W(o.span,e,a);if(!t.ok)return l(t.code,"that span is not a place",t.detail);if(!t.value)return l("invalid-offset","that story holds nothing to wrap","empty-story");let r=M(t.value);if(!r)return l("invalid-handle","that story is not in this document");let d=t.value;if(d.start.paragraphId!==d.end.paragraphId)return l("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!lr.has(o.subtype))return l("unsupported-content","that control type cannot be inserted",o.subtype);let c=u(r),f=y(c);return f||{ok:true,kind:"command",story:r.story,ops:[{op:"insertContentControl",paragraphId:d.start.paragraphId,start:d.start.offset,end:d.end.offset,type:o.subtype,...o.tag===void 0?{}:{tag:o.tag},...o.title===void 0?{}:{alias:o.title}}],answer:()=>E}}case "insertCustomNode":{let t=Yn(o);if(t)return l("unsupported-content",t.message,t.detail);let r=Xn(o.payload);if(!r.ok)return l("unsupported-content","that payload cannot be written",r.field);let d=Jn(o,e,a);if("code"in d)return l(d.code,d.message,d.detail);let{start:c,end:f}=d.range,h=M(d.range);if(!h)return l("invalid-handle","that story is not in this document");let x=y(u(h));return x||{ok:true,kind:"customNodeWrite",story:h.story,write:Gn(o,c,f,r.value),answer:()=>E}}default:return l("unknown-operation","this host does not implement that operation",String(o.op))}};return {plan(o){let t=g.conflict(o);if(t)return l("conflicting-operations",t.message,t.detail);let r=so(o);return r.ok&&g.note(o),r},get hasCommands(){return g.hasCommands},get writeScope(){return p?.reads.scope??null},settle(o){let t=p;if(t){let r=o.story(t.reads.story);if(!r)return {ok:false,detail:`the story this batch wrote is gone: ${B(t.reads.story)}`};let d=new Set(t.reads.paragraphIds),c=r.paragraphIds.filter(h=>!d.has(h));if(c.length!==t.created.length)return {ok:false,detail:`planned ${String(t.created.length)} new paragraphs, the transaction made ${String(c.length)}`};t.order.filter(h=>h.id===null).forEach((h,x)=>{h.id=c[x]??null;});for(let h of t.retargets)h.slot.id&&e.retarget(h.from,h.slot.id);}for(let r of m){let d=o.story(r.range.start.story);!d||!fr(r.range,d)||n.select?.(r.range,r.mode);}return {ok:true}}}}var gr=Object.freeze({status:"skipped"});function G(n,e,i){return Object.freeze(i===void 0?{code:n,message:e}:{code:n,message:e,detail:i})}function hr(n){let e=n==="unsupported-revision"||n.startsWith("unsupported-revision:");return G(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",n)}function et(n,e,i,a){return {ok:false,results:n.map((s,u)=>u===e?{status:"error",error:i}:gr),revision:a,changed:false}}function pi(n){let{port:e}=n,i=Object.freeze({...n.capabilities}),a=cn(),s=new Set,u=false,m=null,g=i.events?e.subscribe(()=>{if(u)return;let v=Object.freeze({revision:e.revision()});for(let k of [...s])k(v);}):()=>{},p=v=>{if(m&&m.pkg===v)return m.value;let k=In(v);return m={pkg:v,value:k},k};return {capabilities:i,revision:()=>e.revision(),execute:v=>{let k=Array.isArray(v?.operations)?v.operations:[],S=e.revision();if(u)return et(k,0,G("disposed","this host was disposed"),S);if(!i.document)return et(k,0,G("unsupported-capability","this host has no document","document"),S);let A=e.currentPackage();if(!A)return et(k,0,G("document-unavailable","this host holds no document right now"),S);if(v.expectedRevision!==void 0&&v.expectedRevision!==S)return et(k,0,G("stale-revision","the document moved since that revision",`expected ${String(v.expectedRevision)}, at ${S}`),S);let b=qn({handles:a,reads:p(A),capabilities:i,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.select?{select:e.select.bind(e)}:{}}),C=[],O=[],T=null,L=[],F=null,J,X=null,M=-1;for(let N=0;N<k.length;N+=1){let z=b.plan(k[N]);if(!z.ok)return et(k,N,z.error,S);if(C.push(z),z.kind==="command")if(M<0&&(M=N),z.lifecycle)T=z.ops[0]??null;else if(z.relate){let it=z.relate;O.push(It=>{let pt=It(it.url);return pt===null?null:it.ops(pt)});}else {let{ops:it}=z;O.push(()=>it);}else z.kind==="commentWrite"?(M<0&&(M=N),L.push(z.write),F=b.writeScope??{kind:"body"}):z.kind==="customNodeWrite"&&(M<0&&(M=N),X={write:z.write,scope:b.writeScope??{kind:"body"}});}let V=false;if(L.length>0){let N=e.applyCommentWrites(L,F??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the comment write",N.reason),S);V=N.changed,J=N.commentId;}if(X){let N=e.applyCustomNodeWrite(X.write,X.scope);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the custom-node write",N.reason),S);V=N.changed;}if(T){let N=e.applyLifecycle(T);if(!N.ok)return et(k,M<0?0:M,G("transaction-refused","the document store refused the transaction",N.reason),S);V=N.changed;}if(O.length>0){let N=e.apply(z=>{let it=[];for(let It of O){let pt=It(z);if(pt===null)return null;it.push(...pt);}return it},b.writeScope??{kind:"body"});if(!N.ok)return et(k,M<0?0:M,hr(N.reason),S);V=N.changed;}let nt=e.currentPackage();if(!nt)return et(k,0,G("document-unavailable","this host holds no document right now"),S);let xt=p(nt),wt=b.settle(xt);return wt.ok?{ok:true,results:C.map(N=>({status:"ok",value:N.kind==="query"?N.value:N.kind==="customNodeWrite"?N.answer(xt):N.answer(xt,J)})),revision:e.revision(),changed:V}:et(k,M<0?0:M,G("transaction-refused","the transaction did not produce the document the batch planned",wt.detail),e.revision())},save(){if(u)return {ok:false,error:G("disposed","this host was disposed")};if(!i.save)return {ok:false,error:G("unsupported-capability","this host cannot save","save")};let v=e.save();return v?{ok:true,bytes:v}:{ok:false,error:G("document-unavailable","this host holds no document right now")}},subscribe(v){return u||!i.events?()=>{}:(s.add(v),()=>{s.delete(v);})},dispose(){u||(u=true,s.clear(),g(),e.dispose(),m=null);}}}export{Ft as a,Ar as b,po as c,mo as d,ne as e,oe as f,pi as g};
|