@docx-editor.dev/core 2.19.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.ts +10 -9
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.ts +8 -9
- package/dist/binding.js +1 -1
- package/dist/chunk-2H4ABRMB.cjs +20 -0
- package/dist/{chunk-YVYEJBLL.cjs → chunk-2HQXLL5L.cjs} +1 -1
- package/dist/chunk-3EZO3O6I.js +4 -0
- package/dist/{chunk-SUEX3CL7.cjs → chunk-44SIVFJT.cjs} +5 -5
- package/dist/chunk-6UCDHGXI.js +1 -0
- package/dist/chunk-7VMVDRRU.js +2 -0
- package/dist/{chunk-4DB7ZFQN.js → chunk-CAIWEQLC.js} +1 -1
- package/dist/{chunk-PBM6WERF.cjs → chunk-CEXC2VHI.cjs} +1 -1
- package/dist/chunk-CF3JR35B.js +11 -0
- package/dist/chunk-D2V4YBWJ.cjs +2 -0
- package/dist/chunk-DGSJZMAE.cjs +11 -0
- package/dist/chunk-EHBPYFRE.js +20 -0
- package/dist/chunk-GSEUM6AI.cjs +1 -0
- package/dist/chunk-H6WDEAOJ.js +18 -0
- package/dist/chunk-I6LSEDUL.cjs +18 -0
- package/dist/{chunk-ZMM5RNM6.js → chunk-IW35GWJN.js} +1 -1
- package/dist/chunk-JRBGCIR2.js +5 -0
- package/dist/chunk-K5HIOS6J.cjs +3 -0
- package/dist/chunk-KLQXP27K.js +3 -0
- package/dist/{chunk-FZ2BIMCY.cjs → chunk-MZFFU66H.cjs} +1 -1
- package/dist/{chunk-2ZEU42EA.js → chunk-MZPNLIP3.js} +1 -1
- package/dist/{chunk-NJONXJJY.cjs → chunk-OA6LFCTG.cjs} +2 -2
- package/dist/{chunk-OODFC5R2.js → chunk-OHVJYJOA.js} +1 -1
- package/dist/{chunk-THCGTV53.js → chunk-P4TGGDK3.js} +1 -1
- package/dist/{chunk-KDYD5TAW.cjs → chunk-PIBYJZIH.cjs} +1 -1
- package/dist/{chunk-CG7CP632.cjs → chunk-WTILOUPG.cjs} +1 -1
- package/dist/collaboration/replication.cjs +1 -1
- package/dist/collaboration/replication.d.ts +3 -3
- package/dist/collaboration/replication.js +1 -1
- package/dist/collaboration.d.ts +3 -3
- package/dist/contracts/document.d.ts +2 -2
- package/dist/contracts/editor.d.ts +8 -9
- package/dist/contracts/modules.d.ts +5 -7
- package/dist/contracts/types.d.ts +1 -562
- package/dist/{custom-node-writes-BqIv94ei.d.ts → custom-node-writes-piokwVR5.d.ts} +2 -2
- package/dist/{document-protection-BL5zp8cU.d.ts → document-protection-C6RvCHx-.d.ts} +1 -1
- package/dist/{editor-WXbTSXx1.d.ts → editor-BgtcHulQ.d.ts} +19 -14
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.d.ts +25 -27
- package/dist/editor.js +1 -1
- package/dist/export.cjs +2 -2
- package/dist/export.d.ts +12 -13
- package/dist/export.js +1 -1
- package/dist/{font-resolver-BSrKnTeR.d.ts → font-resolver-Bv2Z25-J.d.ts} +1 -1
- package/dist/{headless-document-view-C4ttQJ5H.d.ts → headless-document-view-DHKMN_3Y.d.ts} +2 -2
- package/dist/image-resources-C51LuAAu.d.ts +210 -0
- package/dist/{index-C3As-Xxp.d.ts → index-3lr8xXF8.d.ts} +14 -15
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +17 -18
- package/dist/index.js +1 -1
- package/dist/{layout-shaping-Dqu3JW3p.d.ts → layout-shaping-CKBUSaS7.d.ts} +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +48 -19
- package/dist/layout.js +1 -1
- package/dist/{tree-package-fragment-1pdDnhZ_.d.ts → note-lifecycle-D4AOFCAt.d.ts} +142 -141
- package/dist/{note-properties-RjYgbmXe.d.ts → note-properties-CcXUgqr8.d.ts} +2 -2
- package/dist/{omml-equation-hcP9AUFX.d.ts → omml-equation-C5P6Ym3v.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.ts +7 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-OdRd17KZ.d.ts → protocol-CsawNZkt.d.ts} +14 -4
- package/dist/{review-paragraph-order--jLHXIcd.d.ts → review-paragraph-order-BCIqjopY.d.ts} +2 -3
- package/dist/{revision-projection-BIHO_qvw.d.ts → revision-projection-BcRnC4Yj.d.ts} +1 -1
- package/dist/{semantic-cell-selection-lCYAVCCF.d.ts → semantic-cell-selection-R9wrenwR.d.ts} +4 -4
- package/dist/{semantic-interaction-0vQXcMZk.d.ts → semantic-interaction-B7beVwH7.d.ts} +1 -1
- package/dist/{semantic-paint-BSan4pBk.d.ts → semantic-paint-CLvHwf8y.d.ts} +2 -2
- package/dist/{semantic-records-ZcYuB4-H.d.ts → semantic-records-CbXwnS80.d.ts} +5 -4
- package/dist/store.cjs +1 -1
- package/dist/store.d.ts +13 -14
- package/dist/store.js +1 -1
- package/dist/{tree-session-contract-Cgn6fQ-M.d.ts → tree-session-contract-DTQxw2zL.d.ts} +5 -5
- package/dist/{tree-op-types-DbdM7fJV.d.ts → types-barrel-CEOy-Jv0.d.ts} +961 -210
- package/package.json +2 -2
- package/dist/chunk-4KMSEFIG.js +0 -3
- package/dist/chunk-72BDQFHY.js +0 -18
- package/dist/chunk-77DD4EBC.cjs +0 -11
- package/dist/chunk-BEOPUDAB.js +0 -5
- package/dist/chunk-CJCFEXTA.js +0 -11
- package/dist/chunk-DQS4KZUX.js +0 -4
- package/dist/chunk-GUPITGJQ.cjs +0 -2
- package/dist/chunk-LQ6XWTKQ.cjs +0 -18
- package/dist/chunk-MDP5SNK4.cjs +0 -3
- package/dist/chunk-MRPPCGCX.cjs +0 -20
- package/dist/chunk-MSIFK7TJ.js +0 -1
- package/dist/chunk-P6VGDI57.js +0 -2
- package/dist/chunk-QBMAXYN7.js +0 -20
- package/dist/chunk-ZKQX2PNF.cjs +0 -1
- package/dist/review-items-CJz-kAW8.d.ts +0 -370
package/dist/chunk-DQS4KZUX.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import {f,c,d,e}from'./chunk-RIYSCEFQ.js';import {r,v,W as W$1,G as G$1,b,qa,oa as oa$1,Pb,gc,ua as ua$1,Oc,Nc as Nc$1,T,je,B as B$1,Pc,J as J$1,Q as Q$1,Ja,Rb,ic,fc,ta as ta$1,pa as pa$1,C,a as a$1,A}from'./chunk-72BDQFHY.js';import {Ha}from'./chunk-4KMSEFIG.js';import {a,gh,Kc,Ic,Nc,Jc,Nf,jh,ih,hh,wc,Gc}from'./chunk-CJCFEXTA.js';var Jn=Symbol("validated-resolved-font"),Qn=4,ee=64*1024*1024,D=256,V=128*1024*1024,j=class extends Error{name="FontResolutionError";request;code;limit;actual;diagnostic;expectedHash;actualHash;constructor(t,n,r={}){super(`Font resolution failed (${t}) for ${W(n)}`),this.code=t,this.request=K(n),this.limit=r.limit,this.actual=r.actual,this.diagnostic=r.diagnostic,this.expectedHash=r.expectedHash,this.actualHash=r.actualHash;}},jt=e=>{if(e.family.trim().length===0)throw new TypeError("Font family must not be empty");if(!Number.isInteger(e.weight)||e.weight<1||e.weight>1e3)throw new RangeError("Font weight must be an integer from 1 through 1000");if(e.style!=="normal"&&e.style!=="italic")throw new TypeError("Font style must be normal or italic")},K=e=>(jt(e),Object.freeze({family:e.family,weight:e.weight,style:e.style})),Ke=e=>{let t={family:e.family,weight:e.weight,style:e.style};return K(t)},Gt=Symbol("prepared-font-resource"),Xe=new WeakMap,er=new Uint8Array(0),Vt=Object.getPrototypeOf(Uint8Array.prototype),tr=Object.getOwnPropertyDescriptor(Vt,"length").get,nr=Object.getOwnPropertyDescriptor(Vt,"byteLength").get;function te(e){if(!ArrayBuffer.isView(e))throw new TypeError("Font bytes must be a genuine byte array");let t,n;try{t=tr.call(e),n=nr.call(e);}catch{throw new TypeError("Font bytes must be a genuine byte array")}if(t!==n)throw new TypeError("Font bytes must use one-byte elements");return n}function Wt(e){let t=new Uint8Array(te(e));return Uint8Array.prototype.set.call(t,e),t}function Kt(e,t){let n=K(e.request);if(e.availability==="forbidden"){let s=Object.freeze({...e,request:n,actualHash:null,[Gt]:true});return Xe.set(s,null),s}let r=Wt(e.bytes);t?.onOwnedByteCopy?.(),t?.onHash?.();let o=a(r),a$1=Object.freeze({...e,request:n,bytes:r,actualHash:o,[Gt]:true});return Xe.set(a$1,o),a$1}function ne(e){return Xe.get(e)}var Xt=e=>{if(!Number.isFinite(e.heightEm)||!Number.isFinite(e.baselineEm)||e.heightEm<=0||e.heightEm>Qn||e.baselineEm<0||e.baselineEm>e.heightEm)throw new RangeError("Font substitution line metrics must fit within a bounded em box");return Object.freeze({heightEm:e.heightEm,baselineEm:e.baselineEm})},W=e=>(jt(e),JSON.stringify([e.family.trim().toLowerCase(),e.weight,e.style])),qe=class{[Jn]=true;id;identity;request;family;byteLength;hash;faceIndex;substitution;constructor(t,n){if(t.id.length===0)throw new TypeError("Resolved font id must not be empty");if(!Number.isInteger(t.faceIndex)||t.faceIndex<0)throw new RangeError("Font face index must be a non-negative integer");this.id=t.id,this.request=K(t.request),this.family=this.request.family,this.hash=t.hash,this.faceIndex=t.faceIndex,this.identity=`${this.hash}#${this.faceIndex}`,this.byteLength=t.byteLength,this.substitution=null,n&&(this.substitution=Object.freeze({requested:K(n.requested),resolved:K(n.resolved),...n.lineMetrics?{lineMetrics:Xt(n.lineMetrics)}:{}})),Object.freeze(this);}get bytes(){return Ee(this).slice()}},qt=new WeakSet,Yt=new WeakMap,$t=new WeakMap,Zt=(e,t,n,r)=>{let o=new qe(e,r);return Yt.set(o,t),$t.set(o,n),qt.add(o),o},Ee=e=>{re(e);let t=Yt.get(e);if(!t)throw new TypeError("Resolved font has no owned byte capability");return t},Ce=e=>{re(e);let t=$t.get(e);if(!t)throw new TypeError("Resolved font has no admitted table metadata");return t},re=e=>{if(typeof e!="object"||e===null||!qt.has(e))throw new TypeError("Shaping requires a validated resolved font")},Jt=(e,t)=>e[t]<<8|e[t+1],Q=(e,t)=>e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]>>>0,Ut=(e,t)=>{if(t>e.byteLength-12)return {valid:false,diagnostic:"truncated sfnt header"};let n=String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]);if(!(e[t]===0&&e[t+1]===1&&e[t+2]===0&&e[t+3]===0)&&n!=="OTTO"&&n!=="true"&&n!=="typ1")return {valid:false,diagnostic:"unsupported sfnt signature"};let o=Jt(e,t+4),a=t+12+o*16;if(!Number.isSafeInteger(a)||a>e.byteLength)return {valid:false,diagnostic:"truncated sfnt table directory"};for(let s=0;s<o;s+=1){let l=t+12+s*16,i=Q(e,l+8),d=Q(e,l+12);if(i>e.byteLength||d>e.byteLength-i)return {valid:false,diagnostic:"sfnt table range exceeds font bytes"}}return {valid:true}},rr=(e,t)=>{let r=String.fromCharCode(e[0],e[1],e[2],e[3])==="ttcf"?Q(e,12+t*4):0,o=Jt(e,r+4),a=new Set;for(let s=0;s<o;s+=1){let l=r+12+s*16;a.add(String.fromCharCode(e[l],e[l+1],e[l+2],e[l+3]));}return Object.freeze(a)},we=(e,t)=>{if(!Number.isSafeInteger(t)||t<0)return {valid:false,diagnostic:"invalid font face index"};if(e.byteLength<12)return {valid:false,diagnostic:"truncated sfnt header"};if(String.fromCharCode(e[0],e[1],e[2],e[3])!=="ttcf")return t!==0?{valid:false,diagnostic:"standalone sfnt has only face index zero"}:Ut(e,0);let r=Q(e,4);if(r!==65536&&r!==131072)return {valid:false,diagnostic:"unsupported TTC version"};let o=Q(e,8),a=12+o*4;if(o===0||!Number.isSafeInteger(a)||a>e.byteLength||t>=o)return {valid:false,diagnostic:"invalid TTC face directory"};let s=Q(e,12+t*4);return s<a?{valid:false,diagnostic:"invalid TTC face offset"}:Ut(e,s)},or=(e,t,n,r)=>{if(e.availability==="forbidden")return {kind:"forbidden"};let o=te(e.bytes);if(o>t)return {kind:"overLimit",actual:o};let a$1=ne(e),s=a$1===void 0?Wt(e.bytes):e.bytes;a$1===void 0&&r?.onOwnedByteCopy?.(),a$1===void 0&&r?.onHash?.();let l=a$1??a(s);if(e.hash!==l)return {kind:"hashMismatch",expectedHash:e.hash,actualHash:l};let i=we(s,e.faceIndex);if(!i.valid)return {kind:"malformed",diagnostic:i.diagnostic};r?.onTableScan?.();let d=rr(s,e.faceIndex);try{let y=n(s,e.faceIndex);if(!y.valid)return {kind:"malformed",diagnostic:y.diagnostic}}catch(y){return {kind:"malformed",diagnostic:y instanceof Error?y.message:"font validator threw"}}let c={kind:"resolved",font:Zt({...e,byteLength:s.byteLength},s,d)};return r?.onAdmission?.(),c},Ye=e=>{let t=e.epoch,n=e.maxFontBytes,r=e.validateFont,o=e.instrumentation,a=e.resources,s=e.substitutions;if(!Number.isSafeInteger(t)||t<0)throw new RangeError("Font resource epoch must be a non-negative safe integer");if(!Number.isSafeInteger(n)||n<=0||n>ee)throw new RangeError(`Font byte ceiling must be a positive safe integer no greater than ${ee}`);if(typeof r!="function")throw new TypeError("Font snapshot requires a validator");let l=a.length,i=s?.length??0;if(l>D)throw new RangeError(`Font source count must not exceed ${D}`);if(i>D)throw new RangeError(`Font substitution count must not exceed ${D}`);let d=0,c=[];for(let m=0;m<l;m+=1){let u=a[m];if(ne(u)!==void 0){let v=u.availability==="forbidden"?0:te(u.bytes);if(v>V-d)throw new RangeError(`Aggregate font bytes must not exceed ${V}`);d+=v,c.push(u);continue}let g=Ke(u.request),f=u.id,E=u.hash,F=u.faceIndex,T=u.availability,h=T==="forbidden"?er:u.bytes,p=T==="forbidden"?0:te(h);if(p>V-d)throw new RangeError(`Aggregate font bytes must not exceed ${V}`);d+=p,c.push(Object.freeze({request:g,id:f,bytes:h,hash:E,faceIndex:F,...T?{availability:T}:{}}));}let y=[];if(s)for(let m=0;m<i;m+=1){let u=s[m],g=Ke(u.from),f=Ke(u.to),E=u.lineMetrics;y.push(Object.freeze({from:g,to:f,...E?{lineMetrics:Object.freeze({heightEm:E.heightEm,baselineEm:E.baselineEm})}:{}}));}let S=new Map;for(let m of c){let u=W(m.request);S.has(u)||S.set(u,or(m,n,r,o));}let b=new Map;for(let m of y){let u=W(m.from);b.has(u)||b.set(u,Object.freeze({to:K(m.to),...m.lineMetrics?{lineMetrics:Xt(m.lineMetrics)}:{}}));}return Object.freeze({epoch:t,resolve:m=>{let u=K(m),g=W(u),f=b.get(g),E=f?.to??u,F=S.get(W(E));return F?F.kind==="forbidden"?new j("forbidden",u):F.kind==="overLimit"?new j("overLimit",u,{limit:n,actual:F.actual}):F.kind==="malformed"?new j("malformed",u,{diagnostic:F.diagnostic}):F.kind==="hashMismatch"?new j("hashMismatch",u,{expectedHash:F.expectedHash,actualHash:F.actualHash}):f?Zt({request:F.font.request,id:F.font.id,hash:F.font.hash,faceIndex:F.font.faceIndex,byteLength:F.font.byteLength},Ee(F.font),Ce(F.font),{requested:u,resolved:f.to,...f.lineMetrics?{lineMetrics:f.lineMetrics}:{}}):F.font:new j("missing",u)}})};var M=e=>{if(!Number.isSafeInteger(e))throw new RangeError("Fixed-point value must be a safe integer");return e},Oe=(e,t)=>{if(e.trim().length===0||/[\u0000-\u001f\u007f]/.test(e))throw new TypeError(`${t} must be non-blank and contain no control characters`)},ar=(e,t)=>{if(!/^[\x20-\x7e]{4}$/.test(e))throw new TypeError(`${t} must be a four-byte ASCII tag`)},Qt=(e,t,n)=>{let r=Object.entries(e).sort(([a],[s])=>a<s?-1:a>s?1:0),o=Object.create(null);for(let[a,s]of r){if(ar(a,`${t} key`),!Number.isFinite(s)||n&&(!Number.isSafeInteger(s)||s<0))throw new RangeError(`${t} value must be ${n?"a non-negative safe integer":"finite"}`);if(n&&s>4294967295)throw new RangeError(`${t} value must fit an unsigned 32-bit integer`);o[a]=s;}return Object.freeze(o)},$e=e=>Object.freeze({family:e.family,weight:e.weight,style:e.style}),ir=e=>e?Object.freeze({requested:$e(e.requested),resolved:$e(e.resolved),...e.lineMetrics?{lineMetrics:Object.freeze({...e.lineMetrics})}:{}}):void 0,en=new WeakSet,Je=e=>{if(re(e),!en.has(e)){if(e.identity!==`${e.hash}#${e.faceIndex}`)throw new TypeError("Resolved font identity does not match hash and face index");if(!Number.isSafeInteger(e.byteLength)||e.byteLength<0)throw new TypeError("Resolved font byte length is invalid");en.add(e);}},Ze=e=>(Je(e),e),Te=e=>(Je(e),Object.freeze({identity:e.identity,id:e.id,family:e.family,request:$e(e.request),hash:e.hash,faceIndex:e.faceIndex,byteLength:e.byteLength,substitution:ir(e.substitution)??null})),Y=e=>{if(Oe(e.shapingLibrary.name,"shaping library name"),Oe(e.shapingLibrary.version,"shaping library version"),Oe(e.unicodeDataVersion,"Unicode data version"),!/^\d+(?:\.\d+){0,3}(?:[-+][0-9A-Za-z.-]+)?$/.test(e.shapingLibrary.version))throw new TypeError("shaping library version must be a numeric version");if(!/^\d+(?:\.\d+){1,2}$/.test(e.unicodeDataVersion))throw new TypeError("Unicode data version must be a dotted numeric version");if(!/^[A-Z][a-z]{3}$/.test(e.script))throw new TypeError("script must be a four-letter ISO 15924 code");if(Oe(e.language,"language"),!/^(?:und|[A-Za-z]{2,8})(?:-[A-Za-z0-9]{1,8})*$/.test(e.language))throw new TypeError("language must be a BCP 47 language tag");if(e.direction!=="ltr"&&e.direction!=="rtl")throw new TypeError("direction must be ltr or rtl");if(!["none","NFC","NFD","NFKC","NFKD"].includes(e.normalization))throw new TypeError("invalid normalization policy");if(!["halfAwayFromZero","halfToEven","towardZero"].includes(e.roundingMode))throw new TypeError("invalid fixed-point rounding mode");if(!Number.isSafeInteger(e.fixedPointScale)||e.fixedPointScale<=0)throw new RangeError("fixed-point scale must be a positive safe integer");let t=Ze(e.font),n=e.fallbackOrder.map(Ze),r=new Set;for(let o of n){let a=JSON.stringify(Te(o));if(r.has(a))throw new TypeError("fallback order contains a duplicate font");r.add(a);}return Object.freeze({font:t,variationAxes:Qt(e.variationAxes,"variation axis",false),shapingLibrary:Object.freeze({name:e.shapingLibrary.name,version:e.shapingLibrary.version}),unicodeDataVersion:e.unicodeDataVersion,normalization:e.normalization,script:e.script,language:e.language,direction:e.direction,features:Qt(e.features,"OpenType feature",true),fallbackOrder:Object.freeze([...n]),fixedPointScale:e.fixedPointScale,roundingMode:e.roundingMode})},nn=e=>{let t=Y(e);return Object.freeze({font:Te(t.font),variationAxes:Object.freeze(Object.entries(t.variationAxes).map(n=>Object.freeze(n))),shapingLibrary:Object.freeze({name:t.shapingLibrary.name,version:t.shapingLibrary.version}),unicodeDataVersion:t.unicodeDataVersion,normalization:t.normalization,script:t.script,language:t.language,direction:t.direction,features:Object.freeze(Object.entries(t.features).map(n=>Object.freeze(n))),fallbackOrder:Object.freeze(t.fallbackOrder.map(Te)),fixedPointScale:t.fixedPointScale,roundingMode:t.roundingMode})},Qe=e=>JSON.stringify(nn(e)),q=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`${t} must be a non-negative safe integer`)},B=e=>{try{return M(e)}catch{throw new RangeError("Shaped run contains a non-integer fixed-point value")}},tn=new WeakMap,Ie=e=>{let t=tn.get(e);if(t)return t;Je(e);let n=JSON.stringify({identity:e.identity,id:e.id,family:e.family,request:e.request,hash:e.hash,faceIndex:e.faceIndex,byteLength:e.byteLength,substitution:e.substitution??null});return tn.set(e,n),n},Le=(e,t)=>{let n=Y(t);if(e.direction!=="ltr"&&e.direction!=="rtl")throw new TypeError("Shaped run direction must be ltr or rtl");if(e.direction!==n.direction)throw new TypeError("Shaped run direction does not match shaping environment");if(q(e.bidiLevel,"bidi level"),(e.bidiLevel&1)===1!=(e.direction==="rtl"))throw new TypeError("Shaped run direction does not match bidi level parity");let r=new Map,o=e.glyphs.map(i=>{q(i.id,"glyph id"),q(i.cluster,"glyph cluster");let d=r.get(i.outline);if(!d){if(!Number.isSafeInteger(i.outline.unitsPerEm)||i.outline.unitsPerEm<=0)throw new RangeError("Glyph outline units per em must be a positive safe integer");d=Object.isFrozen(i.outline)?i.outline:Object.freeze({path:i.outline.path,unitsPerEm:i.outline.unitsPerEm}),r.set(i.outline,d);}return Object.freeze({id:i.id,cluster:i.cluster,originX:B(i.originX),originY:B(i.originY),advanceX:B(i.advanceX),advanceY:B(i.advanceY),offsetX:B(i.offsetX),offsetY:B(i.offsetY),outline:d})}),a=e.fontSpans.map(i=>{if(q(i.glyphStart,"font span start"),q(i.glyphEnd,"font span end"),i.glyphEnd<=i.glyphStart||i.glyphEnd>o.length)throw new RangeError("Font span glyph range is invalid");i.fallbackIndex!==null&&q(i.fallbackIndex,"fallback index");let d=Ze(i.font);if(i.fallbackIndex===null){if(Ie(d)!==Ie(n.font))throw new TypeError("Shaped primary font does not match shaping environment")}else {let c=n.fallbackOrder[i.fallbackIndex];if(!c)throw new RangeError("Shaped fallback index is outside fallback order");if(Ie(d)!==Ie(c))throw new TypeError("Shaped fallback font does not match shaping environment provenance")}return Object.freeze({...i,font:d})});for(let i=0;i<a.length;i+=1){let d=i===0?0:a[i-1].glyphEnd;if(a[i].glyphStart!==d)throw new RangeError("Font spans must cover glyphs contiguously")}if(o.length===0&&a.length!==0||o.length>0&&a.at(-1)?.glyphEnd!==o.length)throw new RangeError("Font spans must cover every glyph exactly once");let s=e.clusters.map(i=>{for(let[c,y]of [["cluster text start",i.textStart],["cluster text end",i.textEnd],["cluster glyph start",i.glyphStart],["cluster glyph end",i.glyphEnd],["cluster font span",i.fontSpan]])q(y,c);if(i.textEnd<=i.textStart||i.textEnd>e.text.length||i.glyphEnd<=i.glyphStart||i.glyphEnd>o.length)throw new RangeError("Shaped cluster range is invalid");let d=a[i.fontSpan];if(!d||i.glyphStart<d.glyphStart||i.glyphEnd>d.glyphEnd)throw new RangeError("Shaped cluster does not belong to its declared font span");return Object.freeze({...i,advance:B(i.advance),caretEdges:Object.freeze(i.caretEdges.map(B))})}),l=Object.freeze({ascent:B(e.metrics.ascent),descent:B(e.metrics.descent),lineGap:B(e.metrics.lineGap)});return Object.freeze({text:e.text,direction:e.direction,bidiLevel:e.bidiLevel,glyphs:Object.freeze(o),clusters:Object.freeze(s),fontSpans:Object.freeze(a),metrics:l})},sr=(e,t)=>{let n=Le(e,t);return Object.freeze({text:n.text,direction:n.direction,script:t.script,language:t.language,bidiLevel:n.bidiLevel,glyphs:n.glyphs,clusters:n.clusters,fontSpans:Object.freeze(n.fontSpans.map(r=>Object.freeze({glyphStart:r.glyphStart,glyphEnd:r.glyphEnd,fallbackIndex:r.fallbackIndex,font:Te(r.font)}))),metrics:n.metrics})};var $=Object.freeze({name:"HarfBuzz",version:"14.4.0"}),ce=null,le=null;function tt(){return ce?Promise.resolve():le||(le=import('./dist-PKZR6RSH.js').then(e=>{let t=e.versionString();if(t!==$.version)throw new w("shapingLibraryMismatch",{diagnostic:f($.version,t)});ce=e;}).catch(e$1=>{throw le=null,e$1 instanceof w?e$1:c(e$1)?new w("unsupportedRuntime",{diagnostic:d(e$1),cause:e$1}):new w("wasmUnavailable",{diagnostic:e(e$1),cause:e$1})}),le)}function lr(){return ce!==null}function dr(){if(!ce)throw new w("notInitialized",{diagnostic:"Call initializeHarfBuzz() before creating a text shaper"});return ce}var w=class extends Error{name="HarfBuzzShapingError";code;limit;actual;diagnostic;constructor(t,n={}){super(`HarfBuzz shaping failed (${t})`,{cause:n.cause}),this.code=t,this.limit=n.limit,this.actual=n.actual,this.diagnostic=n.diagnostic;}},cr=16*1024*1024,ur=1e6,pr=1e6,yr=1e6,fr=4,hr=512,mr=1024*1024,gr=16*1024*1024,br=32*1024*1024,Sr=64*1024*1024,xr=64*1024*1024,Rr=1e6,Fr=1e6,vr=1e6,Er=64,Cr=4096,wr=4*1024*1024,Or=64*1024*1024,Ir=64*1024*1024,Tr=256*1024*1024,Lr=new Set(["COLR","CPAL","CBDT","CBLC","sbix","SVG "]),rn=["cmap","head","hhea","hmtx","maxp"],Ar=(e,t)=>e[t]<<8|e[t+1],Br=(e,t)=>e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]>>>0,Pr=(e,t)=>String.fromCharCode(e[0],e[1],e[2],e[3])==="ttcf"?Br(e,12+t*4):0,_r=(e,t)=>{let n=Pr(e,t),r=Ar(e,n+4),o=new Set;for(let a=0;a<r;a+=1){let s=n+12+a*16;o.add(String.fromCharCode(e[s],e[s+1],e[s+2],e[s+3]));}return o},Mr=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),zr=(e,t)=>{let n=we(e,t);if(!n.valid)return n;let r=_r(e,t);for(let o of rn)if(!r.has(o))return {valid:false,diagnostic:`missing required ${o} table`};return {valid:true}},nt=zr,z=(e,t,n)=>{if(!Number.isSafeInteger(e)||e<=0||e>n)throw new RangeError(`${t} must be a positive safe integer no greater than ${n}`);return e},Nr=(e,t,n)=>{let r=e<0n,o=r?-e:e,a=o/t,s=o%t;if(n!=="towardZero"){let d=s*2n;(d>t||d===t&&(n==="halfAwayFromZero"||n==="halfToEven"&&a%2n!==0n))&&(a+=1n);}let l=r?-a:a,i=Number(l);if(!Number.isSafeInteger(i))throw new RangeError("Shaped fixed-point value exceeds the safe integer range");return i},on=(e,t,n,r)=>{if(!Number.isSafeInteger(e))throw new RangeError("font units must be a safe integer");if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("fixed-point denominator must be a positive safe integer");if(!Number.isSafeInteger(n)||n<0)throw new RangeError("fixed-point numerator must be a non-negative safe integer");return M(Nr(BigInt(e)*BigInt(n),BigInt(t),r))},kr=(e,t,n,r)=>{if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("font size must be a positive integer number of half points");if(t>Math.floor(Number.MAX_SAFE_INTEGER/n))throw new RangeError("font size and fixed-point scale product exceeds the safe integer range");let o=t*n,a=e*2;return s=>on(s,a,o,r)},Dr=(e,t)=>{if(t.length===0)return [];let n=[...new Set(t.map(s=>s.cluster))].sort((s,l)=>s-l),r=new Map;for(let s=0;s<n.length;s+=1)r.set(n[s],n[s+1]??e.length);let o=[],a=0;for(;a<t.length;){let s=t[a].cluster,l=a+1;for(;l<t.length&&t[l].cluster===s;)l+=1;let i=t.slice(a,l).reduce((c,y)=>c+y.advanceX,0),d=M(i);o.push({textStart:s,textEnd:r.get(s),glyphStart:a,glyphEnd:l,advance:d,caretEdges:Object.freeze([M(0),d]),fontSpan:0}),a=l;}return o},N=64,H=8,Z=8,Hr=32,an=N+2*H,Gr=N+H+Z,Ur=N+H+Z,jr=N+H+Z,sn=N+8*H,ln=N+8*Z+H,Vr=N+6*Z+H,Wr=N+3*Z+2*H,Kr=N+3*Z,ue=e=>N+e.length*Uint16Array.BYTES_PER_ELEMENT,rt=e=>jr+ue(e),de=e=>Hr+e*H,Xr=(e,t)=>an+ue(e)+Gr+rt(t),qr=e=>sn+ue(e)+de(e.length)+e.length*ln,Yr=e=>{let t=new Set(e.glyphs.map(n=>n.outline));return sn+ue(e.text)+de(e.glyphs.length)+e.glyphs.length*ln+de(e.clusters.length)+e.clusters.length*Vr+e.clusters.reduce((n,r)=>n+de(r.caretEdges.length),0)+de(e.fontSpans.length)+e.fontSpans.length*Wr+Kr+[...t].reduce((n,r)=>n+rt(r.path),0)},$r=(e,t)=>an+ue(e)+Ur+t,et=class{#t;#c;#u;#p;#y;#g;#b;#f;#h;#s;#m;#l;#e;#o=new Map;#a=new Map;#n=new Map;#i=0;#r=0;#d;constructor(t,n){this.#t=t,this.#c=z(n.maxFontBytes??cr,"maximum font bytes",xr),this.#u=z(n.maxInputUtf16??ur,"maximum input UTF-16 code units",Rr),this.#p=z(n.maxCodepoints??pr,"maximum input code points",Fr),this.#y=z(n.maxGlyphs??yr,"maximum shaped glyphs",vr),this.#g=z(n.maxCachedFaces??fr,"maximum cached faces",Er),this.#b=z(n.maxCachedShapes??hr,"maximum cached shape results",Cr),this.#f=z(n.maxOutlineBytes??mr,"maximum outline bytes",wr),this.#h=z(n.maxCachedOutlineBytes??gr,"maximum cached outline bytes",Or),this.#s=z(n.maxShapedRunBytes??br,"maximum shaped run bytes",Ir),this.#m=z(n.maxCachedShapeBytes??Sr,"maximum cached shape bytes",Tr),this.#l=n.instrumentation?.onFaceCacheEvent,this.#e=n.instrumentation,this.#d=new this.#t.Buffer;}dispose(){this.#o.clear(),this.#a.clear(),this.#n.clear(),this.#i=0,this.#r=0,this.#e?.onOutlineCacheEvent?.(Object.freeze({kind:"cleared",retainedBytes:0})),this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"cleared",retainedBytes:0})),this.#d=void 0;}#x(t,n){let r=this.#o.get(t.identity);if(r)return this.#o.delete(t.identity),this.#o.set(t.identity,r),this.#l?.(Object.freeze({kind:"hit",identity:t.identity})),r;let o=Ce(t);for(let c of rn)if(!o.has(c))throw new w("malformedFont",{diagnostic:`missing required ${c} table`});this.#e?.onByteCopy?.();let a=new this.#t.Blob(Mr(n)),s=new this.#t.Face(a,t.faceIndex),l=new this.#t.Font(s),i=l.hExtents();if(!Number.isSafeInteger(s.upem)||s.upem<=0||!Number.isSafeInteger(i.ascender)||!Number.isSafeInteger(i.descender)||!Number.isSafeInteger(i.lineGap))throw new w("malformedFont",{diagnostic:"invalid font units or horizontal metrics"});if(l.setScale(s.upem,s.upem),this.#o.size>=this.#g){let c=this.#o.keys().next().value;c!==void 0&&(this.#o.delete(c),this.#l?.(Object.freeze({kind:"evicted",identity:c})));}let d={identity:t.identity,blob:a,face:s,font:l,unitsPerEm:s.upem};return this.#o.set(t.identity,d),this.#l?.(Object.freeze({kind:"created",identity:t.identity})),d}#R(t,n,r){let o=JSON.stringify([t.identity,t.unitsPerEm,r,n]),a=this.#a.get(o);if(a)return this.#a.delete(o),this.#a.set(o,a),this.#e?.onOutlineCacheEvent?.(Object.freeze({kind:"hit",retainedBytes:this.#i})),a.outline;this.#e?.onOutlinePathCall?.();let s=t.font.glyphToPath(n),l=rt(s);if(l>this.#f)throw new w("outlineOverLimit",{limit:this.#f,actual:l});let i=Object.freeze({path:s,unitsPerEm:t.unitsPerEm}),d=Xr(o,s);if(d>this.#h)return this.#e?.onOutlineCacheEvent?.(Object.freeze({kind:"skipped",retainedBytes:this.#i})),i;for(;this.#i+d>this.#h;){let c=this.#a.keys().next().value;if(c===void 0)break;let y=this.#a.get(c);this.#a.delete(c),this.#i-=y.bytes,this.#e?.onOutlineCacheEvent?.(Object.freeze({kind:"evicted",retainedBytes:this.#i}));}return this.#a.set(o,{outline:i,bytes:d}),this.#i+=d,this.#e?.onOutlineCacheEvent?.(Object.freeze({kind:"created",retainedBytes:this.#i})),i}#S(t){if(t.length>this.#u)throw new w("textOverLimit",{limit:this.#u,actual:t.length});let n=0;for(let r=0;r<t.length;){let o=t.codePointAt(r);if(r+=o>65535?2:1,n+=1,n>this.#p)throw new w("codepointsOverLimit",{limit:this.#p,actual:n})}}shape(t){if(!this.#d)throw new w("disposed");if(re(t.environment.font),t.environment.font.byteLength>this.#c)throw new w("fontOverLimit",{limit:this.#c,actual:t.environment.font.byteLength});this.#S(t.text);let n=qr(t.text);if(n>this.#s)throw new w("shapedRunOverLimit",{limit:this.#s,actual:n});let r=Y(t.environment),o=JSON.stringify([t.text,t.fontSizeHalfPoints,t.bidiLevel,Qe(r)]),a=this.#n.get(o);if(a)return this.#n.delete(o),this.#n.set(o,a),this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"hit",retainedBytes:this.#r})),a.run;if(this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"miss",retainedBytes:this.#r})),r.shapingLibrary.name!==$.name||r.shapingLibrary.version!==$.version)throw new w("shapingLibraryMismatch");if(r.normalization!=="none")throw new w("unsupportedNormalization");if(!Number.isSafeInteger(t.bidiLevel)||t.bidiLevel<0||(t.bidiLevel&1)===1!=(r.direction==="rtl"))throw new w("invalidBidiLevel");if(Object.keys(r.variationAxes).length>0)throw new w("unsupportedVariationAxes");if(r.fallbackOrder.length>0)throw new w("unsupportedFallback");let s=Ee(r.font),l=Ce(r.font);if([...Lr].some(d=>l.has(d)))throw new w("unsupportedColorFont");let i=t.text;this.#S(i);try{let d=this.#x(r.font,s),{face:c,font:y}=d,S=this.#d;S.reset(),S.addText(i),S.setDirection(r.direction==="rtl"?this.#t.Direction.RTL:this.#t.Direction.LTR),S.setScript(r.script),S.setLanguage(r.language),S.setClusterLevel(this.#t.ClusterLevel.MONOTONE_CHARACTERS);let b=Object.entries(r.features).map(([R,C])=>new this.#t.Feature(R,C));this.#e?.onShapeCall?.(),this.#t.shape(y,S,b);let x=S.getGlyphInfosAndPositions();if(x.length>this.#y)throw new w("glyphOverLimit",{limit:this.#y,actual:x.length});let m=kr(c.upem,t.fontSizeHalfPoints,r.fixedPointScale,r.roundingMode),u=M(0),g=M(0),f=new Map,E=JSON.stringify(Object.entries(r.variationAxes).sort(([R],[C])=>R.localeCompare(C))),F=x.map(R=>{let C=m(R.xAdvance??0),O=m(R.yAdvance??0),I={id:R.codepoint,cluster:R.cluster,originX:u,originY:g,advanceX:C,advanceY:O,offsetX:m(R.xOffset??0),offsetY:m(R.yOffset??0),outline:f.get(R.codepoint)??(()=>{let L=this.#R(d,R.codepoint,E);return f.set(R.codepoint,L),L})()};return u=M(u+C),g=M(g+O),I}),T=y.hExtents(),h=Le({text:i,direction:r.direction,bidiLevel:t.bidiLevel,glyphs:F,clusters:Dr(i,F),fontSpans:F.length===0?[]:[{glyphStart:0,glyphEnd:F.length,font:r.font,fallbackIndex:null}],metrics:{ascent:m(T.ascender),descent:m(-T.descender),lineGap:m(T.lineGap)}},r),p=Yr(h);if(p>this.#s)throw new w("shapedRunOverLimit",{limit:this.#s,actual:p});let v=$r(o,p);if(v>this.#m)return this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"skipped",retainedBytes:this.#r})),h;for(;this.#n.size>=this.#b||this.#r+v>this.#m;){let R=this.#n.keys().next().value;if(R===void 0)break;let C=this.#n.get(R);this.#n.delete(R),this.#r-=C.bytes,this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"evicted",retainedBytes:this.#r}));}return this.#n.set(o,{run:h,bytes:v}),this.#r+=v,this.#e?.onShapeCacheEvent?.(Object.freeze({kind:"stored",retainedBytes:this.#r})),h}catch(d){throw d instanceof w?d:new w("malformedFont",{diagnostic:d instanceof Error?d.message:"HarfBuzz shaping failed"})}}},ot=(e={})=>new et(dr(),e);var dn=Object.freeze({maxFontBytes:16*1024*1024,maxInputUtf16:1e6,maxCodepoints:1e6,maxGlyphs:1e6,maxCachedFaces:4,maxCachedShapes:512,maxOutlineBytes:1024*1024,maxCachedOutlineBytes:16*1024*1024,maxShapedRunBytes:32*1024*1024,maxCachedShapeBytes:64*1024*1024});function cn(e){let t={maxFontBytes:e.maxFontBytes,maxInputUtf16:e.maxInputUtf16,maxCodepoints:e.maxCodepoints,maxGlyphs:e.maxGlyphs,maxOutlineBytes:e.maxOutlineBytes,maxShapedRunBytes:e.maxShapedRunBytes},n=["docx-editor-layout-harfbuzz-execution-policy",1,Object.entries(t).sort(([r],[o])=>r<o?-1:r>o?1:0).map(([r,o])=>Object.freeze([r,o]))];return `layout-shaper-policy:sha256:${a(new TextEncoder().encode(JSON.stringify(n)))}`}var Zr=Object.freeze({}),un=D,Jr="16.0.0",Qr="none",eo=1e3,to="halfToEven",fn="cluster-edges-only",no="Latn",ro=new Uint8Array(0);var G=class extends Error{code="overLimit";constructor(t){super(t),this.name="LayoutShapingConfigurationError";}};function oo(e,t){let n=e.epoch,r=e.maxFontBytes,o=e.sources,a=e.substitutions,s=e.defaultFont,l=e.language;if(!Number.isSafeInteger(r)||r<=0||r>ee)throw new G(`Font byte ceiling must not exceed the engine hard maximum of ${ee}`);let i=o.length,d=a?.length??0;if(i===0||i>D)throw new G(`Font source count must be between 1 and ${D}`);if(d>un)throw new G(`Font substitution count must not exceed ${un}`);let c=0,y=[];for(let x=0;x<i;x+=1){let m=o[x],u=m.request,g=m.availability,f=m.id,E=m.hash,F=m.faceIndex,T=g==="forbidden",h=T?ro:m.bytes;if(!T){if(typeof f!="string"||f.length===0)throw new TypeError("Resolved font id must not be empty");let p;try{p=te(h);}catch{throw new G(`Font source ${f} must provide genuine bytes`)}if(p>r)throw new G(`Font source ${f} exceeds the per-font byte ceiling`);if(c+=p,c>V)throw new G(`Font sources exceed the aggregate byte ceiling of ${V}`)}y.push(t&&ne(m)!==void 0?m:Object.freeze({request:Object.freeze({family:u.family,weight:u.weight,style:u.style}),id:f,bytes:h,hash:E,faceIndex:F,...g?{availability:g}:{}}));}let S;if(a){S=[];for(let x=0;x<d;x+=1){let m=a[x],u=m.from,g=m.to,f=m.lineMetrics;S.push(Object.freeze({from:Object.freeze({family:u.family,weight:u.weight,style:u.style}),to:Object.freeze({family:g.family,weight:g.weight,style:g.style}),...f?{lineMetrics:Object.freeze({heightEm:f.heightEm,baselineEm:f.baselineEm})}:{}}));}}let b={epoch:n,maxFontBytes:r,sources:Object.freeze(y),substitutions:S?Object.freeze(S):void 0,defaultFont:Object.freeze({family:s.family,sizeHalfPoints:s.sizeHalfPoints}),language:l};return Object.freeze(b)}function pn(e,t){let n=e.map((o,a)=>({value:o,index:a,key:W(t(o))})),r=new Set;for(let o of n){if(r.has(o.key))return e;r.add(o.key);}return n.sort((o,a)=>o.key<a.key?-1:o.key>a.key?1:o.index-a.index).map(({value:o})=>o)}function ao(e,t){let n={family:e.family},r={sizeHalfPoints:e.sizeHalfPoints};return {...n,...t?r:{}}}function yn(e,t){let n=i=>({family:i.family,weight:i.weight,style:i.style}),r=t?e.sources:pn(e.sources,i=>i.request),o=e.substitutions??[],a=t?o:pn(o,i=>i.from),s={sources:r.map(i=>{let d=i.availability??"available",c={request:n(i.request),availability:d};if(d==="forbidden")return {...c,...t?{id:i.id,faceIndex:i.faceIndex,declaredHash:i.hash}:{}};let y=ne(i);if(y==null)throw new TypeError("Font configuration identity requires prepared source bytes");return {...c,...t?{id:i.id}:{},faceIndex:i.faceIndex,declaredHash:i.hash,actualHash:y,byteLength:i.bytes.byteLength}}),substitutions:a.map(i=>({from:n(i.from),to:n(i.to),lineMetrics:i.lineMetrics?{heightEm:i.lineMetrics.heightEm,baselineEm:i.lineMetrics.baselineEm}:null})),defaultFont:ao(e.defaultFont,t),language:e.language||"en"},l={epoch:e.epoch,maxFontBytes:e.maxFontBytes};return {version:1,...t?l:{},...s}}var io=Symbol("prepared-layout-font-configuration"),Ae=new WeakMap;function so(e){return Ae.has(e)}function lo(e){let t=Ae.get(e);if(!t)throw new TypeError("Invalid prepared layout font configuration");return t.configuration}function La(e){let t=Ae.get(e);if(!t)throw new TypeError("Invalid prepared layout font configuration");return t.sharedShapingFingerprint}function at(e,t){return hn(e,t,false)}function Aa(e,t){return hn(e,t,true)}function hn(e,t,n){let r=oo(e,n),o=Object.freeze({epoch:r.epoch,maxFontBytes:r.maxFontBytes,sources:Object.freeze(r.sources.map(y=>n&&ne(y)!==void 0?y:Kt(y,{onOwnedByteCopy:t?.onFontByteCopy,onHash:t?.onFontHash}))),substitutions:r.substitutions,defaultFont:r.defaultFont,language:r.language}),a$1=new TextEncoder,s=yn(o,true),l=a$1.encode(JSON.stringify(s)),i=yn(o,false),d=a$1.encode(JSON.stringify(i)),c=Object.freeze({[io]:true,fingerprint:`font-config:${a(l)}`});return Ae.set(c,{configuration:o,sharedShapingFingerprint:`shared-font-config:${a(d)}`}),c}function co(e){return at(e).fingerprint}function uo(e,t){let n=new TextEncoder().encode(JSON.stringify({version:1,environment:e,executionPolicy:cn(t),ligatureCaretPolicy:fn,fallback:a$1}));return `shaping:${a(n)}`}async function mn(e,t,n,r){let a=so(e)?e:at(e,t),s=lo(a),{epoch:l,maxFontBytes:i,sources:d,substitutions:c,defaultFont:y}=s,S=s.language||"en",b=a.fingerprint,x=Ye({epoch:l,maxFontBytes:i,resources:d,substitutions:c,validateFont:nt,instrumentation:{onOwnedByteCopy:t?.onFontByteCopy,onHash:t?.onFontHash,onAdmission:t?.onFontAdmission}});await tt();let m=Object.freeze({script:no,variationAxes:Object.freeze({}),shapingLibrary:$,unicodeDataVersion:Jr,normalization:Qr,language:S,features:Zr,fixedPointScale:eo,roundingMode:to});return Object.freeze({fonts:x,shaper:n??ot(r),defaultFont:y,environment:m,ligatureCaretPolicy:fn,operation:Object.freeze({resourceEpoch:x.epoch,configEpoch:l,extensionFingerprint:b,shapingHash:uo(m,r),producerVersion:1})})}async function po(e,t){return mn(e,t,void 0,dn)}async function Ba(e,t,n,r){return mn(e,r,t,n)}function yo(e){e.shaper.dispose?.();}function it(e){let t=new Set([0,e.text.length]);for(let r$1 of r(e.text))t.add(r$1.utf16From),t.add(r$1.utf16To);let n=new Set([0,e.text.length]);for(let r of e.clusters)n.add(r.textStart),n.add(r.textEnd);return [...t].filter(r=>n.has(r)).sort((r,o)=>r-o)}function Be(e,t){return it(e).includes(t)}function fo(e,t){return Be(e,t)}function ho(e,t,n){return n>=t&&Be(e,t)&&Be(e,n)}function mo(e){let t=r(e.text);return it(e).map(n=>n===e.text.length?t.length:t.findIndex(r=>r.utf16From===n))}var lt="und";function xn(){return typeof Intl.Segmenter=="function"}function go(){let e=Intl.Segmenter;if(typeof e!="function")throw new Error(`Intl.Segmenter is required for word segmentation (locale: ${lt})`);return e}function Rn(){let e=new(go())(lt,{granularity:"word"});return {segment(t){let n=[];for(let r of e.segment(t)){let o=r.index,a=o+r.segment.length;n.push({utf16From:o,utf16To:a,wordLike:r.isWordLike===true});}return n}}}var bo=/^[\p{L}\p{N}']$/u,So=/^\s$/u;function gn(e){return bo.test(e)}function bn(e){return So.test(e)}function st(e,t,n,r){let o=e[t],a=e[n-1];return {utf16From:o.utf16From,utf16To:a.utf16To,wordLike:r}}function Fn(e){let t=r(e);if(t.length===0)return [];let n=[],r$1=0;for(;r$1<t.length;){let o=t[r$1];if(bn(o.text)){let a=r$1+1;for(;a<t.length&&bn(t[a].text);)a+=1;n.push(st(t,r$1,a,false)),r$1=a;continue}if(gn(o.text)){let a=r$1+1;for(;a<t.length&&gn(t[a].text);)a+=1;n.push(st(t,r$1,a,true)),r$1=a;continue}n.push(st(t,r$1,r$1+1,false)),r$1+=1;}return n}function vn(){return {segment:Fn}}function En(e={}){let t=e.isIntlAvailable??xn,n=e.createIntlBoundary??Rn,r=e.createFallbackBoundary??vn;if(!t())return r();try{return n()}catch{return r()}}var Sn;function Cn(){return Sn??=En(),Sn}function xo(e,t=Cn()){return t.segment(e)}function Ro(e,t){return t.map(n=>({graphemeFrom:v(e,n.utf16From),graphemeTo:v(e,n.utf16To),wordLike:n.wordLike}))}var wn={resourceEpoch:"resource-scoped",configEpoch:"coarse-gate",extensionFingerprint:"coarse-gate",shapingHash:"coarse-gate",producerVersion:"coarse-gate"},ut=Object.keys(wn),On=ut.filter(e=>wn[e]==="coarse-gate"),Pe=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`${t} must be a non-negative safe integer`)},oe=(e,t)=>{if(e.trim().length===0)throw new TypeError(`${t} must not be blank`)},Fo={resourceEpoch:Pe,configEpoch:Pe,extensionFingerprint:oe,shapingHash:oe,producerVersion:Pe},vo=(e,t)=>{Fo[t](e[t],t);},ae=e=>{for(let t of ut)vo(e,t);return Object.freeze({resourceEpoch:e.resourceEpoch,configEpoch:e.configEpoch,extensionFingerprint:e.extensionFingerprint,shapingHash:e.shapingHash,producerVersion:e.producerVersion})},Eo=(e,t)=>{let n=ae(e),r=ae(t),o=ut.filter(a=>n[a]!==r[a]);return o.length===0?Object.freeze({status:"current"}):Object.freeze({status:"restart",changed:Object.freeze(o)})},dt=e=>{let t=e.map(({key:n,fingerprint:r})=>(oe(n,"resource dependency key"),oe(r,"resource dependency fingerprint"),Object.freeze({key:n,fingerprint:r}))).sort((n,r)=>n.key<r.key?-1:n.key>r.key?1:0);for(let n=1;n<t.length;n+=1)if(t[n-1].key===t[n].key)throw new TypeError(`Duplicate resource dependency: ${t[n].key}`);return Object.freeze(t)},Co=e=>(Pe(e.revision,"revision"),oe(e.dependencyFingerprint,"dependencyFingerprint"),oe(e.inputFingerprint,"inputFingerprint"),Object.freeze({revision:e.revision,dependencyFingerprint:e.dependencyFingerprint,inputFingerprint:e.inputFingerprint,resourceDependencies:dt(e.resourceDependencies),...ae(e)})),wo=(e,t)=>{let n=dt(e),r=dt(t),o=Math.max(n.length,r.length);for(let a=0;a<o;a+=1){let s=n[a],l=r[a];if(s?.key!==l?.key||s?.fingerprint!==l?.fingerprint)return {hit:false,reason:"resource-changed",resourceKey:s?.key??l.key}}return null};function Oo(e,t){if(e.dependencyFingerprint!==t.dependencyFingerprint)return {hit:false,reason:"dependency-changed"};if(e.inputFingerprint!==t.inputFingerprint)return {hit:false,reason:"input-changed"};let n=wo(e.resourceDependencies,t.resourceDependencies);if(n)return n;for(let r of On)if(e[r]!==t[r])return {hit:false,reason:"epoch-changed",epoch:r};return null}var ct=class{entries=new Map;get(t,n){let r=this.entries.get(t);if(!r)return {hit:false,reason:"absent"};let o=Oo(r.provenance,n);return o||{hit:true,value:r.value,provenance:r.provenance}}set(t,n,r){this.entries.set(t,{value:n,provenance:Co(r)});}evictEpoch(t){let n=ae(t),r=0;for(let[o,a]of this.entries){let s=a.provenance;On.some(l=>s[l]!==n[l])&&(this.entries.delete(o),r+=1);}return r}evictResources(t,n){let r=ae(t),o=this.evictEpoch(r);for(let[a,s]of this.entries)s.provenance.resourceDependencies.some(i=>n.get(i.key)!==i.fingerprint)&&(this.entries.delete(a),o+=1);return o}get size(){return this.entries.size}};function In(e){return e.projected===true?null:e.range}function To(e,t,n){let{page:r,story:o,host:a,noteScopeId:s,noteAreaKind:l}=e,i=o==="header"||o==="footer"?d=>A(d,e.origin,{x:r.box.x,y:r.box.y}):void 0;J$1(a,(d,c)=>{let{textboxDepth:y,textboxOwner:S,textboxPath:b,storyOrigin:x}=c,m=y===0?o:"textbox";for(let u of d.lines){let g=[...Q$1(u)].sort((f,E)=>(t.get(f.paragraphId)??Number.MAX_SAFE_INTEGER)-(t.get(E.paragraphId)??Number.MAX_SAFE_INTEGER));for(let f of g)for(let E of f.spans)n({page:r,story:m,rootStory:o,root:e,storyOrigin:x,absoluteBox:Object.freeze({x:x.x+E.box.x,y:x.y+E.box.y,width:E.box.width,height:E.box.height}),noteScopeId:s,noteAreaKind:l,textboxDepth:y,textboxOwner:S,textboxPath:b,paragraph:d,paragraphId:f.paragraphId,line:u,span:E,sourceRange:In(E)});}},e.origin,i);}function Lo(e,t){let n=new Map(W$1(e).map((r,o)=>[r,o]));G$1(e,r=>To(r,n,t));}var Bn="Calibri, Carlito, Helvetica, Arial, sans-serif",Xa=new Map([["calibri","Carlito"]]),Ao=65536,Bo=256;function Tn(e,t){return e===void 0?Math.max(1,Math.floor(t)):Number.isFinite(e)&&e>0?Math.max(1,Math.floor(e)):1}function Ln(e){let t=new Map,n=0;return {get(r){let o=t.get(r);if(o!==void 0)return t.delete(r),t.set(r,o),o},set(r,o){for(t.has(r)&&t.delete(r),t.set(r,o);t.size>e;){let a=t.keys().next();if(a.done)break;t.delete(a.value),n+=1;}},get size(){return t.size},get evictions(){return n}}}var An=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function Pn(e=null){return e!=null&&typeof e.measureText=="function"}function _n(e={}){let t=e.scale??1;if(!(t>0)||!Number.isFinite(t))return null;let n=e.fallbackFamily??Bn,r$1=e.context??null;if(!Pn(r$1))return null;let o=r$1,a=Ln(Tn(e.maxWidthEntries,Ao)),s=Ln(Tn(e.maxMetricsEntries,Bo)),l=e.fontAlias,i=c=>{let y=c.fontFamily&&An.test(c.fontFamily)?c.fontFamily:null,S=y?l?.(y):void 0,b=S&&An.test(S)?S:null,x=y?b?`"${b}", "${y}", ${n}`:`"${y}", ${n}`:n,m=c.bold?"bold":"normal",u=c.italic?"italic":"normal",g=c.smallCaps?"small-caps":"normal",f=c.fontSizePt*(c.verticalAlign==="baseline"?1:.75)*t;return `${u} ${g} ${m} ${f}px ${x}`},d=(c,y,S)=>c/t*(S.horizontalScalePercent/100)+y.length*S.characterSpacingPt;return {measure(c,y){if(c.length===0)return 0;let S=i(y),b=`${S}\0${c}`,x=a.get(b);if(x!==void 0)return d(x,c,y);o.font=S;let m=o.measureText(c).width;return a.set(b,m),d(m,c,y)},inkBounds(c,y){if(!c||c.length>2||y.shaping?.direction==="rtl"||r(c).length!==1)return;o.font=i(y);let S=o.textAlign,b=o.direction,x;try{S!==void 0&&(o.textAlign="left"),b!==void 0&&(o.direction="ltr"),x=o.measureText(c);}finally{S!==void 0&&(o.textAlign=S),b!==void 0&&(o.direction=b);}let m=x.actualBoundingBoxLeft,u=x.actualBoundingBoxRight;if(m===void 0||u===void 0||!Number.isFinite(m)||!Number.isFinite(u))return;let g=y.horizontalScalePercent/(100*t);return {left:-m*g,right:u*g}},lineMetrics(c){let y=c.fontSizePt*(c.verticalAlign==="baseline"?1:.75),S=i(c),b=s.get(S);if(b)return b;let x=y*1.15,m=y*.8;o.font=S;let u=o.measureText("Hxg"),g=u.fontBoundingBoxAscent,f=u.fontBoundingBoxDescent;if(typeof g=="number"&&Number.isFinite(g)&&g>0&&(m=g/t,typeof f=="number"&&Number.isFinite(f)&&f>=0)){let F=(g+f)/t;F>0&&(x=Math.max(F,x));}x>0||(x=y*1.15);let E={height:x,baseline:m};return s.set(S,E),E}}}function Po(e=1,t={}){let n=_n({...t,scale:t.scale??e});return n?{measurer:n,producer:t.fontAlias?"canvas-measurer+embedded":"canvas-measurer"}:{measurer:b(),producer:"fixed-measurer"}}function _o(e){let t;return n=>{t===void 0&&(t=qa(e.pages)?.hosts??null);let r=t?.get(n);return r?oa$1(r.pageNumber,r.format):null}}function Mn(e,t){let n=Ja(e,t.displayMode??ua$1),r=Rb({numberingIndex:t.numberingIndex,styleCascade:t.styleCascade},n).listItems,o=t.package?{footnotesPart:Nf(t.package,"footnote"),endnotesPart:Nf(t.package,"endnote")}:void 0,a=ic(n,r,o,t.package?fc(t.package,e,n):void 0,t.displayMode??ua$1);return {blocks:n,notes:o,context:a}}function zn(e,t,n,r,o){for(let a of t){if(r.length>=gh)return;if(n.tokenForParagraph(a.id)!==""&&jh(e,a.id)===null)for(let s of ih(a)){if(r.length>=gh)return;if(!s.rewritable)continue;let l=ta$1(s.instruction);if(l===null)continue;let i=n.liveValueOf(s.fieldNodeId,l);if(i===null&&o&&n.pageRefProjectionOf){let d=n.pageRefProjectionOf(s.fieldNodeId,l);if(d){let c=o(d.targetParagraphId);c!==null&&c.length>0&&pa$1(d.calibration,d.cached,c,Number.NaN)&&(i=c);}}i===null||i===s.cachedText||i.length>hh||i.includes(`
|
|
2
|
-
`)||i.includes("\r")||r.push({paragraphId:a.id,fieldNodeId:s.fieldNodeId,text:i});}}}function Mo(e,t){let{blocks:n,context:r}=Mn(e,t);if(r===null)return null;let o=[];return zn(e,Pb(n),r,o,t.pageRefPageNumberOf),o.length===0?null:{op:"refreshFieldResults",updates:o}}function ri(e,t){let{notes:n,context:r}=Mn(e,t);if(r===null||n===void 0)return [];let o=[],a=[{noteKind:"footnote",notesPart:n.footnotesPart},{noteKind:"endnote",notesPart:n.endnotesPart}];for(let{noteKind:s,notesPart:l}of a){if(!l)continue;let i=[];for(let d of gc(l,t.displayMode??ua$1)){if(i.length>=gh)break;zn(l,Pb(d),r,i);}i.length>0&&o.push({noteKind:s,op:{op:"refreshFieldResults",updates:i}});}return o}function zo(e){return e.box}function Nn(e,t){if(e.kind==="paragraph"){t.add(e.paragraphId);return}for(let n of e.rows)for(let r of n.cells)for(let o of r.blocks)Nn(o,t);}function No(e){let t=new Map,n=(o,a,s)=>{if(!(o.kind==="textValue"||s>wc*4)){for(let l of o.children)if(l.kind!=="textValue"){if(l.kind==="paragraph"){for(let i of r)t.get(i)?.push(l.id);n(l,l.id,s+1);continue}if(l.kind==="contentControl"){t.set(l.id,[]),r.push(l.id);let i=Gc(l);i&&n(i,a,s+1),r.pop();let d=t.get(l.id);d&&d.length===0&&a!==null&&d.push(a);continue}n(l,a,s+1);}}},r=[];return n(e,null,0),t}function ko(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return {x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function Do(e,t){let n=Kc(e.root);if(n.length===0)return Ho;let r=new Map;t.pages.forEach((s,l)=>{(d=>{for(let c of d){let y=new Set;Nn(c,y);for(let S of y){let b=r.get(S)??[];b.push({pageIndex:l,box:zo(c)}),r.set(S,b);}}})(s.fragments);});let o=No(e.root),a=[];for(let s of n){let l=Ic(s.node),i=[...s.ancestors.map(S=>Ic(S).lock),l.lock],d=o.get(s.node.id)??[],c=new Map;for(let S of d)for(let b of r.get(S)??[]){let x=c.get(b.pageIndex);c.set(b.pageIndex,x?ko(x,b.box):b.box);}let y=[...c.entries()].sort((S,b)=>S[0]-b[0]).map(([S,b])=>({pageIndex:S,...b}));a.push({controlId:s.node.id,type:l.type,level:Jc(s.node),depth:s.depth,lock:l.lock,effectiveLock:Nc(i),showingPlaceholder:l.showingPlaceholder,temporary:l.temporary,...l.tag===void 0?{}:{tag:l.tag},...l.alias===void 0?{}:{alias:l.alias},...l.id===void 0?{}:{id:l.id},...l.dataBinding===void 0?{}:{dataBinding:l.dataBinding},paragraphIds:d,fragments:y});}return a}var Ho=Object.freeze([]);function Dn(e,t,n){let r=e.lines?.find(o=>{let a=o.spans;if(!a)return n<o.range.end;let s=a.filter(l=>l.range.paragraphId===t);return s.length===a.length?n<o.range.end:s.length>0&&n<s[s.length-1].range.end});return r?r.box.y:e.fragmentY}function Zo(e,t){let n=new Map;for(let r of e.pages)for(let[o,a]of Jo(r,t))n.has(o)||n.set(o,a);return n}var kn=new WeakMap;function Jo(e,t){let n=kn.get(t);n||(n=new WeakMap,kn.set(t,n));let r=n.get(e);if(r)return r;let o=new Map;for(let a of t(e)){let s=new Set([a.paragraphId]);for(let l of a.lines??[])for(let i of l.spans??[])s.add(i.range.paragraphId);for(let l of s)o.has(l)||o.set(l,{pageIndex:e.index,contentY:e.contentBox.y,fragmentY:a.box.y,...a.lines?{lines:a.lines}:{}});}return n.set(e,o),o}function Qo(e,t){let n=Ha(e);if(!n)return null;let r=t.get(n.start.paragraphId);return r?{pageIndex:r.pageIndex,y:r.contentY+Dn(r,n.start.paragraphId,n.start.offset)}:null}var pt=new WeakMap;function ea(e){let t=pt.get(e);if(t!==void 0)return t??void 0;let n=e.path;if(!n.startsWith("M")||n.length>1e6||/[^MLQCZ0-9eE+.,\s-]/u.test(n))return;let r=1/0,o=-1/0,a=n.matchAll(/([MLQCZ])([^MLQCZ]*)/gu);for(let l of a){let i=l[1]==="Z"?0:l[1]==="C"?6:l[1]==="Q"?4:2,d=l[2].trim().split(/[\s,]+/u).filter(Boolean).map(Number);if(d.length!==i||d.some(c=>!Number.isFinite(c))){pt.set(e,null);return}for(let c=0;c<d.length;c+=2)r=Math.min(r,d[c]),o=Math.max(o,d[c]);}let s=Number.isFinite(r)&&Number.isFinite(o)?{left:r,right:o}:void 0;return pt.set(e,s??null),s}function Hn(e,t,n,r){if(e.clusters.length!==1||e.glyphs.length===0)return;let o=1/0,a=-1/0;for(let l of e.glyphs){if(l.id===0)return;let i=ea(l.outline),d=l.outline.unitsPerEm;if(!i||!(d>0))return;let c=(l.originX+l.offsetX)/n;o=Math.min(o,c+i.left*t/d),a=Math.max(a,c+i.right*t/d);}let s={left:o*r,right:a*r};return Number.isFinite(s.left)&&Number.isFinite(s.right)?s:void 0}var ta="abcdefghijklmnopqrstuvwxyz";function pe(e){let t=Math.round(e.fontSizePt*2);return Math.max(1,t)}function J(e,t,n,r,o){return e.shape({text:o,fontSizeHalfPoints:pe(r),bidiLevel:r.shaping?.direction==="rtl"?1:0,environment:Y({...t,font:n,direction:r.shaping?.direction??"ltr",script:r.shaping?.script==="Zyyy"?t.script:r.shaping?.script??t.script,features:r.smallCaps?{...t.features,smcp:1}:t.features,fallbackOrder:[]})})}function _e(e,t,n,r,o){let a=o.get(n);if(a!==void 0)return a;let s=true;try{for(let l of ta){let i=J(e,t,n,{...r,smallCaps:!0},l),d=J(e,t,n,{...r,smallCaps:!1},l);if(!(i.glyphs.length!==d.glyphs.length||i.glyphs.some((y,S)=>y.id!==d.glyphs[S]?.id))){s=!1;break}}}catch{s=false;}return o.set(n,s),s}var na=.5,ra=4,Gn=4096,ye=e=>e.verticalAlign==="baseline"?1:.75;function Un(e){let t="environment"in e?e.environment:void 0,n="environment"in e?void 0:e,{shaper:r$1,resolveFont:o,fallback:a}=e,s=t??{shapingLibrary:n.shapingLibrary,unicodeDataVersion:n.unicodeDataVersion,script:n?.script??"Latn",fixedPointScale:n?.fixedPointScale??1e3,normalization:n?.normalization??"none",features:n?.features??{},roundingMode:n?.roundingMode??"halfToEven",language:n?.language??"en",variationAxes:{}},l=new WeakMap,i=new WeakMap,d=new WeakMap,c=new WeakMap,y=new WeakMap,S=new Array(Gn),b=0,x=(h,p,v)=>{let R=S[b];R&&R.cache.delete(R.text),h.set(p,v),S[b]={cache:h,text:p},b=(b+1)%Gn;},m=h=>{let p=c.get(h);if(p!==void 0)return p;let v=o(h);return c.set(h,v),v},u=(h,p,v)=>{let R=v?i:l,C=R.get(h);C||(C=new Map,R.set(h,C));let O=C.get(p);return O||(O=new Map,C.set(p,O)),O},g=new WeakMap,f=h=>{if(!h.shaping?.wordSpacingPt)return h;let p=g.get(h);return p||(p={...h,shaping:{...h.shaping,wordSpacingPt:void 0}},g.set(h,p)),p},E=(h,p)=>p.shaping?.wordSpacingPt?Pc(h)*p.shaping.wordSpacingPt:0,F=(h,p)=>a.measure(h,f(p))+E(h,p),T=(h,p)=>{let v=Math.max(0,a.measure(h,f(p))),R=a.caretAdvances?.(h,f(p))??Nc$1(h,v);if(!R||R.length!==h.length+1)return Nc$1(h,F(h,p));let C=Math.max(0,F(h,p)),O=0,I=0;return R.map((L,A)=>{if(A===0)return 0;h[A-1]===" "&&I++;let k=L+I*(p.shaping?.wordSpacingPt??0);return O=Math.max(O,Math.min(C,Number.isFinite(k)?k:O)),A===h.length?C:O})};return {measure(h,p){if(h.length===0)return 0;let v=m(p);if(!v)return F(h,p);let R=u(v,pe(p),p.smallCaps),C=p.shaping?`1:${JSON.stringify([p.shaping.script,p.shaping.direction,h])}`:`0:${h}`,O=R.get(C);if(O===void 0){let I=0;try{if(p.smallCaps&&!_e(r$1,s,v,p,y))return F(h,p);let L=J(r$1,s,v,p,h);if(L.glyphs.some(A=>A.id===0))return F(h,p);for(let A of L.glyphs)I+=A.advanceX;}catch{return F(h,p)}O=I/s.fixedPointScale,x(R,C,O);}return O*ye(p)*(p.horizontalScalePercent/100)+h.length*p.characterSpacingPt+E(h,p)},inkBounds(h,p){if(!h||h.length>2||p.shaping?.direction==="rtl"||r(h).length!==1)return;let v=m(p);if(!v)return a.inkBounds?.(h,p);try{if(p.smallCaps&&!_e(r$1,s,v,p,y))return a.inkBounds?.(h,p);let R=J(r$1,s,v,p,h);return Hn(R,pe(p)/2,s.fixedPointScale,ye(p)*p.horizontalScalePercent/100)}catch{return}},caretAdvances(h,p){let v=m(p);if(!v)return T(h,p);try{if(p.smallCaps&&!_e(r$1,s,v,p,y))return T(h,p);let R=J(r$1,s,v,p,h);return R.glyphs.some(C=>C.id===0)?T(h,p):Oc(h,R,ye(p)*(p.horizontalScalePercent/100)/s.fixedPointScale,p.characterSpacingPt,p.shaping?.wordSpacingPt??0)??Nc$1(h,R.glyphs.reduce((C,O)=>C+O.advanceX,0)*ye(p)*(p.horizontalScalePercent/100)/s.fixedPointScale+h.length*p.characterSpacingPt+E(h,p))}catch{return T(h,p)}},lineMetrics(h){let p=m(h);if(!p)return a.lineMetrics(h);let v=ye(h),R=d.get(p);R||(R=new Map,d.set(p,R));let C=pe(h),O=R.get(C);if(O)return v===1?O:{height:O.height*v,baseline:O.baseline*v};let I,L=true,A=p.substitution?.lineMetrics;if(A){let k=C/2;I={height:A.heightEm*k,baseline:A.baselineEm*k};}else try{let k=J(r$1,s,p,h," "),ft=k.metrics.ascent/s.fixedPointScale,Yn=k.metrics.descent/s.fixedPointScale,$n=C/2,ze=ft+Yn,ht=$n*ra,mt=ze>ht?ht/ze:1,gt=ze*mt,Zn=Math.min(Math.max(0,k.metrics.lineGap/s.fixedPointScale),gt*na),bt=gt+Zn;bt>0?I={height:bt,baseline:ft*mt}:(I=a.lineMetrics(h),L=!1);}catch{I=a.lineMetrics(h),L=false;}return L?(R.set(C,I),v===1?I:{height:I.height*v,baseline:I.baseline*v}):I}}}function oa(e,t){return Un({...t,shaper:e.shaper,environment:e.environment})}function aa(e){let{layout:t,viewport:n}=e,r=new Set;if(!n){for(let i of t.pages)r.add(i.index);return r}let o=Math.max(0,Math.trunc(e.overscanPages??1)),a=n.top+n.height,s=-1,l=-1;for(let i of t.pages){let d=i.box.y;d+i.box.height>=n.top&&d<=a&&(s===-1&&(s=i.index),l=i.index);}if(s===-1){let i=ia(t,n.top);i!==null&&(s=i,l=i);}if(s!==-1){let i=Math.max(0,s-o),d=Math.min(t.pages.length-1,l+o);for(let c=i;c<=d;c+=1)r.add(c);}for(let i of e.pinnedPages??[])i>=0&&i<t.pages.length&&r.add(i);return r}function ia(e,t){let n=null,r=Number.POSITIVE_INFINITY;for(let o of e.pages){let a=t<o.box.y?o.box.y-t:t>o.box.y+o.box.height?t-(o.box.y+o.box.height):0;a<r&&(r=a,n=o.index);}return n}var jn=["text-local","paragraph-local","flow-structural","global"];function Vn(e,t){return jn.indexOf(t)>jn.indexOf(e)?t:e}function sa(e){return {impact:"text-local",paragraphIds:new Set,created:new Set,deleted:new Set,dependencyKeys:new Set,structural:false,revision:e}}function la(e){let{run:t,currentRevision:n,publish:r,schedule:o}=e,a=null,s=null,l=null,i=0,d=0;function c(u){let g=e.runCooperatively;if(!g)return t(u);let f=g(u);l=f;try{for(;;){let E=f.step();if(E)return E;if(n()!==u.revision)return f.cancel(),d+=1,null;if(l!==f)return null}}finally{l===f&&(l=null);}}function y(u){let g=b(n());g.impact=Vn(g.impact,u.impact),g.structural=g.structural||u.structural;for(let f of u.paragraphIds)g.paragraphIds.add(f);for(let f of u.created)g.created.add(f);for(let f of u.deleted)g.deleted.add(f);for(let f of u.dependencyKeys)g.dependencyKeys.add(f);}let S=u=>({impact:u.impact,paragraphIds:u.paragraphIds,created:u.created,deleted:u.deleted,dependencyKeys:u.dependencyKeys,structural:u.structural,revision:u.revision});function b(u){return a||(a=sa(u)),a.revision=Math.max(a.revision,u),a}function x(){!o||s||(s=o(()=>{s=null,m();}));}function m(){s&&(s(),s=null),l&&(l.cancel(),l=null,d+=1);let u=a;if(!u)return false;a=null;let g=S(u),f=c(g);return !f||f.revision!==n()?(i+=1,y(g),x(),false):(r(f,g),true)}return {notify(u){let g=b(n());g.impact=Vn(g.impact,u.impact);for(let f of u.dirty)g.paragraphIds.add(f);for(let f of u.created)g.created.add(f),g.paragraphIds.add(f);for(let f of u.deleted)g.deleted.add(f),g.paragraphIds.add(f);for(let f of u.dependencyKeys)g.dependencyKeys.add(f);for(let f of u.splitJoin)g.structural=true,"split"in f?(g.paragraphIds.add(f.split.from),g.paragraphIds.add(f.split.tail)):(g.paragraphIds.add(f.join.kept),g.paragraphIds.add(f.join.removed));(u.impact==="flow-structural"||u.impact==="global")&&(g.structural=true),x();},invalidateAll(u,g){let f=b(u);f.impact="flow-structural",f.structural=true,g&&f.dependencyKeys.add(g),x();},flush:m,pending:()=>a?S(a):null,cancel(){s?.(),s=null,l?.cancel(),l=null,a=null;},get staleDiscards(){return i},get cancelledRuns(){return d}}}var Wn=new WeakMap;function U(e){let t=Wn.get(e);if(t)return t;let n=new Map,r=new Map,o=new Map,a=new Map,s=(i,d,c,y)=>{for(let S of i){if(S.kind==="paragraph")continue;let b=S.tableId;a.set(b,Math.max(a.get(b)??0,(S.columnEdges?.length??1)-1));let x=o.get(b);x||(x=new Map,o.set(b,x),n.set(b,[]),r.set(b,new Map));for(let m of S.rows){let u=x.get(m.id);u===void 0&&(u=x.size,x.set(m.id,u),r.get(b).set(u,m.cells));for(let g of m.cells)n.get(b).push({pageIndex:d,tableId:b,row:m,cell:g,rowIndex:u,isHeaderRepeat:m.isHeaderRepeat,offsetX:c,offsetY:y}),s(g.blocks,d,c,y);}}};for(let i of e.pages){s(i.fragments,i.index,0,0);for(let d of [i.header,i.footer])d&&s(d.fragments,i.index,d.box.x-i.contentBox.x,d.box.y-i.contentBox.y);for(let d of [i.footnotes,i.endnotes])if(d)for(let c of d.notes)s(c.fragments,i.index,c.box.x-i.contentBox.x,c.box.y-i.contentBox.y);}let l=new Map;for(let[i,d]of n)l.set(i,{placed:d,rows:r.get(i)??new Map,columnCount:a.get(i)??0});return Wn.set(e,l),l}function Xn(e){let t=e.columnCount;for(let n of e.rows.values())for(let r of n)t=Math.max(t,X(r).to+1);return t}var X=e=>({from:e.gridColumn,to:e.gridColumn+Math.max(1,e.gridSpan)-1});function da(e,t,n){if(t.tableId!==n.tableId)return null;let r=U(e).get(t.tableId);if(!r)return null;let o=Math.min(t.rowIndex,n.rowIndex),a=Math.max(t.rowIndex,n.rowIndex),s=Math.min(X(t).from,X(n).from),l=Math.max(X(t).to,X(n).to),i=b=>{let{from:x,to:m}=X(b);return m>=s&&x<=l},d=b=>(r.rows.get(b)??[]).some(x=>x.vMergeContinue&&i(x)),c=r.rows.size+Xn(r)+2;for(let b=0;!(b>c);b+=1){let x=false;for(let[m,u]of r.rows)if(!(m<o||m>a))for(let g of u){if(!i(g))continue;let{from:f,to:E}=X(g);f<s&&(s=f,x=true),E>l&&(l=E,x=true);}for(;o>0&&d(o);)o-=1,x=true;for(;d(a+1);)a+=1,x=true;if(!x)break}let y=[],S=new Set;for(let b of r.placed){if(b.isHeaderRepeat||b.rowIndex<o||b.rowIndex>a)continue;let{from:x,to:m}=X(b.cell);m<s||x>l||S.has(b.cell.id)||(S.add(b.cell.id),y.push(b.cell.id));}return y.length===0?null:{kind:"cells",tableId:t.tableId,cellIds:y,rows:{from:o,to:a},columns:{from:s,to:l},text:ca(e,t.tableId,y)}}function wi(e,t){return qn(e,t,true)}function Me(e,t){return qn(e,t,false)}function qn(e,t,n){let r=new Set(t),o=[],a=new Set;for(let s of U(e).values())for(let l of s.placed)if(!(l.isHeaderRepeat||!r.has(l.cell.id)))for(let i of l.cell.blocks)n&&i.kind!=="paragraph"||ie(i,o,a);return o}function ie(e,t,n){if(e.kind==="paragraph"){for(let r of T(e))n.has(r)||(n.add(r),t.push(r));return}for(let r of e.rows)if(!r.isHeaderRepeat)for(let o of r.cells)for(let a of o.blocks)ie(a,t,n);}function ca(e,t,n){let r=Me(e,n),o=r[0],a=r[r.length-1];return !o||!a?ua(e,t):{anchor:{paragraphId:o,offset:0},head:{paragraphId:a,offset:je(e,a).length}}}function ua(e,t){let n=U(e).get(t);for(let o of n?.placed??[]){if(o.isHeaderRepeat)continue;let a=[];for(let l of o.cell.blocks)ie(l,a,new Set);let s=a[0];if(s){let l={paragraphId:s,offset:0};return {anchor:l,head:l}}}for(let o of e.pages)for(let a of B$1(o)){let s={paragraphId:a.paragraphId,offset:0};return {anchor:s,head:s}}let r={paragraphId:"",offset:0};return {anchor:r,head:r}}function pa(e){let t=[...B$1(e)];for(let n of [e.header,e.footer])n&&t.push(...C(n.fragments));for(let n of [e.footnotes,e.endnotes])if(n)for(let r of n.notes)t.push(...C(r.fragments));return t}function ya(e,t){let n=new Set(Me(e,t)),r=[],o=new Set;for(let a of e.pages)for(let s of pa(a))if(n.has(s.paragraphId))for(let l of s.lines)for(let i of l.spans){let d=`${i.range.paragraphId}:${i.range.start}:${i.range.end}`;o.has(d)||(o.add(d),r.push(i));}return r}function fa(e,t){let n=new Set(t),r=[];for(let o of U(e).values())for(let a of o.placed)n.has(a.cell.id)&&r.push({pageIndex:a.pageIndex,x:a.cell.box.x+a.offsetX,y:a.cell.box.y+a.offsetY,width:a.cell.box.width,height:a.cell.box.height});return r}function ha(e,t){let n=U(e).get(t.tableId);if(!n)return "";let r=new Set(t.cellIds),o=n.placed.some(l=>l.cell.logicalGridColumn!==void 0),a=new Map,s=new Set;for(let l of n.placed){if(l.isHeaderRepeat||!r.has(l.cell.id)||s.has(l.cell.id))continue;s.add(l.cell.id);let i=Me(e,[l.cell.id]).map(y=>je(e,y)).join(`
|
|
3
|
-
`),d=a.get(l.rowIndex),c=l.cell.gridColumn+(o?Math.max(1,l.cell.gridSpan)-1:0);d?d.set(c,i):a.set(l.rowIndex,new Map([[c,i]]));}return [...a.keys()].sort((l,i)=>l-i).map(l=>{let i=a.get(l),d=[];for(let c=0;c<=t.columns.to-t.columns.from;c+=1){let y=o?t.columns.to-c:t.columns.from+c;d.push(i.get(y)??"");}return d.join(" ")}).join(`
|
|
4
|
-
`)}function yt(e,t){let n=null,r=-1;for(let[o,a]of U(e))for(let s of a.placed){if(s.isHeaderRepeat)continue;let l=[];for(let d of s.cell.blocks)ie(d,l,new Set);if(!l.includes(t))continue;let i=o.length;i<=r||(r=i,n={tableId:o,rows:a.rows.size,columns:Xn(a),rowIndex:s.rowIndex,columnIndex:s.cell.logicalGridColumn??s.cell.gridColumn});}return n}function Oi(e,t,n){if(n){let a=yt(e,t);if(!a||a.tableId!==n.tableId)return null;let s=n.cellIds[0];if(!s)return null;let l=U(e).get(n.tableId);if(!l)return null;for(let i of l.placed)if(i.cell.id===s)return {tableId:n.tableId,rowId:i.row.id,cellId:s,cellIds:n.cellIds,gridColumnIndex:i.cell.logicalGridColumn??i.cell.gridColumn,isHeaderRepeat:i.isHeaderRepeat};return null}let r=yt(e,t);if(!r)return null;let o=U(e).get(r.tableId);if(!o)return null;for(let a of o.placed){if(a.isHeaderRepeat)continue;let s=[];for(let l of a.cell.blocks)ie(l,s,new Set);if(s.includes(t))return {tableId:r.tableId,rowId:a.row.id,cellId:a.cell.id,cellIds:[a.cell.id],gridColumnIndex:a.cell.logicalGridColumn??a.cell.gridColumn,isHeaderRepeat:a.row.isHeaderRepeat}}return null}var Kn=new WeakMap;function Ii(e,t){let n=Kn.get(e);if(n)return n.get(t)??null;let r=new Map;for(let[o,a]of U(e))for(let s of a.placed){if(s.isHeaderRepeat)continue;let l=[];for(let d of s.cell.blocks)ie(d,l,new Set);let i={tableId:o,rowId:s.row.id,cellId:s.cell.id,rowIndex:s.rowIndex,gridColumn:s.cell.gridColumn,gridSpan:s.cell.gridSpan};for(let d of l){let c=r.get(d);c&&c.tableId.length>=o.length||r.set(d,i);}}return Kn.set(e,r),r.get(t)??null}export{Bn as $,lo as A,La as B,at as C,Aa as D,co as E,po as F,Ba as G,yo as H,it as I,Be as J,fo as K,ho as L,mo as M,lt as N,xn as O,Rn as P,Fn as Q,vn as R,En as S,Cn as T,xo as U,Ro as V,ae as W,Eo as X,ct as Y,In as Z,Lo as _,ee as a,Xa as aa,D as b,Pn as ba,V as c,_n as ca,j as d,Po as da,te as e,_o as ea,Kt as f,Mo as fa,W as g,ri as ga,Ee as h,Do as ha,we as i,Dn as ia,Ye as j,Zo as ja,M as k,Qo as ka,Y as l,J as la,nn as m,_e as ma,Qe as n,Un as na,Le as o,oa,sr as p,aa as pa,$ as q,la as qa,tt as r,da as ra,lr as s,wi as sa,w as t,Me as ta,nt as u,ya as ua,on as v,fa as va,ot as w,ha as wa,dn as x,yt as xa,G as y,Oi as ya,so as z,Ii as za};
|
package/dist/chunk-GUPITGJQ.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkZKQX2PNF_cjs=require('./chunk-ZKQX2PNF.cjs'),chunkLQ6XWTKQ_cjs=require('./chunk-LQ6XWTKQ.cjs'),chunkYVYEJBLL_cjs=require('./chunk-YVYEJBLL.cjs'),chunkMDP5SNK4_cjs=require('./chunk-MDP5SNK4.cjs'),chunk77DD4EBC_cjs=require('./chunk-77DD4EBC.cjs');function ta(t){let e=[];for(let n of t.pages){let r=n.pageFieldSource?.pageNumber??n.index+1,i=chunkLQ6XWTKQ_cjs.oa(r,n.pageFieldSource?.format),s=d=>{for(let p of d)if(p.kind==="paragraph")for(let u of p.lines)e.push({...u.range,pageNumber:r,pageNumberText:i});else for(let u of p.rows)for(let m of u.cells)s(m.blocks);};s(n.fragments),n.header&&s(n.header.fragments),n.footer&&s(n.footer.fragments);for(let d of n.footnotes?.notes??[])s(d.fragments);for(let d of n.endnotes?.notes??[])s(d.fragments);}return {pageCount:t.pages.length,ranges:e}}function mi(t,e,n,r){if(!t||!Number.isInteger(t.pageCount)||t.pageCount<1)return null;let i=chunk77DD4EBC_cjs.Ga(e,n);if(!i||i.kind!=="paragraph")return null;let s=chunk77DD4EBC_cjs.Ne(i).find(p=>p.node.id===r);if(!s)return null;let d=t.ranges.find(p=>p.paragraphId===n&&p.start<=s.start&&p.end>s.start);return !d||!Number.isInteger(d.pageNumber)||d.pageNumber<1?null:{pageNumber:d.pageNumber,pageNumberText:d.pageNumberText,pageCount:t.pageCount}}function fi(t){return async e=>{let n=chunkZKQX2PNF_cjs.e(e,{measurer:t.measurer,producer:t.producer,displayMode:"proposed"});if(!n.ok)throw new Error("field pagination could not open the document");try{return ta(await n.session.layout())}finally{n.session.dispose();}}}var Se=Object.freeze(["default","first","even"]),Ft=Object.freeze({kind:"body"});function J(t){switch(t.kind){case "body":return "body";case "note":return `note:${t.noteKind}:${String(t.noteId)}`;default:return `${t.kind}:${String(t.sectionIndex)}:${t.variant}`}}function Io(t){if(typeof t!="object"||t===null)return false;let e=t;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&&Se.includes(e.variant)}var hi=["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","getFields","getField","getInlinePictures","getInlinePicture","getChangeTrackingMode","getDocument","getBody","getParagraphs","getRange","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"],ea=["insertTable","updateTable","updateTableCell","setInlinePicture","deleteInlinePicture","insertField","setFieldCode","deleteField","updateFieldResult","insertInlinePicture","insertBreak","setChangeTrackingMode","proposeInsertion","proposeDeletion","proposeReplacement","insertText","replaceSpan","replaceStoryBlocks","insertParagraph","splitParagraph","deleteParagraph","selectSpan","selectBookmark","setFont","setParagraphFormat","setStyle","setPageSetup","deleteNote","setListLevel","startNewList","attachToList","detachFromList","setListLevelFormat","insertListParagraph","setHyperlink","insertComment","setCommentResolved","replyToComment","deleteComment","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","setContentControlValue","setContentControlProperties","deleteContentControl","insertContentControlText","insertContentControl","insertCustomNode"],na=["insertTable","insertInlinePicture","insertBreak","startNewList","deleteNote","insertComment","setCommentResolved","replyToComment","insertCustomNode"],oa=new Set(na);function nn(t){return oa.has(t.op)||t.op==="updateTable"&&["addRows","addColumns","deleteRows","deleteColumns","delete"].includes(t.mutation.kind)}var ra=new Set(ea);function Wt(t){return ra.has(t.op)}var aa=63360;function Tt(t){return Math.round(chunk77DD4EBC_cjs.Ze(chunk77DD4EBC_cjs.Xe(t))*100)/100}function ia(t,e){if(typeof t!="number"||!Number.isFinite(t))return null;let n=chunk77DD4EBC_cjs._e(chunk77DD4EBC_cjs.Ye(t));return n>aa||n<0||n===0&&!e?null:n}var sa=[["pageWidth","pageWidthTwips",false],["pageHeight","pageHeightTwips",false],["topMargin","marginTopTwips",true],["rightMargin","marginRightTwips",true],["bottomMargin","marginBottomTwips",true],["leftMargin","marginLeftTwips",true]];function Po(t){if(typeof t!="object"||t===null)return {ok:false,reason:"that is not a page setup",detail:"not-an-object"};let e=t,n={},r=0;for(let[s,d,p]of sa){let u=e[s];if(u===void 0)continue;let m=ia(u,p);if(m===null)return {ok:false,reason:`that is not a value for ${s}`,detail:String(u)};n[d]=m,r+=1;}let i=e.orientation;if(i!==void 0){if(i!=="portrait"&&i!=="landscape")return {ok:false,reason:"that is not an orientation",detail:String(i)};n.orientation=i,r+=1;}return r===0?{ok:false,reason:"that page setup names nothing to write",detail:"empty"}:{ok:true,value:n}}function la(t){let e=chunk77DD4EBC_cjs.Ch(t),n=e.widthTwips>e.heightTwips?"landscape":"portrait";return Object.freeze({pageWidth:Tt(e.widthTwips),pageHeight:Tt(e.heightTwips),orientation:n,topMargin:Tt(e.topTwips),rightMargin:Tt(e.rightTwips),bottomMargin:Tt(e.bottomTwips),leftMargin:Tt(e.leftTwips),headerDistance:Tt(e.headerTwips),footerDistance:Tt(e.footerTwips),gutter:Tt(e.gutterTwips)})}function da(t,e){if(!e)return null;let n=null,r=(i,s,d)=>{if(n!==null||i.kind==="textValue"||d>64)return;let p=i.kind==="paragraph"?i.id:s;if(i.id===e.id){n=p;return}for(let u of i.children)r(u,p,d+1);};return r(t.root,null,0),n}function Oo(t,e,n){let r=chunk77DD4EBC_cjs.Md(e.root);return Object.freeze(r.map((i,s)=>{let d=n[s];return Object.freeze({index:s,markParagraphId:da(e,i),pageSetup:la(i),titlePage:d?.titlePage??false,evenAndOddHeaders:d?.evenAndOddHeaders??false})}))}var ua=255,ca=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false});function Ro(t){let e=chunk77DD4EBC_cjs.if(t);if(!e)return ca;let n=new Map,r=new Map,i=null;for(let s of chunk77DD4EBC_cjs.hf(e).values())if(s.type==="paragraph"){if(n.set(s.styleId,s.name),s.name!==null){let d=s.name.trim().toLowerCase();r.has(d)||r.set(d,s.styleId);}s.isDefault&&i===null&&(i=s.styleId);}return Object.freeze({nameOf:s=>n.get(s)??null,idOf:s=>r.get(s.trim().toLowerCase())??null,defaultId:i,present:true})}function Ce(t,e,n){let r=chunk77DD4EBC_cjs.Ga(t,e);if(!r||r.kind!=="paragraph")return null;let i=pa(chunk77DD4EBC_cjs.Le(chunk77DD4EBC_cjs.Je(r),"pStyle"));return i!==null?n.nameOf(i):n.defaultId===null?null:n.nameOf(n.defaultId)}function pa(t){if(!t)return null;for(let e of t.attributes)if(e.localName==="val")return e.value;return null}function we(t,e){if(typeof t!="string"||t.trim().length===0)return {ok:false,detail:"style: not a name"};if(t.length>ua)return {ok:false,detail:"style: name too long"};if(!chunk77DD4EBC_cjs.O(t))return {ok:false,detail:"style: not valid XML text"};if(!e.present)return {ok:false,detail:"style: this document defines no styles"};let n=e.idOf(t);return n===null?{ok:false,detail:"style: this document defines no paragraph style with that name"}:{ok:true,styleId:n}}function So(t,e,n){return e>=n?null:{text:t.text.slice(e-t.rawStart,n-t.rawStart),rawStart:e,rawEnd:n}}function ma(t,e){let n=[],r=0;for(let i of t){for(;r<e.length&&e[r].end<=i.rawStart;)r+=1;let s=i.rawEnd-i.rawStart;if(i.text.length!==s){let u=e[r];(!u||u.start>=i.rawEnd)&&n.push(i);continue}let d=i.rawStart;for(;r<e.length;){let u=e[r];if(u.end<=d){r+=1;continue}if(u.start>=i.rawEnd)break;let m=So(i,d,Math.min(u.start,i.rawEnd));if(m&&n.push(m),d=Math.max(d,u.end),u.end<=i.rawEnd&&(r+=1),d>=i.rawEnd)break}let p=So(i,d,i.rawEnd);p&&n.push(p);}return n}function Te(t,e,n){if(n==="model")return chunkYVYEJBLL_cjs.b(e);let r=chunkYVYEJBLL_cjs.c(t,e,n);if(n==="allMarkup")return chunkYVYEJBLL_cjs.a(r);let i=fa(t);if(i.length===0)return chunkYVYEJBLL_cjs.a(r);let s=ma(r,i);return chunkYVYEJBLL_cjs.a(s)}function fa(t){let e=chunk77DD4EBC_cjs.Pe(t),n=[],r=(s,d)=>{if(!(d>64||s.kind==="textValue")){if(s.kind==="revisionInsert"||s.kind==="revisionMoveTo"){let p=e.spanOf(s);p&&p.end>p.start&&n.push({start:p.start,end:p.end});return}for(let p of s.children)r(p,d+1);}};r(t,0),n.sort((s,d)=>s.start-d.start||d.end-s.end);let i=[];for(let s of n){let d=i[i.length-1];d&&s.start<=d.end?d.end=Math.max(d.end,s.end):i.push({...s});}return i}var on="\r",ga=Object.freeze({nameOf:()=>null,idOf:()=>null,defaultId:null,present:false}),ya=Object.freeze([]),ha=Object.freeze([]),Co=Object.freeze([]),ka=Object.freeze({package:null,body:null,story:()=>null,storyOf:()=>null,sections:()=>ha,furniture:()=>Co,noteIds:()=>({ok:true,ids:wo}),styles:()=>ga});function ba(t){return t.kind==="textValue"?ya:Object.freeze(t.children.filter(e=>e.kind!=="textValue").map(e=>{let n=[];chunk77DD4EBC_cjs.Bd([e],n,0);let r=e.kind==="paragraph"?"paragraph":e.kind==="table"?"table":"other",i=e.kind==="paragraph"&&chunk77DD4EBC_cjs.Le(chunk77DD4EBC_cjs.Je(e),"sectPr")!==void 0;return Object.freeze({id:e.id,kind:r,paragraphIds:Object.freeze(n.map(s=>s.id)),removable:r!=="other"&&!i})}))}function Ne(t,e,n,r,i){let s=chunk77DD4EBC_cjs.Ad(r),d=Object.freeze(s.map(k=>k.id)),p=new Map,u=new Map;s.forEach((k,b)=>{p.set(k.id,b),u.set(k.id,k);});let m=new Map,A=k=>{if(!p.has(k))return null;let b=m.get(k);if(b!==void 0)return b;let v=chunk77DD4EBC_cjs.gi(e,k)??"";return m.set(k,v),v},g=new Map,x=(k,b="allMarkup")=>{let v=u.get(k);if(!v||v.kind!=="paragraph")return null;let S=`${k}:${b}`,w=g.get(S);if(w)return w;let H=Te(v,A(k)??"",b);return g.set(S,H),H};return {story:t,part:e,root:r,scope:n,paragraphIds:d,blocks:ba(r),has:k=>p.has(k),indexOf:k=>p.get(k)??-1,paragraph(k){let b=u.get(k);return b?{nodeId:k,paraId:chunk77DD4EBC_cjs.Eb(b),text:x(k)?.text??""}:null},node:k=>u.get(k)??null,rawText:A,paragraphText:(k,b)=>x(k,b)?.text??null,projectedText:x,text:k=>d.map(b=>x(b,k)?.text??"").join(on),styles:i}}function Ee(t,e){let n=Ne(t.story,t.part,t.scope,e,t.styles);return {...n,indexOf:r=>n.has(r)?t.indexOf(r):-1}}function de(t){let e=t.parts.get(t.mainDocumentPart);if(!e)return ka;let n,r=()=>n??=Ro(t),i,s=()=>i??=chunk77DD4EBC_cjs.Od(t),d,p=new Map,u=new Map,m=b=>{let v=u.get(b);if(v)return v;let S=chunk77DD4EBC_cjs.Nf(t,b);if(!S){let C={ok:true,ids:wo};return u.set(b,C),C}let w=[],H=new Set,E=new Set,j=0,F=false;for(let C of S.root.children){if(chunk77DD4EBC_cjs.gd(C)!==b)continue;if(j+=1,C.kind!=="note"){F=true;continue}if(!chunk77DD4EBC_cjs.jd(C))continue;let D=chunk77DD4EBC_cjs.hd(C);if(D===null){F=true;continue}H.has(D)?E.add(D):(H.add(D),w.push(D));}let K=j>chunk77DD4EBC_cjs.qd?{ok:false,reason:"truncated"}:F?{ok:false,reason:"malformed"}:E.size>0?{ok:false,reason:"duplicates",duplicateIds:Object.freeze([...E])}:{ok:true,ids:Object.freeze(w)};return u.set(b,K),K},A=b=>{let v=s()[b.sectionIndex];return v?(b.kind==="header"?v.headers:v.footers).get(b.variant)??null:null},g=b=>{if(b.kind==="body"){let S=chunk77DD4EBC_cjs.zd(e);return S?Ne(b,e,{kind:"body"},S,r):null}if(b.kind==="note"){let S=m(b.noteKind);if(!S.ok||!S.ids.includes(b.noteId))return null;let w=chunk77DD4EBC_cjs.Nf(t,b.noteKind);if(!w)return null;let H=chunk77DD4EBC_cjs.ud(w.root,b.noteId);return !H||!chunk77DD4EBC_cjs.jd(H)?null:Ne(b,w,{kind:"notesPart",noteKind:b.noteKind},H,r)}let v=A(b);return v?Ne(b,v.part,{kind:"headerFooter",rId:v.rId},v.part.root,r):null},x=b=>{let v=J(b);if(p.has(v))return p.get(v)??null;let S=g(b);return p.set(v,S),S};return {package:t,get body(){return x(Ft)},story:x,storyOf:b=>{if(x(Ft)?.has(b))return Ft;for(let[S]of s().entries())for(let w of ["header","footer"])for(let H of Se){let E={kind:w,sectionIndex:S,variant:H};if(x(E)?.has(b))return E}for(let S of ["footnote","endnote"]){let w=m(S);if(w.ok)for(let H of w.ids){let E={kind:"note",noteKind:S,noteId:H};if(x(E)?.has(b))return E}}return null},sections:()=>d??=Oo(t,e,s()),furniture(b){let v=s()[b];if(!v)return Co;let S=[];for(let w of ["header","footer"]){let H=w==="header"?v.headers:v.footers;for(let E of Se){let j=H.get(E);j&&S.push(Object.freeze({kind:w,variant:E,declared:!j.inherited}));}}return Object.freeze(S)},noteIds:m,styles:r}}var wo=Object.freeze([]);function To(t,e,n){let r=i=>({state:n,step:{ok:false,error:{code:"unsupported-capability",message:i,detail:"changeTrackingMode"}}});return t.op==="getChangeTrackingMode"||t.op==="setChangeTrackingMode"?e?t.op==="getChangeTrackingMode"?{state:n,step:{ok:true,kind:"query",value:{kind:"text",text:n.mode}}}:t.mode!=="Off"&&t.mode!=="TrackMineOnly"?r("TrackAll requires shared tracking enforcement for every peer and is not supported"):t.mode==="TrackMineOnly"&&(typeof t.author!="string"||!t.author.trim()||!chunk77DD4EBC_cjs.O(t.author))?r("TrackMineOnly requires a non-empty XML-safe runtime author"):{state:{mode:t.mode,...t.mode==="TrackMineOnly"?{author:t.author.trim()}:{}},step:{ok:true,kind:"query",value:{kind:"applied"}}}:r("this host does not support runtime-local change tracking"):n.mode==="Off"||rn(t)?null:r(`${t.op} does not support TrackMineOnly; no permanent edit was applied`)}function rn(t){return !Wt(t)||t.op==="setChangeTrackingMode"||t.op==="insertText"||t.op==="replaceSpan"&&!("body"in t.span)?true:["proposeInsertion","proposeDeletion","proposeReplacement","insertComment","replyToComment","deleteComment","setCommentResolved","acceptRevision","rejectRevision","acceptAllRevisions","rejectAllRevisions","selectSpan","selectBookmark"].includes(t.op)}function xa(){let t=globalThis.crypto,e=t?.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 n=e.call(t,new Uint8Array(16)),r="";for(let i of n)r+=i.toString(16).padStart(2,"0");return r}function Aa(t){return typeof t=="object"&&t!==null&&"kind"in t&&"ref"in t}function No(){let t=new Map,e=new Map,n=new Map,r=new Map,i=xa(),s=null,d=(u,m)=>{let A=(r.get(u)??0)+1;r.set(u,A);let g=`${u}:${i}:${String(A)}`;return t.set(g,m),Object.freeze({kind:u,ref:g})},p=(u,m,A)=>{let g=`${u}\0${m}`,x=n.get(g);if(x)return Object.freeze({kind:u,ref:x});let k=d(u,A);return n.set(g,k.ref),k};return {document(){return s??=d("document",{kind:"document"}),s},body(u,m){return p("body",`${J(u)}:${m??""}`,{kind:"body",story:u,...m?{rootNodeId:m}:{}})},table(u,m){return p("table",`${J(m)}:${u}`,{kind:"table",nodeId:u,story:m})},tableRow(u,m){return p("tableRow",`${J(m)}:${u}`,{kind:"tableRow",nodeId:u,story:m})},tableCell(u,m){return p("tableCell",`${J(m)}:${u}`,{kind:"tableCell",nodeId:u,story:m})},field(u,m,A){return p("field",`${J(A)}:${m}`,{kind:"field",paragraphId:u,fieldNodeId:m,story:A})},inlinePicture(u,m){return p("inlinePicture",`${J(m)}:${u}`,{kind:"inlinePicture",drawingNodeId:u,story:m})},paragraph(u,m){let A=e.get(u);if(A)return Object.freeze({kind:"paragraph",ref:A});let g=d("paragraph",{kind:"paragraph",paragraphId:u,story:m});return e.set(u,g.ref),g},section(u){return p("section",String(u),{kind:"section",index:u})},note(u,m){return p("note",`${u}:${String(m)}`,{kind:"note",noteKind:u,noteId:m})},comment(u,m){return p("comment",`${J(m)}\0${u}`,{kind:"comment",commentId:u,story:m})},revision(u,m){return p("revision",`${J(m)}\0${u}`,{kind:"revision",revisionId:u,story:m})},bookmark(u,m){return p("bookmark",`${J(m)}\0${u}`,{kind:"bookmark",name:u,story:m})},list(u,m){return p("list",`${J(m)}\0${u}`,{kind:"list",numId:u,story:m})},contentControl(u,m){return p("contentControl",`${J(m)}\0${u}`,{kind:"contentControl",nodeId:u,story:m})},retarget(u,m){let A=e.get(u);if(!A||u===m)return;let g=t.get(A);!g||g.kind!=="paragraph"||(e.delete(u),t.set(A,{kind:"paragraph",paragraphId:m,story:g.story}),e.has(m)||e.set(m,A));},resolve(u,m){if(!Aa(u)||u.kind!==m||typeof u.ref!="string")return null;let A=t.get(u.ref);return !A||A.kind!==m?null:A}}}function bt(t,e){return {ok:false,code:t,detail:e}}function xt(t){return {ok:true,value:t}}function rt(t,e,n,r){let i=n.resolve(t,e);if(!i||i.kind!=="body"&&i.kind!=="paragraph")return bt("invalid-handle",`not-a-${e}-handle`);let s=r.story(i.story);if(!s)return bt("invalid-handle",`no-such-story:${J(i.story)}`);if(i.kind==="body"&&i.rootNodeId){let d=chunk77DD4EBC_cjs.Ga(s.part,i.rootNodeId);return !d||d.kind!=="tableCell"?bt("invalid-handle","cell no longer exists"):xt(Ee(s,d))}return xt(s)}function pt(t,e,n){let r=e.resolve(t,"paragraph");if(!r||r.kind!=="paragraph")return bt("invalid-handle","not-a-paragraph-handle");let i=n.story(r.story);if(!i)return bt("invalid-handle",`no-such-story:${J(r.story)}`);let s=i.indexOf(r.paragraphId);return s<0?bt("invalid-handle","paragraph-not-in-body"):xt({story:r.story,paragraphId:r.paragraphId,index:s,offset:0})}function va(t,e,n){let r=pt(t.paragraph,e,n);if(!r.ok)return r;let s=(n.story(r.value.story)?.rawText(r.value.paragraphId)??"").length,{offset:d}=t;return !Number.isInteger(d)||d<0||d>s?bt("invalid-offset",`offset ${String(d)} outside 0..${String(s)}`):xt({...r.value,offset:d})}function Zt(t,e,n){if("paragraph"in t){if(!("at"in t))return va(t,e,n);let p=pt(t.paragraph,e,n);if(!p.ok||t.at==="start")return p;let m=(n.story(p.value.story)?.rawText(p.value.paragraphId)??"").length;return xt({...p.value,offset:m})}let r=rt(t.body,"body",e,n);if(!r.ok)return r;let i=r.value.paragraphIds;if(i.length===0)return bt("invalid-offset","empty-story");if(t.at==="start")return xt({story:r.value.story,paragraphId:i[0],index:r.value.indexOf(i[0]),offset:0});let s=i.length-1,d=i[s];return xt({story:r.value.story,paragraphId:d,index:r.value.indexOf(d),offset:(r.value.rawText(d)??"").length})}function Ia(t,e){return t.index<e.index||t.index===e.index&&t.offset<=e.offset}function Pa(t){let e=t.paragraphIds;if(e.length===0)return null;let n=e.length-1,r=e[n];return {start:{story:t.story,paragraphId:e[0],index:t.indexOf(e[0]),offset:0},end:{story:t.story,paragraphId:r,index:t.indexOf(r),offset:(t.rawText(r)??"").length}}}function z(t,e,n){if("body"in t){let s=rt(t.body,"body",e,n);return s.ok?xt(Pa(s.value)):s}if("paragraph"in t){let s=pt(t.paragraph,e,n);if(!s.ok)return s;let p=(n.story(s.value.story)?.rawText(s.value.paragraphId)??"").length;return xt({start:s.value,end:{...s.value,offset:p}})}let r=Zt(t.start,e,n);if(!r.ok)return r;let i=Zt(t.end,e,n);return i.ok?J(r.value.story)!==J(i.value.story)?bt("invalid-handle","span-crosses-stories"):Ia(r.value,i.value)?xt({start:r.value,end:i.value}):bt("invalid-offset","span-start-after-end"):i}function ot(t,e,n){if("body"in t)return rt(t.body,"body",e,n);if("paragraph"in t)return rt(t.paragraph,"paragraph",e,n);let r=t.start;return "paragraph"in r?rt(r.paragraph,"paragraph",e,n):rt(r.body,"body",e,n)}function Le(t,e,n){if("paragraph"in t)return pt(t.paragraph,e,n);let r=rt(t.body,"body",e,n);if(!r.ok)return r;let i=r.value.paragraphIds;if(i.length===0)return bt("invalid-offset","empty-story");let s=t.at==="first"?0:i.length-1;return xt({story:r.value.story,paragraphId:i[s],index:s,offset:0})}function At(t,e){if(!t)return [];let n=e.paragraphIds,r=n[t.start.index]===t.start.paragraphId?t.start.index:n.indexOf(t.start.paragraphId),i=n[t.end.index]===t.end.paragraphId?t.end.index:n.indexOf(t.end.paragraphId);return r<0||i<r?[]:n.slice(r,i+1)}function Ut(t,e){if(!t)return [];let n=At(t,e),r=n.length-1;return n.map((i,s)=>{let d=(e.rawText(i)??"").length,p=s===0?t.start.offset:0,u=s===r?t.end.offset:d;return {paragraphId:i,start:p,end:u,whole:p===0&&u===d}})}function Eo(t,e,n,r="allMarkup"){if(!t)return "";let i=At(t,e);return i.length===1?e.projectedText(t.start.paragraphId,r)?.sliceRaw(t.start.offset,t.end.offset)??"":i.map((s,d)=>{let p=e.projectedText(s,r);if(!p)return "";let u=(e.rawText(s)??"").length;return d===0?p.sliceRaw(t.start.offset,u):d===i.length-1?p.sliceRaw(0,t.end.offset):p.text}).join(n)}function Nt(t,e){return {start:{paragraph:e.paragraph(t.start.paragraphId,t.start.story),offset:t.start.offset},end:{paragraph:e.paragraph(t.end.paragraphId,t.end.story),offset:t.end.offset}}}function Oa(t){return t?.kind!=="paragraph"?false:t.children.every(e=>e.namespaceUri!==chunk77DD4EBC_cjs.da?false:e.localName==="pPr"?true:e.kind==="run"&&e.children.every(n=>n.namespaceUri===chunk77DD4EBC_cjs.da&&(n.localName==="rPr"||n.localName==="t"&&n.children.every(r=>r.kind==="textValue"))))}function an(t,e,n){return Oa(chunk77DD4EBC_cjs.Ga(t,e))&&chunk77DD4EBC_cjs.Ph(t,e,n)===null}function Lo(t,e,n,r){let i=chunk77DD4EBC_cjs.Ph(t,e,n);if(!i)return null;let s=n===i.offset?chunk77DD4EBC_cjs.fi(t,{op:"insertText",paragraphId:e,offset:n,text:r}):null;return s?.ok&&chunk77DD4EBC_cjs.gi(s.part,e)?.slice(n,n+r.length)===r?null:{ok:false,error:{code:"unsupported-capability",message:"insert at the placeholder start or replace the complete prompt",detail:"placeholder-insertion-offset"}}}function Ra(t,e,n){return t.start===t.end?e<t.start&&t.start<n:e===n?t.start<e&&e<t.end:Math.max(t.start,e)<Math.min(t.end,n)}var He=class{#t=new Map;has(e){return this.#t.has(e)}append(e,n,r,i,s=false){let d=this.#t.get(e)??[];if(d.some(g=>Ra(g,n,r)))return null;let p=n,u=r;for(let g of d){let x=g.length-(g.end-g.start);g.end<=n&&!(s&&g.start===n&&g.end===n)&&(p+=x),(g.end<r||g.end===r&&g.start!==g.end)&&(u+=x);}n===r&&(u=p);let m=i-(r-n);for(let g of d)r<=g.start&&!(n===r&&g.start===g.end&&n===g.start&&!s)&&(g.result.start+=m,g.result.end+=m);let A={start:p,end:p+i};return d.push({start:n,end:r,length:i,result:A}),this.#t.set(e,d),{start:p,end:u,result:A}}};function Ho(t,e,n,r,i=false){let s=e.start.paragraphId,d=t.append(s,e.start.offset,e.end.offset,n.length,i);return d?{ok:true,kind:"command",ops:Fo(s,d.start,d.end,n),story:e.start.story,answer:()=>({kind:"span",span:Nt({start:{...e.start,offset:d.result.start},end:{...e.start,offset:d.result.end}},r)})}:{ok:false,error:{code:"conflicting-operations",message:"text edits overlap in the batch snapshot",detail:s}}}function Fo(t,e,n,r){let i=[];return r.length&&i.push({op:"insertText",paragraphId:t,offset:e,text:r,...n>e?{bias:"right"}:{}}),n>e&&i.push({op:"deleteText",paragraphId:t,start:e+r.length,end:n+r.length}),i}function Mo(t,e,n,r){let i=e.start.paragraphId,s=chunk77DD4EBC_cjs.gi(t,i),d=chunk77DD4EBC_cjs.Ph(t,i,e.start.offset),p=d&&n.length?[{op:"insertText",paragraphId:i,offset:e.start.offset,text:n,bias:"right"}]:Fo(i,e.start.offset,e.end.offset,n),u=t;for(let A of p){let g=chunk77DD4EBC_cjs.fi(u,A);if(!g.ok)return {ok:false,error:{code:"unsupported-content",message:"that replacement cannot preserve the targeted text safely",detail:g.reason}};u=g.part;}let m=chunk77DD4EBC_cjs.gi(u,i);return s===null||m!==s.slice(0,e.start.offset)+n+s.slice(e.end.offset)?{ok:false,error:{code:d?"unsupported-capability":"unsupported-content",message:d?"replace the complete placeholder prompt to avoid consuming unrelated text":"that replacement changes the expected text positions",detail:i}}:{ok:true,kind:"command",ops:p,story:e.start.story,answer:()=>({kind:"span",span:Nt({start:e.start,end:{...e.start,offset:e.start.offset+n.length}},r)})}}var jo=/\s/;function Do(t,e){let n=[],r=0;for(;r<t.length;){let i=null;for(let s of e){let d=t.indexOf(s,r);d<0||(!i||d<i.start||d===i.start&&s.length>i.length)&&(i={start:d,length:s.length});}if(!i)break;n.push(i),r=i.start+i.length;}return n}function Bo(t,e,n){let r=e[n]?.markParagraphId??null;if(r!==null)return r;let i=t.paragraphIds,s=i[i.length-1];return s===void 0||new Set(e.map(p=>p.markParagraphId).filter(p=>p!==null)).has(s)?null:s}function _o(t,e){for(let n of [t.start,t.end]){let r=e.rawText(n.paragraphId);if(r===null||n.offset>r.length)return false}return true}function Vo(t,e,n){let r=e,i=n;for(;r<i&&jo.test(t[r]);)r+=1;for(;i>r&&jo.test(t[i-1]);)i-=1;return [r,i]}function Fe(t,e){let n=chunk77DD4EBC_cjs.Ga(t,e);if(!n||n.kind!=="paragraph")return [];let r=chunk77DD4EBC_cjs.Ne(n);return chunk77DD4EBC_cjs.ih(n).flatMap(i=>{let s=r.find(p=>p.node.id===i.fieldNodeId),d=chunk77DD4EBC_cjs.Ga(t,i.fieldNodeId);return s?[{paragraphId:e,fieldNodeId:i.fieldNodeId,code:i.instruction,start:s.start,end:s.end,rewritable:i.rewritable,locked:!!d&&chunk77DD4EBC_cjs.he(d,"fldLock")===true}]:[]})}function Wo(t){let n=chunk77DD4EBC_cjs.xa(`<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:fldSimple w:instr="${t==="PAGE"?"PAGE":"NUMPAGES"}"><w:r><w:t/></w:r></w:fldSimple></w:p></w:body></w:document>`,{name:"/word/document.xml",contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"});if(!n.ok)throw new Error("could not build a page field");let r=n.part.root.children.find(s=>s.kind==="body"),i=r&&chunk77DD4EBC_cjs.Ad(r)[0];if(!i||i.kind!=="paragraph")throw new Error("could not build a page field paragraph");return i}var dt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function Uo(t,e,n,r,i){if(t.op==="getFields"||t.op==="insertField"){let A=z(t.span,e,n),g=ot(t.span,e,n);if(!A.ok||!g.ok)return dt("that field range no longer exists","invalid-handle");let x=g.value;if(t.op==="getFields")return {ok:true,kind:"query",value:{kind:"handles",handles:Ut(A.value,x).flatMap(F=>Fe(x.part,F.paragraphId).filter(K=>K.start>=F.start&&K.end<=F.end)).map(F=>e.field(F.paragraphId,F.fieldNodeId,x.story))}};if(!A.value)return dt("insert a paragraph before inserting a field");if(t.removeFormatting!==void 0&&t.removeFormatting!==false)return dt("removeFormatting is not supported");if(t.text!==void 0&&typeof t.text!="string")return dt("field text must be a string");if(t.fieldType!==void 0&&typeof t.fieldType!="string")return dt("field type must be a string");let k=t.fieldType??"Empty",b=null;if(k==="Page"||k==="NumPages"){if(t.text!==void 0&&t.text.trim()!=="")return dt("field switches are not supported");b=k==="Page"?"PAGE":"NUMPAGES";}else k==="Empty"&&(b=chunk77DD4EBC_cjs.lh(t.text??""));if(!b)return dt("only PAGE and NUMPAGES fields are supported");let{start:v,end:S}=A.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return dt("unsupported field insert location");if(t.location==="Replace"&&v.paragraphId!==S.paragraphId)return dt("field replacement requires one paragraph");let w=t.location==="After"||t.location==="End"?S:v,H=r(x,w.paragraphId);if(H)return H;let E=[];return t.location==="Replace"&&S.offset>v.offset&&E.push({op:"deleteText",paragraphId:v.paragraphId,start:v.offset,end:S.offset}),E.push({op:"insertFragment",paragraphId:w.paragraphId,offset:w.offset,blocks:[Wo(b)],lastMarkCovered:false}),{ok:true,kind:"command",story:x.story,ops:E,answer:j=>{let F=j.story(x.story)?.part,K=F&&Fe(F,w.paragraphId).find(C=>C.start===w.offset);if(!K)throw new Error("inserted field was not committed");return {kind:"handle",handle:e.field(w.paragraphId,K.fieldNodeId,x.story)}}}}let s=e.resolve(t.field,"field");if(!s||s.kind!=="field")return dt("that is not a field handle","invalid-handle");let d=n.story(s.story),p=d&&Fe(d.part,s.paragraphId).find(A=>A.fieldNodeId===s.fieldNodeId);if(!d||!d.has(s.paragraphId)||!p)return dt("that field no longer exists","invalid-handle");if(t.op==="getField")return {ok:true,kind:"query",value:{kind:"field",field:{code:p.code}}};if(p.locked||chunk77DD4EBC_cjs.Fe(d.part,s.fieldNodeId).content||chunk77DD4EBC_cjs.He(d.part,s.fieldNodeId))return dt("field is protected");let u=r(d,s.paragraphId,t.op==="updateFieldResult");if(u)return u;let m=[];if(t.op==="deleteField")m.push({op:"deleteText",paragraphId:s.paragraphId,start:p.start,end:p.end});else if(t.op==="setFieldCode"){if(!chunk77DD4EBC_cjs.lh(p.code)||!chunk77DD4EBC_cjs.lh(t.code))return dt("only PAGE and NUMPAGES code writes are supported");m.push({op:"setFieldCode",paragraphId:s.paragraphId,fieldNodeId:s.fieldNodeId,code:t.code});}else {let A=chunk77DD4EBC_cjs.lh(p.code);if(!A||!p.rewritable)return dt("this field result cannot be evaluated","unsupported-capability");let g=i?.(d.story,s.paragraphId,s.fieldNodeId);if(!g||!Number.isInteger(g.pageNumber)||g.pageNumber<1||!Number.isInteger(g.pageCount)||g.pageCount<1)return dt("field update requires actual semantic pagination","unsupported-capability");let x=A==="PAGE"?g.pageNumberText??String(g.pageNumber):String(g.pageCount);m.push({op:"refreshFieldResults",updates:[{paragraphId:s.paragraphId,fieldNodeId:s.fieldNodeId,text:x}]});}return {ok:true,kind:"command",story:d.story,ops:m,answer:()=>({kind:"applied"})}}var it=(t,e)=>({ok:false,error:{code:t,message:e,detail:e}}),$t=t=>({ok:true,kind:"query",value:t}),Sa=new Set(["getTables","getTable","getTableRows","getTableCells","getTableCell","getTableCellProperties","getTableCellBody","updateTable","updateTableCell","insertTable"]);function ue(t){let e=new Set,n=[t];for(;n.length;){let r=n.pop();r.kind==="paragraph"&&e.add(r.id),r.kind!=="textValue"&&n.push(...r.children);}return e}function $o(t,e){let n=ue(t);return [...ue(e)].filter(r=>!n.has(r)).length}function Ca(t,e){let n=[{node:t}];for(;n.length;){let{node:r,table:i}=n.pop();if(r.id===e)return i;if(r.kind==="textValue")continue;let s=r.kind==="table"?r:i;for(let d of r.children)n.push({node:d,table:s});}}function zo(t){let e=t.package&&chunk77DD4EBC_cjs.if(t.package);return e?[...chunk77DD4EBC_cjs.hf(e).values()].filter(n=>n.type==="table"):[]}function Ko(t,e){if(!Sa.has(t.op))return null;let{handles:n,reads:r}=e;if(t.op==="getTables"||t.op==="insertTable"){let g=t.op==="getTables"?t.scope:t.span,x=ot(g,n,r);if(!x.ok)return it(x.code,x.detail);let k=z(g,n,r);if(!k.ok)return it(k.code,k.detail);let b=x.value;if(t.op==="getTables"){let E=k.value,j=chunk77DD4EBC_cjs.hi(b.root).filter(F=>{if("body"in g)return true;if(!E)return false;let K=[...ue(F)].sort((Z,et)=>b.indexOf(Z)-b.indexOf(et)),C=K[0],D=K[K.length-1];return !C||!D?false:b.indexOf(C)>=E.start.index&&b.indexOf(D)<=E.end.index});return $t({kind:"handles",handles:j.map(F=>n.table(F.id,b.story))})}if(!k.value)return it("invalid-offset","empty-table-insertion-range");if(!["Before","After"].includes(t.location))return it("unsupported-content","table-insertion-location");let v=t.location==="Before"?k.value.start:k.value.end,S=chunk77DD4EBC_cjs.li(b,v.paragraphId,v.offset,t.rowCount,t.columnCount,t.values);if(!S.ok)return it("unsupported-content",S.reason);let w=e.admitWrite(b,$o(b.part.root,S.resultPart.root),[v.paragraphId]);if(w)return w;let H=new Set(chunk77DD4EBC_cjs.hi(b.root).map(E=>E.id));return {ok:true,kind:"command",story:b.story,ops:[{op:"authorTable",action:{kind:"insert",paragraphId:v.paragraphId,offset:v.offset,rowCount:t.rowCount,columnCount:t.columnCount,...t.values?{values:t.values}:{}}}],answer:E=>{let j=E.story(b.story),F=j&&chunk77DD4EBC_cjs.hi(j.root).find(K=>!H.has(K.id));return F?{kind:"handle",handle:n.table(F.id,b.story)}:{kind:"applied"}}}}let i=t.op==="getTableCells"?"tableRow":"cell"in t?"tableCell":"table",s=t.op==="getTableCells"?t.row:"cell"in t?t.cell:"table"in t?t.table:{kind:"document",ref:""},d=n.resolve(s,i);if(!d||!("nodeId"in d)||!("story"in d))return it("invalid-handle","unknown-table-object");let p=r.story(d.story);if(!p)return it("invalid-handle","missing-table-story");let u=chunk77DD4EBC_cjs.Ga(p.part,d.nodeId);if(!u||u.kind!==i)return it("invalid-handle","deleted-table-object");let m=i==="table"?u:Ca(p.root,d.nodeId);if(!m)return it("invalid-handle","missing-parent-table");let A=chunk77DD4EBC_cjs.ii(p,m.id);if(!A)return it("unsupported-content","unsupported-table-topology");switch(t.op){case "getTable":return $t({kind:"table",table:{values:A.values,headerRowCount:A.headerRowCount,rowCount:A.rowIds.length,columnCount:A.columnCount,style:zo(r).find(g=>g.styleId===A.styleId)?.name??""}});case "getTableRows":return $t({kind:"handles",handles:A.rowIds.map(g=>n.tableRow(g,p.story))});case "getTableCells":{let g=A.rowIds.indexOf(d.nodeId);return $t({kind:"handles",handles:(A.cellIds[g]??[]).map(x=>n.tableCell(x,p.story))})}case "getTableCell":{if(!Number.isInteger(t.rowIndex)||!Number.isInteger(t.cellIndex))return it("invalid-offset","invalid-cell-index");let g=A.cellIds[t.rowIndex]?.[t.cellIndex];return g?$t({kind:"handle",handle:n.tableCell(g,p.story)}):it("invalid-handle","cell-not-found")}case "getTableCellBody":return $t({kind:"handle",handle:n.body(p.story,d.nodeId)});case "getTableCellProperties":{let g=chunk77DD4EBC_cjs.ji(p,m.id,d.nodeId);return g?$t({kind:"tableCell",cell:{value:g.value,columnWidth:g.columnWidth,shadingColor:g.shadingColor,verticalAlignment:g.verticalAlignment}}):it("invalid-handle","cell-not-found")}case "updateTable":case "updateTableCell":{let g=t.op==="updateTable"?t.mutation:{...t.properties,kind:"cell",cellId:d.nodeId};if(g.kind==="properties"&&g.styleId!==void 0){let v=g.styleId;if(typeof v!="string"||v.trim().length===0)return it("unsupported-content","invalid-table-style-name");let S=zo(r).find(w=>w.name?.trim().toLowerCase()===v.trim().toLowerCase());if(!S)return it("unsupported-content","table-style-not-defined");g={...g,styleId:S.styleId};}let x=chunk77DD4EBC_cjs.ki(p,m.id,g);if(!x.ok)return it("unsupported-content",x.reason);let k=e.admitWrite(p,$o(p.part.root,x.resultPart.root),g.kind==="values"?[...ue(m)]:g.kind==="cell"&&g.value!==void 0?[...ue(u)]:[]);if(k)return k;let b=new Set(A.rowIds);return {ok:true,kind:"command",story:p.story,ops:[{op:"authorTable",action:{kind:"existing",tableId:m.id,mutation:g}}],answer:v=>{if(g.kind!=="addRows")return {kind:"applied"};let S=v.story(p.story);return {kind:"handles",handles:((S&&chunk77DD4EBC_cjs.ii(S,m.id))?.rowIds??[]).filter(H=>!b.has(H)).map(H=>n.tableRow(H,p.story))}}}}default:return it("unsupported-content","unknown-table-operation")}}var Go=t=>({ok:false,error:{code:"unsupported-content",message:t}});function wa(t){if(t.op==="getText")return t.target;if("body"in t)return t.body;if(t.op==="insertText"&&"body"in t.at)return t.at.body;if(t.op==="replaceSpan"&&"body"in t.span)return t.span.body;if(t.op==="insertParagraph"&&"body"in t.anchor)return t.anchor.body}function Xo(t,e,n){let r=wa(t);if(!r)return null;let i=e.handles.resolve(r,"body");if(!i||i.kind!=="body"||i.story.kind!=="header"&&i.story.kind!=="footer")return null;let s=i.story,d=e.reads.package;if(!d||e.reads.story(s))return null;if(!e.reads.sections()[s.sectionIndex])return Go("that section no longer exists");if(t.op==="getText")return {ok:true,kind:"query",value:{kind:"text",text:""}};if(t.op==="getParagraphs"||t.op==="getLists")return {ok:true,kind:"query",value:{kind:"handles",handles:[]}};if(t.op!=="insertText"&&t.op!=="replaceSpan"&&t.op!=="insertParagraph")return null;let p=m=>{let A=chunk77DD4EBC_cjs.wf(m,{op:"createHeaderFooter",sectionIndex:s.sectionIndex,kind:s.kind,variant:s.variant,...s.variant==="first"?{titlePage:true}:{},...s.variant==="even"?{evenAndOddHeaders:true}:{}});if(!A.ok||!A.createdPartName)return null;let g=de(A.package),x=n(g),k=x.plan(t);if(!k.ok||k.kind!=="command"||k.relate||k.lifecycle||k.packageEdits?.length)return null;let b=A.package.parts.get(A.createdPartName);if(!b)return null;for(let S of k.ops){let w=chunk77DD4EBC_cjs.fi(b,S);if(!w.ok)return null;b=w.part;}let v=chunk77DD4EBC_cjs.fc(A.package,b);return x.settle(de(v)).ok?{pkg:v,planner:x,step:k}:null},u=p(d);return u?{ok:true,kind:"command",story:{kind:"body"},ops:[],solitary:true,packageEdits:[m=>{let A=p(m);if(!A)throw new Error("header/footer creation changed during transaction");return u=A,A.pkg}],answer:m=>u.step.answer(m)}:Go("cannot create this header or footer with that content")}var Ta=20*1024*1024;function Na(t){if(typeof t!="string"||t.length===0||t.length>Math.ceil(Ta/3)*4||t.length%4!==0)return null;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=t.endsWith("==")?2:t.endsWith("=")?1:0,r=new Uint8Array(t.length/4*3-n),i=0;for(let s=0;s<t.length;s+=4){let d=s+4===t.length,p=d?4-n:4,u=[0,0,0,0];for(let A=0;A<p;A++){let g=e.indexOf(t[s+A]);if(g<0)return null;u[A]=g;}if(d&&(n===2&&(u[1]&15)!==0||n===1&&(u[2]&3)!==0))return null;let m=u[0]<<18|u[1]<<12|u[2]<<6|u[3];i<r.length&&(r[i++]=m>>>16),i<r.length&&(r[i++]=m>>>8),i<r.length&&(r[i++]=m);}return r}function Yo(t,e,n,r,i){let s=Na(i);if(!s)return {ok:false,detail:"picture: invalid or oversized base64 (20 MiB maximum)"};let d=chunk77DD4EBC_cjs.tb(s);if(d!=="image/png"&&d!=="image/jpeg")return {ok:false,detail:"picture: only PNG and JPEG are supported"};if(!Ea(s,d))return {ok:false,detail:"picture: truncated raster container"};let p=chunk77DD4EBC_cjs.yb(s,d);if(!p||p.pixelWidth*p.pixelHeight>4e7)return {ok:false,detail:"picture: invalid or oversized raster dimensions"};let u=p.pixelWidth*72/(p.dpiX??96),m=p.pixelHeight*72/(p.dpiY??96),A=chunk77DD4EBC_cjs.Zb(u),g=chunk77DD4EBC_cjs.Zb(m);if(A===null||g===null)return {ok:false,detail:"picture: invalid physical dimensions"};let x=chunk77DD4EBC_cjs.Wb(t,e,{bytes:s,mime:d});if(!x.ok)return {ok:false,detail:`picture: ${x.reason}`};let k=chunk77DD4EBC_cjs._b({docPrId:x.docPrId,lockAspectRatio:true,relationshipId:x.relationshipId,extentEmu:{cx:A,cy:g}});return {ok:true,docPrId:x.docPrId,ops:[{op:"insertDrawing",paragraphId:n,offset:r,drawing:k}],packageEdits:[b=>{let v=chunk77DD4EBC_cjs.Wb(b,e,{bytes:s,mime:d});if(!v.ok||v.relationshipId!==x.relationshipId||v.docPrId!==x.docPrId||v.partName!==x.partName)throw new Error("picture allocation changed during the batch");return v.pkg}]}}function Jo(t,e){return chunk77DD4EBC_cjs.mb(t).find(n=>n.drawingNodeId===e&&n.kind==="inline"&&n.picture!==null)??null}function Qo(t){return {width:t.extentEmu.cx/chunk77DD4EBC_cjs.Yb,height:t.extentEmu.cy/chunk77DD4EBC_cjs.Yb,lockAspectRatio:t.locks.changeAspect,altTextDescription:t.description}}function Zo(t,e){let n=new Set(chunk77DD4EBC_cjs.mb(t).filter(i=>i.kind==="inline"&&i.picture!==null).map(i=>i.drawingNodeId)),r=[];for(let i of e){let s=chunk77DD4EBC_cjs.Ga(t,i.paragraphId);if(!(!s||s.kind!=="paragraph"))for(let d of chunk77DD4EBC_cjs.Ne(s))d.start>=i.start&&d.end<=i.end&&n.has(d.node.id)&&r.push(d.node.id);}return r}function qo(t,e){let n=[],r=t.drawingNodeId;if(e.lockAspectRatio!==void 0&&typeof e.lockAspectRatio!="boolean")return {ok:false,detail:"lockAspectRatio: not a boolean"};let i=e.lockAspectRatio??t.locks.changeAspect;if(e.lockAspectRatio===false&&n.push({op:"setDrawingLocks",drawingNodeId:r,locks:{changeAspect:false}}),e.width!==void 0||e.height!==void 0){let s=e.width??t.extentEmu.cx/chunk77DD4EBC_cjs.Yb,d=e.height??t.extentEmu.cy/chunk77DD4EBC_cjs.Yb;if(i){let m=t.extentEmu.cx/t.extentEmu.cy;if(e.width!==void 0&&e.height!==void 0&&Math.abs(s/d-m)>1e-6)return {ok:false,detail:"picture: width and height disagree with the locked aspect ratio"};e.width!==void 0&&e.height===void 0&&(d=s/m),e.height!==void 0&&e.width===void 0&&(s=d*m);}let p=chunk77DD4EBC_cjs.Zb(s),u=chunk77DD4EBC_cjs.Zb(d);if(p===null||u===null)return {ok:false,detail:"picture: dimensions must be finite positive points"};n.push({op:"resizeDrawing",drawingNodeId:r,extentEmu:{cx:p,cy:u}});}if(e.lockAspectRatio===true&&n.push({op:"setDrawingLocks",drawingNodeId:r,locks:{changeAspect:true}}),e.altTextDescription!==void 0){if(typeof e.altTextDescription!="string"||e.altTextDescription.length>32767||!chunk77DD4EBC_cjs.O(e.altTextDescription))return {ok:false,detail:"altTextDescription: invalid XML text or length"};n.push({op:"setDrawingMetadata",drawingNodeId:r,title:t.title,description:e.altTextDescription});}return n.length?{ok:true,ops:n}:{ok:false,detail:"picture: no properties requested"}}function Ea(t,e){if(e==="image/jpeg")return t.length>=4&&t[t.length-2]===255&&t[t.length-1]===217;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=8,i=false;for(;r+12<=t.length;){let s=n.getUint32(r);if(s>t.length-r-12)return false;let d=String.fromCharCode(t[r+4],t[r+5],t[r+6],t[r+7]);if(d==="IDAT"&&s>0&&(i=true),r+=s+12,d==="IEND")return i&&s===0&&r===t.length}return false}var vt=(t,e="unsupported-content")=>({ok:false,error:{code:e,message:t}});function tr(t,e,n,r){if(t.op==="getInlinePictures"||t.op==="insertInlinePicture"){let A=z(t.span,e,n),g=ot(t.span,e,n);if(!A.ok||!g.ok)return vt("that picture range no longer exists","invalid-handle");let x=g.value;if(t.op==="getInlinePictures")return {ok:true,kind:"query",value:{kind:"handles",handles:Zo(x.part,Ut(A.value,x)).map(j=>e.inlinePicture(j,x.story))}};if(!A.value||!n.package)return vt("insert a paragraph before inserting a picture");let{start:k,end:b}=A.value;if(!["Before","After","Start","End","Replace"].includes(t.location))return vt("unsupported picture insert location");if(t.location==="Replace"&&k.paragraphId!==b.paragraphId)return vt("picture replacement requires a single paragraph");let v=t.location==="After"||t.location==="End"?b:k;if(chunk77DD4EBC_cjs.Fe(x.part,v.paragraphId).content||chunk77DD4EBC_cjs.He(x.part,v.paragraphId))return vt("picture insertion is inside protected content");let S=chunk77DD4EBC_cjs.Ga(x.part,v.paragraphId);if(S?.kind==="paragraph"){for(let j of chunk77DD4EBC_cjs.Ne(S))if((t.location==="Replace"?j.start<b.offset&&j.end>k.offset:j.start<v.offset&&j.end>v.offset)&&(chunk77DD4EBC_cjs.Fe(x.part,j.node.id).content||chunk77DD4EBC_cjs.He(x.part,j.node.id)))return vt("picture insertion touches protected content")}let w=r(x,v.paragraphId);if(w)return w;let H=Yo(n.package,x.part.name,v.paragraphId,v.offset,t.base64);if(!H.ok)return vt(H.detail);let E=[];return t.location==="Replace"&&b.offset>k.offset&&E.push({op:"deleteText",paragraphId:k.paragraphId,start:k.offset,end:b.offset}),E.push(...H.ops),{ok:true,kind:"command",story:x.story,ops:E,packageEdits:H.packageEdits,answer:j=>{let F=j.story(x.story)?.part,K=F&&chunk77DD4EBC_cjs.mb(F).find(C=>C.docPrId===H.docPrId&&C.kind==="inline");if(!K)throw new Error("inserted picture was not committed");return {kind:"handle",handle:e.inlinePicture(K.drawingNodeId,x.story)}}}}let i=e.resolve(t.picture,"inlinePicture");if(!i||i.kind!=="inlinePicture")return vt("that is not a picture handle","invalid-handle");let s=n.story(i.story),d=s&&Jo(s.part,i.drawingNodeId);if(!s||!d)return vt("that inline picture no longer exists","invalid-handle");if(t.op==="getInlinePicture")return {ok:true,kind:"query",value:{kind:"inlinePicture",picture:Qo(d)}};let p=chunk77DD4EBC_cjs.Ga(s.part,i.drawingNodeId);for(;p&&p.kind!=="paragraph";)p=chunk77DD4EBC_cjs.Me(s.part,p.id);if(!p||!s.has(p.id))return vt("picture is outside this story","invalid-handle");let u=r(s,p.id);if(u)return u;let m=t.op==="deleteInlinePicture"?{ok:true,ops:[{op:"deleteDrawing",drawingNodeId:i.drawingNodeId}]}:qo(d,t.properties);return m.ok?{ok:true,kind:"command",story:s.story,ops:m.ops,answer:()=>({kind:"applied"})}:vt(m.detail)}function er(t,e,n,r){let i=x=>({ok:false,error:{code:"unsupported-content",message:x}});if(t.breakType!=="Page"&&t.breakType!=="SectionNext")return i("only Page and SectionNext breaks are supported");if(!["Before","After","Start","End","Replace"].includes(t.location))return i("invalid break insertion location");let s=z(t.span,e,n);if(!s.ok)return {ok:false,error:{code:s.code,message:s.detail}};let d=s.value;if(!d)return i("empty story has no break position");let p=t.location==="After"||t.location==="End"?d.end:d.start,u=n.story(p.story);if(!u)return i("missing story");if(t.location==="Replace"&&d.start.paragraphId!==d.end.paragraphId)return i("break replacement must remain in one paragraph");let m=t.breakType==="SectionNext";if(m&&(u.story.kind!=="body"||chunk77DD4EBC_cjs.zh(u.part,p.paragraphId)))return i("section breaks require a body paragraph outside a table");let A=r(u,p.paragraphId,m?1:0);if(A)return A;let g=[];return t.location==="Replace"&&d.end.offset>d.start.offset&&g.push({op:"deleteText",paragraphId:p.paragraphId,start:d.start.offset,end:d.end.offset}),m?g.push({op:"splitParagraph",paragraphId:p.paragraphId,offset:p.offset},{op:"setSectionMark",paragraphId:p.paragraphId,breakType:"nextPage"}):g.push({op:"insertPageBreak",paragraphId:p.paragraphId,offset:p.offset}),{ok:true,kind:"command",story:u.story,ops:g,answer:()=>({kind:"applied"})}}var St=(t,e)=>t.children.find(n=>n.kind!=="textValue"&&n.namespaceUri===chunk77DD4EBC_cjs.da&&n.localName===e),It=(t,e)=>t.attributes.find(n=>n.namespaceUri===chunk77DD4EBC_cjs.da&&n.localName===e)?.value,Me=t=>t.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">"),sn=t=>typeof t=="string"&&t.length<=255&&!/[\x00-\x08\x0b\x0c\x0e-\x1f\uFFFE\uFFFF]/.test(t),nr={None:"none",Arabic:"decimal",UpperRoman:"upperRoman",LowerRoman:"lowerRoman",UpperLetter:"upperLetter",LowerLetter:"lowerLetter"},or={Solid:["\uF0B7","Symbol"],Hollow:["o","Courier New"],Square:["\uF0A7","Wingdings"],Diamonds:["\uF076","Wingdings"],Arrow:["\uF0D8","Wingdings"],Checkmark:["\uF0FC","Wingdings"]};function ln(t){let e=chunk77DD4EBC_cjs.nf(t,"bullet");if(!e)return null;let n=e.pkg;for(let r=0;r<=8;r+=1)if(!ce(n,e.numId,r)){let i=je(n,e.numId,r,{bullet:r%3===0?"Solid":r%3===1?"Hollow":"Square"});if(!i)return null;n=i;}return {pkg:n,numId:e.numId}}function ce(t,e,n){let r=t.parts.get("/word/numbering.xml")?.root;if(!r)return false;let i=r.children,s=i.find(m=>m.kind!=="textValue"&&m.namespaceUri===chunk77DD4EBC_cjs.da&&m.localName==="num"&&It(m,"numId")===e);if(!s)return false;let d=s.children.find(m=>m.kind!=="textValue"&&m.namespaceUri===chunk77DD4EBC_cjs.da&&m.localName==="lvlOverride"&&It(m,"ilvl")===String(n));if(d&&St(d,"lvl"))return true;let p=St(s,"abstractNumId"),u=p&&i.find(m=>m.kind!=="textValue"&&m.namespaceUri===chunk77DD4EBC_cjs.da&&m.localName==="abstractNum"&&It(m,"abstractNumId")===It(p,"val"));return !!u&&!St(u,"numStyleLink")&&u.children.some(m=>m.kind!=="textValue"&&m.namespaceUri===chunk77DD4EBC_cjs.da&&m.localName==="lvl"&&It(m,"ilvl")===String(n))}function dn(t,e){if(!Number.isInteger(t)||t<0||t>8||!e||typeof e!="object")return false;if(e.bullet!==void 0){if(e.numbering!==void 0)return false;if(e.bullet==="Custom"){if(!Number.isInteger(e.charCode)||e.charCode<1||e.charCode>65535||e.charCode>=55296&&e.charCode<=57343||!sn(String.fromCharCode(e.charCode)))return false}else if(!Object.hasOwn(or,e.bullet))return false;if(e.fontName!==void 0&&(!sn(e.fontName)||!e.fontName.trim()))return false}if(e.numbering!==void 0&&!Object.hasOwn(nr,e.numbering)||e.formatString!==void 0&&(!Array.isArray(e.formatString)||e.formatString.length>32||e.formatString.some(r=>typeof r=="number"?!Number.isInteger(r)||r<0||r>t:!sn(r)||/%[1-9]/.test(r)))||e.startingNumber!==void 0&&(!Number.isInteger(e.startingNumber)||e.startingNumber<0||e.startingNumber>2147483647))return false;for(let r of [e.textIndent,e.bulletNumberPictureIndent])if(r!==void 0&&(!Number.isFinite(r)||Math.abs(r)>1584))return false;let n=["bullet","charCode","fontName","numbering","formatString","startingNumber","textIndent","bulletNumberPictureIndent"];return Object.keys(e).some(r=>!n.includes(r))||e.bullet===void 0&&(e.charCode!==void 0||e.fontName!==void 0)||e.numbering===void 0&&e.formatString!==void 0?false:Object.keys(e).length>0}function je(t,e,n,r){if(!dn(n,r))return null;let i=t.parts.get("/word/numbering.xml");if(!i)return null;let s=i.root.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===chunk77DD4EBC_cjs.da&&C.localName==="num"&&It(C,"numId")===e),d=s&&St(s,"abstractNumId");if(!s||!d)return null;let p=i.root.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===chunk77DD4EBC_cjs.da&&C.localName==="abstractNum"&&It(C,"abstractNumId")===It(d,"val"));if(!p||St(p,"numStyleLink"))return null;let u=s.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===chunk77DD4EBC_cjs.da&&C.localName==="lvlOverride"&&It(C,"ilvl")===String(n)),m=(u&&St(u,"lvl"))??p.children.find(C=>C.kind!=="textValue"&&C.namespaceUri===chunk77DD4EBC_cjs.da&&C.localName==="lvl"&&It(C,"ilvl")===String(n));if(m&&St(m,"lvlPicBulletId"))return null;let A=chunk77DD4EBC_cjs.Ea(i),g=C=>C.kind==="textValue"?{...C,id:A()}:{...C,id:A(),children:C.children.map(g)},x=C=>{let D=chunk77DD4EBC_cjs.xa(`<w:numbering xmlns:w="${chunk77DD4EBC_cjs.da}">${C}</w:numbering>`,{name:i.name,contentType:i.contentType}),Z=D.ok?D.part.root.children[0]:void 0;return Z&&Z.kind!=="textValue"?g(Z):null};if(m??=x(`<w:lvl w:ilvl="${n}"><w:start w:val="1"/><w:numFmt w:val="decimal"/><w:lvlText w:val="%${n+1}."/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="${720*(n+1)}" w:hanging="360"/></w:pPr></w:lvl>`)??void 0,!m)return null;let k=[...m.children],b=["start","numFmt","lvlRestart","pStyle","isLgl","suff","lvlText","lvlPicBulletId","legacy","lvlJc","pPr","rPr"],v=(C,D)=>{let Z=x(D);if(!Z)return false;let et=k.findIndex(_=>_.kind!=="textValue"&&_.namespaceUri===chunk77DD4EBC_cjs.da&&_.localName===C);if(et>=0){let _=k[et];k.splice(et,1,{..._,attributes:[..._.attributes.filter(nt=>!Z.attributes.some(at=>at.namespaceUri===nt.namespaceUri&&at.localName===nt.localName)),...Z.attributes]});}else {let _=k.findIndex(nt=>nt.kind!=="textValue"&&nt.namespaceUri===chunk77DD4EBC_cjs.da&&b.indexOf(nt.localName)>b.indexOf(C));k.splice(_<0?k.length:_,0,Z);}return true};if(r.startingNumber!==void 0&&!v("start",`<w:start w:val="${r.startingNumber}"/>`))return null;if(r.numbering!==void 0){let C=r.formatString?.map(D=>typeof D=="number"?`%${D+1}`:D).join("")??(r.numbering==="None"?"":`%${n+1}.`);if(!v("numFmt",`<w:numFmt w:val="${nr[r.numbering]}"/>`)||!v("lvlText",`<w:lvlText w:val="${Me(C)}"/>`))return null}if(r.numbering!==void 0&&(k=k.map(C=>C.kind!=="textValue"&&C.namespaceUri===chunk77DD4EBC_cjs.da&&C.localName==="rPr"?{...C,children:C.children.filter(D=>D.kind==="textValue"||D.namespaceUri!==chunk77DD4EBC_cjs.da||D.localName!=="rFonts")}:C)),r.bullet!==void 0){let[C,D]=r.bullet==="Custom"?[String.fromCharCode(r.charCode),r.fontName??"Symbol"]:or[r.bullet];if(!v("numFmt",'<w:numFmt w:val="bullet"/>')||!v("lvlText",`<w:lvlText w:val="${Me(C)}"/>`))return null;let Z=St(m,"rPr"),et=x(`<w:rFonts w:ascii="${Me(D)}" w:hAnsi="${Me(D)}"/>`);if(!et)return null;let _=Z?.children.filter(ct=>ct.kind==="textValue"||ct.namespaceUri!==chunk77DD4EBC_cjs.da||ct.localName!=="rFonts")??[],nt=Z?{...Z,children:[et,..._]}:x("<w:rPr/>");if(!nt)return null;let at=k.findIndex(ct=>ct.kind!=="textValue"&&ct.namespaceUri===chunk77DD4EBC_cjs.da&&ct.localName==="rPr");at<0?k.push({...nt,children:[et,..._]}):k[at]={...nt,children:[et,..._]};}if(r.textIndent!==void 0||r.bulletNumberPictureIndent!==void 0){let C=St(m,"pPr"),D=C&&St(C,"ind"),Z=D?.attributes.filter(Q=>Q.namespaceUri!==chunk77DD4EBC_cjs.da||!["left","start","firstLine","hanging"].includes(Q.localName))??[],et=r.textIndent===void 0?It(D??m,"left")??"0":String(Math.round(r.textIndent*20)),_=r.bulletNumberPictureIndent,nt=_===void 0?D?.attributes.filter(Q=>Q.namespaceUri===chunk77DD4EBC_cjs.da&&["firstLine","hanging"].includes(Q.localName))??[]:[],at=x(`<w:ind w:left="${et}"${_===void 0?"":` w:${_<0?"hanging":"firstLine"}="${Math.abs(Math.round(_*20))}"`}/>`);if(!at)return null;let ct={...at,attributes:[...Z,...nt,...at.attributes]},Mt=C?.children.filter(Q=>Q.kind==="textValue"||Q.namespaceUri!==chunk77DD4EBC_cjs.da||Q.localName!=="ind")??[],Et=C??x("<w:pPr/>");if(!Et)return null;let ee=D?C.children.indexOf(D):-1,V=[...Mt],Pt=["contextualSpacing","mirrorIndents","suppressOverlap","jc","textDirection","textAlignment","textboxTightWrap","outlineLvl","divId","cnfStyle","rPr","sectPr","pPrChange"],ht=V.findIndex(Q=>Q.kind!=="textValue"&&Q.namespaceUri===chunk77DD4EBC_cjs.da&&Pt.includes(Q.localName));V.splice(ee>=0?ee:ht>=0?ht:V.length,0,ct);let q={...Et,children:V},gt=k.findIndex(Q=>Q.kind!=="textValue"&&Q.namespaceUri===chunk77DD4EBC_cjs.da&&Q.localName==="pPr");if(gt>=0)k[gt]=q;else {let Q=k.findIndex(Ot=>Ot.kind!=="textValue"&&Ot.localName==="rPr"&&Ot.namespaceUri===chunk77DD4EBC_cjs.da);k.splice(Q<0?k.length:Q,0,q);}}let S=g({...m,children:k}),w=u?.children.filter(C=>C.kind==="textValue"||C.namespaceUri!==chunk77DD4EBC_cjs.da||C.localName!=="lvl"&&(r.startingNumber===void 0||C.localName!=="startOverride"))??[],H=u??x(`<w:lvlOverride w:ilvl="${n}"/>`);if(!H)return null;let E={...H,children:[...w,S]},j=[...s.children],F=u?j.indexOf(u):-1;F>=0?j[F]=E:j.push(E);let K=chunk77DD4EBC_cjs.La(i,s.id,{...s,children:j});return K.ok?chunk77DD4EBC_cjs.fc(t,K.part):null}var qt=8;function rr(t){if(!t||t.kind==="textValue")return null;for(let e of t.attributes)if(e.namespaceUri===chunk77DD4EBC_cjs.da&&e.localName==="val")return e.value;return null}function De(t){let e=chunk77DD4EBC_cjs.Le(chunk77DD4EBC_cjs.Je(t),"numPr");if(!e)return null;let n=rr(chunk77DD4EBC_cjs.Le(e,"numId"));if(n===null||!/^\d{1,10}$/.test(n)||n==="0")return null;let r=rr(chunk77DD4EBC_cjs.Le(e,"ilvl")),i=r===null?0:Number(r);return !Number.isInteger(i)||i<0||i>qt?null:{numId:n,level:i}}function zt(t){let e=new Map;for(let n of t.paragraphIds){let r=t.node(n);if(!r)continue;let i=De(r);if(!i)continue;let s=e.get(i.numId);s?s.push(n):e.set(i.numId,[n]);}return Object.freeze([...e].map(([n,r])=>Object.freeze({numId:n,paragraphIds:Object.freeze(r)})))}function pe(t,e){let n=t.node(e);return n?De(n):null}var mt=t=>({ok:false,error:{code:"unsupported-content",message:t}});function La(t,e){if(t.root.namespaceUri!==chunk77DD4EBC_cjs.da||t.root.localName!=="styles")return false;let n=[t.root];for(;n.length;){let r=n.pop();if(r.kind!=="textValue"){if(r.namespaceUri===chunk77DD4EBC_cjs.da&&r.localName==="numId"&&r.attributes.some(i=>i.namespaceUri===chunk77DD4EBC_cjs.da&&i.localName==="val"&&i.value===e))return true;for(let i of r.children)n.push(i);}}return false}function ar(t,e,n,r){let i=n.package;if(!i)return mt("no document");if(t.op==="setListLevelFormat"){let x=e.resolve(t.list,"list");if(!x||x.kind!=="list")return mt("that is not a list");let k=n.story(x.story),b=k&&zt(k).find(v=>v.numId===x.numId);if(!k||!b)return mt("that list no longer exists");if(!dn(t.level,t.format))return mt("invalid list level format");for(let v of i.parts.values()){if(La(v,x.numId))return mt("list is referenced by a style");for(let S of chunk77DD4EBC_cjs.xd(v))for(let w of chunk77DD4EBC_cjs.Ad(S.root))if(De(w)?.numId===x.numId&&!k.has(w.id))return mt("list is shared across stories")}for(let v of b.paragraphIds){if(chunk77DD4EBC_cjs.Fe(k.part,v).content||chunk77DD4EBC_cjs.He(k.part,v))return mt("list contains protected content");let S=r(k,v,{numId:x.numId,level:t.level});if(S)return S}return je(i,x.numId,t.level,t.format)?{ok:true,kind:"command",story:k.story,ops:[],packageEdits:[v=>{let S=je(v,x.numId,t.level,t.format);if(!S)throw new Error("list definition changed during transaction");return S}],answer:()=>({kind:"applied"})}:mt("cannot format this list")}let s=pt(t.paragraph,e,n);if(!s.ok)return {ok:false,error:{code:s.code,message:s.detail}};let d=n.story(s.value.story);if(!d)return mt("missing story");let p=r(d,s.value.paragraphId);if(p)return p;let u=null,m=0,A=[];if(t.op==="startNewList"){let x=ln(i);if(!x)return mt("cannot create numbering definition");let k=s.value.paragraphId;if(!chunk77DD4EBC_cjs.fi(d.part,{op:"setListNumbering",paragraphId:k,numId:x.numId,level:0}).ok)return mt("cannot number this paragraph");let v=x.numId;return {ok:true,kind:"command",story:d.story,ops:[],packageEdits:[S=>{let w=ln(S),H=w?.pkg.parts.get(d.part.name);if(!w||!H)throw new Error("cannot create numbering definition");let E=chunk77DD4EBC_cjs.fi(H,{op:"setListNumbering",paragraphId:k,numId:w.numId,level:0});if(!E.ok)throw new Error("cannot number this paragraph");return v=w.numId,chunk77DD4EBC_cjs.fc(w.pkg,E.part)}],answer:()=>({kind:"handle",handle:e.list(v,d.story)})}}else if(t.op==="attachToList"){if(!Number.isSafeInteger(t.listId)||t.listId<=0||!Number.isInteger(t.level)||t.level<0||t.level>8)return mt("invalid list identity or level");if(u=String(t.listId),m=t.level,!ce(i,u,m))return mt("list level is not defined; configure that level first");if(!zt(d).some(x=>x.numId===u))return mt("that list does not exist in this story")}let g=u;return {ok:true,kind:"command",story:d.story,ops:[{op:"setListNumbering",paragraphId:s.value.paragraphId,numId:t.op==="detachFromList"?"0":u,level:m}],packageEdits:A,answer:()=>g===null?{kind:"applied"}:{kind:"handle",handle:e.list(g,d.story)}}}var un=Object.freeze({None:"none",Single:"single",Word:"words",Double:"double",Thick:"thick",Dotted:"dotted",DottedHeavy:"dottedHeavy",DashLine:"dash",DashLineHeavy:"dashedHeavy",DashLineLong:"dashLong",DashLineLongHeavy:"dashLongHeavy",DotDashLine:"dotDash",DotDashLineHeavy:"dashDotHeavy",TwoDotDashLine:"dotDotDash",TwoDotDashLineHeavy:"dashDotDotHeavy",Wave:"wave",WaveHeavy:"wavyHeavy",WaveDouble:"wavyDouble"}),ir=[["Yellow","yellow","#FFFF00"],["Lime","green","#00FF00"],["Turquoise","cyan","#00FFFF"],["Pink","magenta","#FF00FF"],["Blue","blue","#0000FF"],["Red","red","#FF0000"],["DarkBlue","darkBlue","#000080"],["Teal","darkCyan","#008080"],["Green","darkGreen","#008000"],["Purple","darkMagenta","#800080"],["DarkRed","darkRed","#800000"],["Olive","darkYellow","#808000"],["Gray","darkGray","#808080"],["LightGray","lightGray","#C0C0C0"],["Black","black","#000000"],["White","white","#FFFFFF"]];function sr(t){return Object.entries(un).find(([,e])=>e===t)?.[0]??null}function lr(t){return ir.find(([,e])=>e===t)?.[2]??null}function dr(t){let e=[];if(t.underline!==void 0){let n=typeof t.underline=="string"&&Object.hasOwn(un,t.underline)?un[t.underline]:void 0;if(!n)return {ok:false,detail:"underline: unsupported underline style"};e.push({localName:"u",attributes:{val:n}});}if(t.strikeThrough!==void 0){if(typeof t.strikeThrough!="boolean")return {ok:false,detail:"strikeThrough: not a boolean"};e.push({localName:"strike",attributes:{val:t.strikeThrough?"1":"0"}});}for(let n of ["subscript","superscript"])if(t[n]!==void 0&&typeof t[n]!="boolean")return {ok:false,detail:`${n}: not a boolean`};if(t.subscript===true&&t.superscript===true)return {ok:false,detail:"subscript and superscript are mutually exclusive"};if(t.highlightColor!==void 0){let n=t.highlightColor,r=typeof n=="string"?ir.find(([i,,s])=>i.toLowerCase()===n.toLowerCase()||s===n.toUpperCase()):void 0;if(n!==null&&!r)return {ok:false,detail:"highlightColor: use an exact Word palette color or null to clear"};e.push({localName:"highlight",attributes:{val:r?.[1]??"none"}});}return {ok:true,value:e}}var Ha=31680,Fa=1999,Ma=Object.freeze({bold:null,italic:null,underline:null,strikeThrough:null,highlightColor:null,subscript:null,superscript:null,name:null,size:null,color:null});function st(t,e){if(!t)return null;for(let n of t.attributes)if(n.localName===e)return n.value;return null}function _e(t){if(!t)return null;let e=st(t,"val");if(e===null)return true;let n=e.trim().toLowerCase();return !(n==="0"||n==="false"||n==="off"||n==="none")}function ja(t){if(t===null)return null;let e=t.trim();return /^[0-9a-fA-F]{6}$/.test(e)?`#${e.toUpperCase()}`:null}function Da(t){if(t===null)return null;let e=Number(t.trim());return !Number.isFinite(e)||e<=0?null:e/2}function Kt(t){if(t===null)return null;let e=Number(t.trim());return Number.isFinite(e)?chunk77DD4EBC_cjs.Ze(chunk77DD4EBC_cjs.Xe(e)):null}function Ct(t){if(t.length===0)return null;let e=t[0];if(e===null)return null;for(let n of t)if(n!==e)return null;return e}function pr(t,e,n=chunkMDP5SNK4_cjs.ja){let r=[];for(let i of e)for(let s of chunkMDP5SNK4_cjs.Ba(t,i.paragraphId,i.start,i.end,n))r.push(chunk77DD4EBC_cjs.Ke(s));return r.length===0?Ma:{bold:Ct(r.map(i=>_e(chunk77DD4EBC_cjs.Le(i,"b")))),italic:Ct(r.map(i=>_e(chunk77DD4EBC_cjs.Le(i,"i")))),underline:Ct(r.map(i=>sr(st(chunk77DD4EBC_cjs.Le(i,"u"),"val")))),strikeThrough:Ct(r.map(i=>_e(chunk77DD4EBC_cjs.Le(i,"strike")))),highlightColor:Ct(r.map(i=>lr(st(chunk77DD4EBC_cjs.Le(i,"highlight"),"val")))),subscript:Ct(r.map(i=>cr(i,"subscript"))),superscript:Ct(r.map(i=>cr(i,"superscript"))),name:Ct(r.map(i=>{let s=chunk77DD4EBC_cjs.Le(i,"rFonts"),d=st(s,"ascii");return d===null||d.length===0?null:d})),size:Ct(r.map(i=>Da(st(chunk77DD4EBC_cjs.Le(i,"sz"),"val")))),color:Ct(r.map(i=>ja(st(chunk77DD4EBC_cjs.Le(i,"color"),"val"))))}}var Ba=Object.freeze({left:"Left",start:"Left",center:"Centered",right:"Right",end:"Right",both:"Justified",distribute:"Justified"}),_a=Object.freeze({Left:"left",Centered:"center",Right:"right",Justified:"both"});function Va(t){let e=st(chunk77DD4EBC_cjs.Le(t,"jc"),"val");return e===null?"Unknown":Ba[e.trim().toLowerCase()]??"Unknown"}function mr(t,e,n){let r=chunk77DD4EBC_cjs.Ga(t,e);if(!r||r.kind!=="paragraph")return null;let i=chunk77DD4EBC_cjs.Je(r),s=chunk77DD4EBC_cjs.Le(i,"spacing"),d=chunk77DD4EBC_cjs.Le(i,"ind");return {alignment:Va(i),style:Ce(t,e,n),firstLineIndent:Wa(d),leftIndent:Kt(st(d,"left")??st(d,"start")),rightIndent:Kt(st(d,"right")??st(d,"end")),lineSpacing:Kt(st(s,"line")),spaceBefore:Kt(st(s,"before")),spaceAfter:Kt(st(s,"after")),widowControl:_e(chunk77DD4EBC_cjs.Le(i,"widowControl"))}}function Wa(t){let e=Kt(st(t,"hanging"));if(e!==null&&e>0)return -e;let n=Kt(st(t,"firstLine"));return n!==null?n:e===null?null:-e}function Be(t,e){if(typeof t!="number"||!Number.isFinite(t))return {ok:false,detail:`${e}: not a measurement`};let n=chunk77DD4EBC_cjs._e(chunk77DD4EBC_cjs.Ye(t));return Math.abs(n)>Ha?{ok:false,detail:`${e}: out of range`}:{ok:true,value:n}}function fr(t){let e=dr(t);if(!e.ok)return e;let n=e.value;if(t.bold!==void 0){if(typeof t.bold!="boolean")return {ok:false,detail:"bold: not a boolean"};n.push({localName:"b",...t.bold?{}:{attributes:{val:"0"}}});}if(t.italic!==void 0){if(typeof t.italic!="boolean")return {ok:false,detail:"italic: not a boolean"};n.push({localName:"i",...t.italic?{}:{attributes:{val:"0"}}});}if(t.name!==void 0){let r=t.name;if(typeof r!="string"||r.length===0||r.length>128)return {ok:false,detail:"name: not a font name"};if(!chunk77DD4EBC_cjs.O(r))return {ok:false,detail:"name: not valid XML text"};n.push({localName:"rFonts",attributes:{ascii:r,hAnsi:r}});}if(t.size!==void 0){let r=t.size;if(typeof r!="number"||!Number.isFinite(r)||r<=0)return {ok:false,detail:"size: not a positive number of points"};let i=Math.round(r*2);if(i<1||i>Fa)return {ok:false,detail:"size: out of range"};n.push({localName:"sz",attributes:{val:String(i)}}),n.push({localName:"szCs",attributes:{val:String(i)}});}if(t.color!==void 0){let r=t.color;if(typeof r!="string"||!/^#[0-9a-fA-F]{6}$/.test(r.trim()))return {ok:false,detail:"color: not a #RRGGBB triplet"};n.push({localName:"color",attributes:{val:r.trim().slice(1).toUpperCase()}});}return n.length===0&&t.subscript===void 0&&t.superscript===void 0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:n}}function gr(t,e,n,r){let i=chunk77DD4EBC_cjs.Ga(t,e);if(!i||i.kind!=="paragraph")return {ok:false,detail:"not a paragraph"};let s=chunk77DD4EBC_cjs.Je(i),d=[];if(n.style!==void 0){let k=we(n.style,r);if(!k.ok)return {ok:false,detail:k.detail};d.push({localName:"pStyle",attributes:{val:k.styleId}});}if(n.alignment!==void 0){let k=_a[n.alignment];if(k===void 0)return {ok:false,detail:`alignment: ${String(n.alignment)}`};d.push({localName:"jc",attributes:{val:k}});}let p=chunk77DD4EBC_cjs.Le(s,"ind"),u=ur(p),m=false;if(n.firstLineIndent!==void 0){let k=Be(n.firstLineIndent,"firstLineIndent");if(!k.ok)return k;delete u.firstLine,delete u.hanging,k.value<0?u.hanging=String(-k.value):u.firstLine=String(k.value),m=true;}for(let[k,b,v]of [["leftIndent","left","start"],["rightIndent","right","end"]]){let S=n[k];if(S===void 0)continue;let w=Be(S,k);if(!w.ok)return w;delete u[v],u[b]=String(w.value),m=true;}m&&d.push({localName:"ind",attributes:u});let A=chunk77DD4EBC_cjs.Le(s,"spacing"),g=ur(A),x=false;for(let[k,b]of [["spaceBefore","before"],["spaceAfter","after"]]){let v=n[k];if(v===void 0)continue;let S=Be(v,k);if(!S.ok)return S;if(S.value<0)return {ok:false,detail:`${k}: out of range`};g[b]=String(S.value),x=true;}if(n.lineSpacing!==void 0){let k=Be(n.lineSpacing,"lineSpacing");if(!k.ok)return k;if(k.value<=0)return {ok:false,detail:"lineSpacing: out of range"};g.line=String(k.value),g.lineRule??="auto",x=true;}if(x&&d.push({localName:"spacing",attributes:g}),n.widowControl!==void 0){if(typeof n.widowControl!="boolean")return {ok:false,detail:"widowControl: not a boolean"};d.push({localName:"widowControl",...n.widowControl?{}:{attributes:{val:"0"}}});}return d.length===0?{ok:false,detail:"no formatting was asked for"}:{ok:true,value:chunkMDP5SNK4_cjs.ta(chunkMDP5SNK4_cjs.ra(t,e),d)}}function ur(t){let e=Object.create(null);if(!t)return e;for(let n of t.attributes)e[n.localName]=n.value;return e}function cn(t,e){if(e.subscript===void 0&&e.superscript===void 0)return [...t];let n=t.find(i=>i.localName==="vertAlign")?.attributes?.val,r=e.subscript===true?"subscript":e.superscript===true?"superscript":n==="subscript"&&e.subscript===false||n==="superscript"&&e.superscript===false?"baseline":n??"baseline";return chunkMDP5SNK4_cjs.ta(t,[{localName:"vertAlign",attributes:{val:r}}])}function cr(t,e){let n=st(chunk77DD4EBC_cjs.Le(t,"vertAlign"),"val");return n===null?null:n===e}function yr(){let t=false,e=false,n=false,r=false;return {conflict(i){let s=Wt(i),d=nn(i),p=i.op==="deleteComment",u=i.op==="updateFieldResult";return s&&(u&&t&&!r||r&&!u)?{message:"field result updates require a batch without other edits; sync document edits before updating fields",detail:i.op}:d&&t||e&&s?{message:"that command commits on its own and cannot share a batch",detail:i.op}:p&&t&&!n||n&&s&&!p?{message:"comment deletions may share a batch only with other comment deletions",detail:i.op}:null},note(i){Wt(i)&&(t=true,nn(i)&&(e=true),i.op==="deleteComment"&&(n=true),i.op==="updateFieldResult"&&(r=true));},get hasCommands(){return t}}}var Ua=256,hr=1e4;function pn(t,e){if(t.kind!=="textValue"){for(let n of t.attributes)if(n.namespaceUri===chunk77DD4EBC_cjs.da&&n.localName===e)return n.value}}function $a(t){return t.startsWith("_")}function mn(t){let e=new Map,n=[],r=new Set;for(let i of t.paragraphIds){let s=t.node(i);if(s?.kind!=="paragraph")continue;let d=chunk77DD4EBC_cjs.Pe(s),p=u=>{if(u.kind!=="textValue"){if(u.kind==="bookmarkStart"){if(n.length>=hr||e.size>=hr)return;let m=pn(u,"id"),A=pn(u,"name");if(m===void 0||A===void 0||A.length===0||A.length>Ua||$a(A)||r.has(A)||e.has(m))return;let g=d.spanOf(u)?.start??0;e.set(m,{name:A,start:{paragraphId:i,offset:g}});return}if(u.kind==="bookmarkEnd"){let m=pn(u,"id");if(m===void 0)return;let A=e.get(m);if(!A)return;e.delete(m),r.add(A.name);let g=d.spanOf(u)?.start??0;n.push(Object.freeze({name:A.name,start:A.start,end:{paragraphId:i,offset:g}}));return}for(let m of u.children)p(m);}};for(let u of s.children)p(u);}return Object.freeze(n)}function fn(t,e){return mn(t).find(n=>n.name===e)??null}function kr(t,e){let n=t.node(e);if(n?.kind!=="paragraph")return Object.freeze([]);let r=chunk77DD4EBC_cjs.Pe(n),i=[],s=(d,p)=>{if(!(d.kind==="textValue"||p>32)){if(chunk77DD4EBC_cjs.Ya(d)){let u=r.spanOf(d);u&&i.push(Object.freeze({id:d.id,paragraphId:e,start:u.start,end:u.end}));return}for(let u of d.children)s(u,p+1);}};for(let d of n.children)s(d,0);return Object.freeze(i)}function br(t,e,n){let r=chunk77DD4EBC_cjs.$a(n,i=>chunk77DD4EBC_cjs.rf(t,e,i));if(r.kind==="external")return r.href;if(r.kind==="internal"){let i=chunk77DD4EBC_cjs.Za(n);return i===void 0||i.length===0?null:`#${i}`}return null}function xr(t,e,n,r,i){let s=Math.min(i?.limit??2e3,2e3),d=[],p=At(e,t),u=p.length-1;for(let[m,A]of p.entries()){if(s<=0)break;let g=t.projectedText(A,i?.projection??"allMarkup");if(!g)continue;let x=g.findOccurrences(r,s,{matchCase:i?.matchCase===true,wholeWord:i?.matchWholeWord===true,...m===0&&e?{from:g.projectedOffset(e.start.offset)}:{},...m===u&&e?{to:g.projectedOffset(e.end.offset)}:{}});for(let k of x.matches){if(m===0&&e&&k.rawStart<e.start.offset||m===u&&e&&k.rawEnd>e.end.offset)continue;let b=n.paragraph(A,t.story);d.push({start:{paragraph:b,offset:k.rawStart},end:{paragraph:b,offset:k.rawEnd}}),s-=1;}}return {ok:true,spans:d}}var za={insert:"Insert",delete:"Delete",replace:"Replace",moveFrom:"MovedFrom",moveTo:"MovedTo",format:"Property",paragraphMark:"ParagraphProperty"};function Ka(t){return t.kind==="note"}function Ga(t,e){return e.length===0?!Ka(t.story):e.every(n=>t.has(n.start.paragraphId))}function Xa(t){return Object.freeze(chunkMDP5SNK4_cjs.Oa(t.part).filter(e=>Ga(t,e.ranges)))}function gn(t){let e=[];for(let n of Xa(t)){if(n.readOnly||n.revisionKind==="structural")continue;let r=za[n.revisionKind];r!==void 0&&e.push(Object.freeze({id:n.id,type:r,author:n.author,date:n.date??"",item:n}));}return Object.freeze(e)}function Ya(t,e){let n=t;for(let r=0;n!==void 0&&r<=64;r+=1){if(n.parentId===void 0)return n.range!==null;n=e.get(n.parentId);}return false}var Ja=Object.freeze({items:Object.freeze([]),roots:Object.freeze([]),byId:()=>null,textOf:()=>""});function Ar(t,e){let n=t.parts.get(chunkMDP5SNK4_cjs.X(t,e.part.name));if(!n)return Ja;let r=t.parts.get(chunkMDP5SNK4_cjs.Y(t,e.part.name)),i=chunk77DD4EBC_cjs.pg(n),s=r?chunk77DD4EBC_cjs.qg(r):new Map,d=chunk77DD4EBC_cjs.ng(e.part).filter(g=>e.has(g.start.paragraphId)),p=chunkMDP5SNK4_cjs.Pa(i,d,s),u=new Map(p.map(g=>[g.id,g])),m=p.filter(g=>Ya(g,u)),A=new Map(m.map(g=>[g.id,g]));return Object.freeze({items:Object.freeze(m),roots:Object.freeze(m.filter(g=>g.parentId===void 0)),byId:g=>A.get(g)??null,textOf:g=>{let x=A.get(g);return x?chunkMDP5SNK4_cjs.Ca(x.comment):""}})}var Qa=/[\r\n\v\f\u2028\u2029]/;function Ve(t,e,n){return {code:t,message:e,detail:n}}function vr(t,e=false){if(typeof t.author!="string"||!t.author.trim()||!chunk77DD4EBC_cjs.O(t.author))return Ve("unsupported-content","proposals need a non-empty XML-safe author","author");let n=t.op==="proposeInsertion";return !(t.op==="proposeDeletion")&&(typeof t.text!="string"||!e&&!t.text.length||Qa.test(t.text)||!chunk77DD4EBC_cjs.O(t.text))?Ve("unsupported-content","proposals need non-empty inline XML-safe text","text"):n&&t.where!=="Before"&&t.where!=="After"?Ve("unsupported-content","insertion needs Before or After","where"):null}function Ir(t,e,n,r){let i=chunkMDP5SNK4_cjs.Oa(t.part),s=new Set;if(i.some(p=>p.revisionKind==="structural"))for(let p=chunk77DD4EBC_cjs.Ha(t.part,e);p!==null&&(s.add(p.id),p.id!==t.root.id);p=chunk77DD4EBC_cjs.Ha(t.part,p.id));return i.some(p=>{if(p.revisionKind==="structural"){let u=chunkMDP5SNK4_cjs.Ea(p),m=0;for(let A of u){let g=chunk77DD4EBC_cjs.Ha(t.part,A),x=g&&chunk77DD4EBC_cjs.Ha(t.part,g.id),k=x?.kind==="tableRow"?"trPr":x?.kind==="tableCell"?"tcPr":null;if(!(!x||!k||chunk77DD4EBC_cjs.Le(x,k)?.id!==g?.id)){if(s.has(x.id))return true;m+=1;}}if(u.length>0&&m===u.length)return false}return p.ranges.some(u=>{let m=t.indexOf(u.start.paragraphId),A=t.indexOf(u.end.paragraphId),g=t.indexOf(e);if(m<0||A<0||g<m||g>A)return false;let x=g===m?u.start.offset:0,k=g===A?u.end.offset:1/0;return n<=k&&r>=x})})?Ve("unsupported-revision","proposal touches or overlaps a pending revision","span"):null}function Pr(t,e,n,r,i){let s=(F,K,C)=>({ok:false,error:{code:F,message:K,...C===void 0?{}:{detail:C}}}),d=F=>Nt(F,n),p=F=>({ok:true,kind:"query",value:F}),u=vr(t,e);if(u)return {ok:false,error:u};let m=t.op==="proposeInsertion",A=t.op==="proposeDeletion",g=z(t.span,n,r);if(!g.ok)return s(g.code,"that span is not a place",g.detail);let x=g.value;if(!x||x.start.paragraphId!==x.end.paragraphId)return s("unsupported-content","proposals require a single paragraph range","span");if(!e&&!m&&x.start.offset===x.end.offset)return s("unsupported-content","deletion and replacement need a non-empty range","span");let k=ot(t.span,n,r);if(!k.ok)return s(k.code,"that story is not a place",k.detail);let b=x.start.paragraphId,v=m&&t.where==="After"?x.end.offset:x.start.offset,S=m?v:x.end.offset;if(e&&!A&&v===S&&t.text==="")return p({kind:"span",span:d({start:x.start,end:x.start})});let w=Ir(k.value,b,v,S);if(w)return {ok:false,error:w};let H=i(k.value,b);if(H)return H;let E={author:t.author.trim(),date:new Date().toISOString()},j=[];return !m&&S>v&&j.push({op:"deleteText",paragraphId:b,start:v,end:S,revision:E}),!A&&t.text.length>0&&j.push({op:"insertText",paragraphId:b,offset:m?v:S,text:t.text,revision:E}),{ok:true,kind:"command",ops:j,story:k.value.story,answer:()=>{if(!e)return {kind:"applied"};let F={...x.start,offset:m?v:S};return {kind:"span",span:d({start:F,end:{...F,offset:F.offset+(A?0:t.text.length)}})}}}}function Or(t,e,n){if("body"in t){let r=rt(t.body,"body",e,n);return r.ok?{ok:true,reads:r.value}:{ok:false,code:r.code,message:"that handle does not name a body",detail:r.detail}}return e.resolve(t.document,"document")?n.body?{ok:true,reads:n.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 Rr(t,e){let n=t.op==="acceptAllRevisions",r=e.story.kind==="note"?{scopeRootId:e.root.id}:{};return [n?{op:"acceptAllRevisions",...r}:{op:"rejectAllRevisions",...r}]}var Za=/[\r\n\u2028\u2029]/u,Cr=Object.freeze({kind:"applied"});function te(t,e,n){return {ok:false,error:Object.freeze(n===void 0?{code:t,message:e}:{code:t,message:e,detail:n})}}function yn(t,e){return te("unsupported-content",t==="author"?"a comment records who wrote it":t==="date"?"a comment date must be a valid ISO-8601 instant":e==="reply"?"a reply says something":"a comment says something",t)}function hn(t){return chunkMDP5SNK4_cjs.P(t.author)?yn("author",t.kind):chunkMDP5SNK4_cjs.Q(t.text)?yn("text",t.kind):typeof t.text=="string"&&Za.test(t.text)?te("unsupported-content",t.kind==="reply"?"a reply is one paragraph in this slice":"a comment is one paragraph in this slice","text"):chunkMDP5SNK4_cjs.S(t.date)?yn("date",t.kind):null}function kn(t){if(t===void 0)return;let e=chunkMDP5SNK4_cjs.R(t);return e.ok?e.value:void 0}function Sr(t,e){let n=chunk77DD4EBC_cjs.Ga(t.part,e);for(;n;){if(n.kind==="tableCell"||n.kind!=="textValue"&&n.namespaceUri===chunk77DD4EBC_cjs.da&&n.localName==="tc")return n.id;n=chunk77DD4EBC_cjs.Ha(t.part,n.id);}return null}function wr(t,e,n,r){let i=hn({author:t.author,text:t.text,date:t.date,kind:"comment"});if(i)return i;let s=z(t.span,e,n);if(!s.ok)return te(s.code,"that span is not a place",s.detail);if(s.value===null)return te("invalid-handle","an empty story has no comment anchor");let d=ot(t.span,e,n);if(!d.ok)return te(d.code,"that span is not a place",d.detail);let p=s.value;if(Sr(d.value,p.start.paragraphId)!==Sr(d.value,p.end.paragraphId))return te("unsupported-content","a comment range cannot cross a table-cell boundary");let u=r(d.value);if(u)return u;let m=kn(t.date);return {ok:true,kind:"commentWrite",write:{kind:"create",anchor:{paragraphId:p.start.paragraphId,start:p.start.offset,end:p.end.offset,...p.end.paragraphId===p.start.paragraphId?{}:{endParagraphId:p.end.paragraphId}},text:t.text,author:t.author,...m===void 0?{}:{date:m}},story:d.value.story,answer:(g,x)=>x===void 0?Cr:{kind:"handle",handle:e.comment(x,d.value.story)}}}function Tr(t,e,n){let r=n(e);if(r)return r;let i=e.story;return {ok:true,kind:"commentWrite",write:{kind:"delete",commentId:t.id,...t.parentId===void 0?{}:{parentCommentId:t.parentId},...i.kind==="note"?{noteId:i.noteId}:{}},story:i,answer:()=>Cr}}var qa=1e4;function Nr(t,e){let n=[],r=e.kind==="contentControl"?chunk77DD4EBC_cjs.Gc(e):e;if(!r)return n;for(let i of chunk77DD4EBC_cjs.Kc(r))if(!(i.ancestors.length>0)){if(n.length>=qa)break;n.push(Mr(t,i.node));}return n}function Er(t,e){for(let n of chunk77DD4EBC_cjs.Kc(t.root))if(n.node.id===e)return Mr(t,n.node);return null}function Lr(t,e){for(let n of chunk77DD4EBC_cjs.Kc(t.root))if(n.node.id===e)return n.node;return null}function Hr(t,e){for(let n of t.paragraphIds){let r=t.node(n);if(!(!r||r.kind!=="paragraph")&&chunk77DD4EBC_cjs.Kc(r).some(i=>i.node.id===e))return r}return null}function We(t,e){let n=jr(e);if(n.length>0){let s=n[0],d=n[n.length-1],p=t.rawText(d);return p===null||!t.has(s)?null:{start:{paragraphId:s,offset:0},end:{paragraphId:d,offset:p.length}}}let r=Hr(t,e.id);if(!r)return null;let i=chunk77DD4EBC_cjs.Pe(r).spanOf(e);return i?{start:{paragraphId:r.id,offset:i.start},end:{paragraphId:r.id,offset:i.end}}:null}function ti(t,e,n){let r=Hr(t,e.id),i=chunk77DD4EBC_cjs.Gc(e);if(!r||!i)return null;let s={...r,children:i.children},d=chunk77DD4EBC_cjs.wh(s);return Te(s,d,n).text}function Fr(t,e,n="allMarkup"){if(n==="allMarkup")return chunk77DD4EBC_cjs.Mc(e);let r=ti(t,e,n);if(r!==null)return r;let i=We(t,e);if(!i)return "";let s=t.indexOf(i.start.paragraphId),d=t.indexOf(i.end.paragraphId);if(s<0||d<s)return "";let p=[];for(let u=s;u<=d;u+=1){let m=t.paragraphIds[u],A=t.projectedText(m,n),g=t.rawText(m);if(!A||g===null)return "";p.push(A.sliceRaw(u===s?i.start.offset:0,u===d?i.end.offset:g.length));}return p.join("\r")}function Mr(t,e){return {nodeId:e.id,properties:chunk77DD4EBC_cjs.Ic(e),lock:chunk77DD4EBC_cjs.Lh(t.part,e.id),paragraphIds:jr(e)}}function jr(t){let e=chunk77DD4EBC_cjs.Gc(t);if(!e)return [];let n=[];return chunk77DD4EBC_cjs.Bd(e.children,n,0),n.map(r=>r.id)}function me(t){let e=t.kind==="contentControl"?chunk77DD4EBC_cjs.Gc(t):t;return e?chunk77DD4EBC_cjs.Kc(e).map(n=>n.node):[]}var Dr=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),Br=new Set(["whole","content","start","end","before","after"]),_r=new Set(["richText","plainText","dropDownList","comboBox","date"]),ei=4096;function Vr(t){let e=(i,s)=>({ok:false,code:"unsupported-content",message:i,detail:s});if(typeof t!="object"||t===null||!("kind"in t))return e("a control value states its kind","value");let n=t,r=n.kind;if(r==="text"||r==="listItem"){let i=r==="text"?n.text:n.value;return typeof i!="string"?e("that value is not a string",String(r)):i.length>ei?e("that value is too long",String(i.length)):{ok:true,value:r==="text"?{kind:"text",text:i}:{kind:"listItem",value:i}}}if(r==="checkbox"){let i=n.checked;return typeof i!="boolean"?e("a checkbox is checked or not","checked"):{ok:true,value:{kind:"checkbox",checked:i}}}if(r==="date"){let i=n.iso;return typeof i!="string"?e("a date is an ISO-8601 string","iso"):i.length>64?e("that is not a date",String(i.length)):{ok:true,value:{kind:"date",iso:i}}}return e("that is not a value any control accepts",String(r))}var ni=new Set(["unlocked","sdtLocked","contentLocked","sdtContentLocked"]),oi=4096,Wr=64;function Ur(t){if(t===void 0)return {ok:true,value:null};if(typeof t!="object"||t===null)return {ok:false,field:"payload"};let e=t;for(let n of ["namespaceUri","rootLocalName","nodeId"]){let r=e[n];if(typeof r!="string"||r.length===0||r.length>oi)return {ok:false,field:n}}return typeof e.label!="string"||e.label.length>chunkMDP5SNK4_cjs.ba?{ok:false,field:"label"}:typeof e.data!="string"||e.data.length===0||e.data.length>chunkMDP5SNK4_cjs.aa?{ok:false,field:"data"}:{ok:true,value:{namespaceUri:e.namespaceUri,rootLocalName:e.rootLocalName,nodeId:e.nodeId,label:e.label,data:e.data}}}function $r(t){let e=t.at!==void 0,n=t.span!==void 0;return e===n?{message:"a custom node goes at a position or over a span, not both",detail:e?"at+span":"no-place"}:typeof t.tag!="string"||t.tag.length===0?{message:"a custom node carries its identity in its tag",detail:"tag"}:t.tag.length>Wr?{message:`w:tag caps at ${String(Wr)} characters; a longer payload belongs in the store`,detail:"tag"}:typeof t.text!="string"||t.text.length===0?{message:"a custom node shows some text",detail:"text"}:t.lock!==void 0&&!ni.has(t.lock)?{message:"that is not a lock",detail:String(t.lock)}:null}function zr(t,e,n,r){return {paragraphId:e.paragraphId,offset:e.offset,...n.offset>e.offset?{replaceUntil:n.offset}:{},tag:t.tag,text:t.text,...t.title===void 0?{}:{alias:t.title},...t.lock===void 0||t.lock==="unlocked"?{}:{lock:t.lock},...r===null?{}:{payload:r}}}function Kr(t,e,n){if(t.span){let i=z(t.span,e,n);return i.ok?i.value?i.value.start.paragraphId!==i.value.end.paragraphId?{code:"unsupported-content",message:"a custom node wraps text inside one paragraph",detail:"multi-paragraph"}:{range:i.value}:{code:"invalid-offset",message:"that story holds nothing to wrap",detail:"empty-story"}:{code:i.code,message:"that span is not a place",detail:i.detail}}let r=Zt(t.at,e,n);return r.ok?{range:{start:r.value,end:r.value}}:{code:r.code,message:"that is not a place",detail:r.detail}}var fe=/[\r\n\v\f\u2028\u2029]/,ri=16,ai=64;function ii(t,e,n){return Object.freeze(n===void 0?{code:t,message:e}:{code:t,message:e,detail:n})}function f(t,e,n){return {ok:false,error:ii(t,e,n)}}var tt=Object.freeze({kind:"applied"});function N(t){return {ok:true,kind:"query",value:t}}function bn(t){let{handles:e,capabilities:n}=t,r=t.reads,i=new Map,s=new Map,d=a=>{let c=`${J(a.story)}:${a.root.id}`,y=i.get(c);if(y)return y;let I=new Map,R=a.paragraphIds.map(l=>{let h={id:l};return I.set(l,h),h}),o={externalCreatedCount:0,reads:a,order:R,slotById:I,created:[],restructured:new Set,touched:new Set,textEdits:new He,formatted:new Set,selected:new Set,retargets:[]};return i.set(c,o),o},p=[],u=yr(),m=false,A=null,g=a=>A===null?(A=a,null):A===a?null:f("conflicting-operations","one batch writes into one story",`${J(A.reads.story)} then ${J(a.reads.story)}`),x=a=>g(d(a)),k=a=>{let c=r.package;return c===null?null:Ar(c,a)},b=a=>{let c=e.resolve(a,"comment");if(!c||c.kind!=="comment")return {ok:false,planned:f("invalid-handle","that handle does not name a comment","comment")};let y=r.story(c.story);if(!y)return {ok:false,planned:f("invalid-handle","that story is not in this document")};let R=k(y)?.byId(c.commentId)??null;return R?{ok:true,reads:y,item:R}:{ok:false,planned:f("invalid-handle","this document no longer holds that comment",c.commentId)}},v=a=>{let c=e.resolve(a,"revision");if(!c||c.kind!=="revision")return {ok:false,planned:f("invalid-handle","that handle does not name a tracked change","revision")};let y=r.story(c.story);if(!y)return {ok:false,planned:f("invalid-handle","that story is not in this document")};let I=gn(y).find(R=>R.id===c.revisionId)??null;return I?{ok:true,reads:y,item:I}:{ok:false,planned:f("invalid-handle","this document no longer holds that tracked change",c.revisionId)}},S=(a,c)=>{let y=a.rawText(c.start.paragraphId),I=a.rawText(c.end.paragraphId);if(y===null||I===null)return null;let R={story:a.story,paragraphId:c.start.paragraphId,index:a.indexOf(c.start.paragraphId),offset:Math.min(c.start.offset,y.length)},o={story:a.story,paragraphId:c.end.paragraphId,index:a.indexOf(c.end.paragraphId),offset:Math.min(c.end.offset,I.length)};return C({start:R,end:o})},w=(a,c)=>a.order.indexOf(c),H=(a,c)=>a.selected.has(c)?f("conflicting-operations","this batch selects a paragraph it also edits",c):null,E=(a,c)=>{let y=H(a,c);return y||(a.restructured.has(c)||a.touched.has(c)?f("conflicting-operations","another operation in this batch already changes that paragraph",c):(a.restructured.add(c),a.touched.add(c),null))},j=(a,c)=>{let y=H(a,c);return y||(a.restructured.has(c)||a.textEdits.has(c)?f("conflicting-operations","another operation in this batch restructures that paragraph",c):(a.touched.add(c),null))},F=(a,c,y)=>{let I=`${y}:${c}`;if(a.formatted.has(I))return f("conflicting-operations","another operation in this batch already writes that formatting",c);let R=j(a,c);return R||(a.formatted.add(I),null)},K=(a,c)=>{let y={id:null};return a.order.splice(c,0,y),a.created.push(y),y},C=a=>Nt(a,e),D=a=>a===null?null:r.story(a.start.story),Z=a=>a===void 0||a==="allMarkup"||a==="original"||a==="model",et=(a,c,y,I)=>{if(!Z(I?.projection))return f("unsupported-content","unknown text projection","projection");if(I?.matchWildcards===true)return f("unsupported-capability","wildcard search is not implemented","matchWildcards");if(I?.ignorePunct===true)return f("unsupported-capability","ignoring punctuation is not implemented","ignorePunct");if(I?.ignoreSpace===true)return f("unsupported-capability","ignoring whitespace is not implemented","ignoreSpace");if(!chunkMDP5SNK4_cjs.Xa(y))return f("unsupported-content","that is not a query this host will scan for","text");let R=I?.limit;if(R!==void 0&&(!Number.isInteger(R)||R<0))return f("invalid-offset","limit must be a non-negative integer",String(R));let o=xr(a,c,e,y,I);return N({kind:"spans",spans:o.spans})},_=(a,c,y,I=false)=>{let R=c.start.paragraphId,o=a.textEdits.has(R)?H(a,R):a.touched.has(R)?f("conflicting-operations","text edits cannot share a paragraph with other edits",R):j(a,R);return o||Ho(a.textEdits,c,y,e,I)},nt=(a,c,y,I=false)=>{if(typeof y!="string"||fe.test(y))return f("unsupported-content","insertText needs text without paragraph marks","text");let R=g(a);if(R)return R;let o=t.replacementLanding?.(c.paragraphId,c.offset,c.offset)!=null,l=!o&&Lo(a.reads.part,c.paragraphId,c.offset,y);if(l)return l;if(!o&&an(a.reads.part,c.paragraphId,c.offset))return _(a,{start:c,end:c},y,I);let h=E(a,c.paragraphId);return h||{ok:true,kind:"command",ops:y.length?[{op:"insertText",paragraphId:c.paragraphId,offset:c.offset,text:y}]:[],story:a.reads.story,answer:()=>({kind:"span",span:C({start:c,end:{...c,offset:c.offset+y.length}})})}},at=(a,c,y)=>{let I=a.reads;if(typeof y!="string")return f("unsupported-content","replaceSpan needs text","text");if(fe.test(y))return f("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let R=At(c,I),o=c.start.paragraphId,l=[],h=g(a);if(h)return h;let P=R.length===1?c.end.offset:(I.rawText(o)??"").length,O=t.replacementLanding?.(o,c.start.offset,P);if(R.length===1&&O==null&&an(I.part,o,c.start.offset))return _(a,c,y);if(R.length===1){let G=E(a,o);if(G)return G;if(O==null)return Mo(I.part,c,y,e);c.end.offset>c.start.offset&&l.push({op:"deleteText",paragraphId:o,start:c.start.offset,end:c.end.offset});}else {for(let M of R){let B=E(a,M);if(B)return B}let G=c.end.paragraphId,U=(I.rawText(o)??"").length;c.start.offset<U&&l.push({op:"deleteText",paragraphId:o,start:c.start.offset,end:U}),c.end.offset>0&&l.push({op:"deleteText",paragraphId:G,start:0,end:c.end.offset});for(let M of R.slice(1,-1))l.push({op:"deleteBlock",blockId:M});l.push({op:"joinParagraphs",firstId:o,secondId:G});for(let M of R.slice(1)){let B=a.slotById.get(M);B&&a.order.splice(w(a,B),1);}}let T=O??c.start.offset;y.length>0&&l.push({op:"insertText",paragraphId:o,offset:T,text:y});let L={...c.start,paragraphId:o,offset:T},$=()=>({kind:"span",span:C({start:L,end:{...L,offset:L.offset+y.length}})});return {ok:true,kind:"command",ops:l,story:a.reads.story,answer:$}},ct=(a,c)=>{let y=a.reads;if(typeof c!="string")return f("unsupported-content","replaceSpan needs text","text");if(fe.test(c))return f("unsupported-content","text carrying a paragraph mark is not written by this host","paragraph-mark-in-text");let I=y.blocks,R=I.filter(M=>M.removable),o=I.filter(M=>!M.removable).flatMap(M=>M.paragraphIds),l=o.length===0?R.find(M=>M.kind==="paragraph"):void 0;if(!l&&o.length===0)return f("invalid-offset","that story holds no paragraph this host can write into","no-top-level-paragraph");let h=g(a);if(h)return h;for(let M of y.paragraphIds){let B=E(a,M);if(B)return B}let P=[],O=(l?[l.id]:[...o]).sort((M,B)=>y.indexOf(M)-y.indexOf(B)),T=O[0],L=(y.rawText(T)??"").length;for(let M of O){let B=(y.rawText(M)??"").length;B>0&&P.push({op:"deleteText",paragraphId:M,start:0,end:B});}for(let M of R)M.id!==l?.id&&P.push({op:"deleteBlock",blockId:M.id});let $=t.replacementLanding?.(T,0,L)??0;c.length>0&&P.push({op:"insertText",paragraphId:T,offset:$,text:c});for(let M of R)if(M.id!==l?.id)for(let B of M.paragraphIds){let kt=a.slotById.get(B);kt&&a.order.splice(w(a,kt),1);}let G={story:y.story,paragraphId:T,index:y.indexOf(T),offset:$},U=()=>({kind:"span",span:C({start:G,end:{...G,offset:$+c.length}})});return {ok:true,kind:"command",ops:P,story:y.story,answer:U}},Mt=(a,c)=>{if(!Array.isArray(c)||c.length<1||c.length>1e4||c.some(I=>typeof I!="string"||fe.test(I)||!chunk77DD4EBC_cjs.O(I)))return f("unsupported-content","replaceStoryBlocks needs 1-10000 valid XML text strings without paragraph marks","paragraphs");let y=g(a);if(y)return y;for(let I of a.reads.paragraphIds){let R=E(a,I);if(R)return R}a.order.splice(0,a.order.length);for(let I=0;I<c.length;I+=1)K(a,I);return {ok:true,kind:"command",ops:[{op:"replaceStoryBlocks",storyRootId:a.reads.root.id,paragraphs:c}],story:a.reads.story,answer:()=>tt}},Et=(a,c,y,I)=>{let R=a.reads;if(typeof I!="string")return f("unsupported-content","insertParagraph needs text","text");if(fe.test(I))return f("unsupported-content","a paragraph mark inside a paragraph\u2019s text is not written by this host","paragraph-mark-in-text");let o=g(a);if(o)return o;let l=E(a,c.paragraphId);if(l)return l;let h=a.slotById.get(c.paragraphId);if(!h)return f("invalid-handle","that paragraph is not in the body");let P=(R.rawText(c.paragraphId)??"").length,O=[];y==="after"?(I.length>0&&O.push({op:"insertText",paragraphId:c.paragraphId,offset:P,text:I}),O.push({op:"splitParagraph",paragraphId:c.paragraphId,offset:P})):(I.length>0&&O.push({op:"insertText",paragraphId:c.paragraphId,offset:0,text:I}),O.push({op:"splitParagraph",paragraphId:c.paragraphId,offset:I.length}));let T=K(a,w(a,h)+1);y==="before"&&a.retargets.push({from:c.paragraphId,slot:T});let L=()=>{let $=y==="after"?T.id:c.paragraphId;return $===null?tt:{kind:"handle",handle:e.paragraph($,R.story)}};return {ok:true,kind:"command",ops:O,story:R.story,answer:L}},ee=(a,c,y,I,R)=>{let o=a.reads;if(!Array.isArray(y)||y.length===0)return f("unsupported-content","split needs at least one delimiter","delimiters");if(y.length>ri)return f("unsupported-content","too many delimiters",String(y.length));for(let B of y){if(typeof B!="string"||B.length===0)return f("unsupported-content","a delimiter must be a non-empty string","delimiters");if(B.length>ai)return f("unsupported-content","that delimiter is too long","delimiters")}let l=g(a);if(l)return l;let h=E(a,c.paragraphId);if(h)return h;let P=a.slotById.get(c.paragraphId);if(!P)return f("invalid-handle","that paragraph is not in the body");let O=o.rawText(c.paragraphId)??"",T=Do(O,y),L=[],$=[],G=[];if(T.length===0)G.push(O);else if(I){for(let lt of [...T].reverse())L.push({op:"deleteText",paragraphId:c.paragraphId,start:lt.start,end:lt.start+lt.length});let B=0,kt=0;for(let lt of T){let $e=lt.start-B;$.push($e),G.push(O.slice(kt,lt.start)),kt=lt.start+lt.length,B+=lt.length;}G.push(O.slice(kt));}else {let B=0;for(let kt of T){let lt=kt.start+kt.length;$.push(lt),G.push(O.slice(B,lt)),B=lt;}G.push(O.slice(B));}$.length>0&&L.push({op:"splitParagraphMany",paragraphId:c.paragraphId,offsets:$});let U=[P];for(let B=0;B<$.length;B+=1)U.push(K(a,w(a,P)+1+B));let M=B=>{let kt=B.story(o.story),lt=[];return U.forEach(($e,Qr)=>{let ze=$e.id;if(ze===null)return;let Ke=kt?.rawText(ze)??G[Qr]??"",[Zr,qr]=R?Vo(Ke,0,Ke.length):[0,Ke.length],In=e.paragraph(ze,o.story);lt.push({start:{paragraph:In,offset:Zr},end:{paragraph:In,offset:qr}});}),{kind:"spans",spans:lt}};return {ok:true,kind:"command",ops:L,story:o.story,answer:M}},V=(a,c)=>{let y=g(a);if(y)return y;let I=E(a,c.paragraphId);if(I)return I;let R=a.slotById.get(c.paragraphId);return R&&a.order.splice(w(a,R),1),{ok:true,kind:"command",ops:[{op:"deleteBlock",blockId:c.paragraphId}],story:a.reads.story,answer:()=>tt}},Pt=(a,c,y)=>{let I=a.reads,R=I.part,o=g(a);if(o)return o;let l=fr(y??{});if(!l.ok)return f("unsupported-content","that is not formatting this host writes",l.detail);let h=[];for(let P of Ut(c,I)){if(P.end<=P.start&&!P.whole)continue;let O=F(a,P.paragraphId,"runs");if(O)return O;for(let T of chunkMDP5SNK4_cjs.za(R,P.paragraphId,P.start,P.end,l.value.filter(L=>L.localName!=="vertAlign"),t.displayMode))h.push({op:"setRunProperties",paragraphId:P.paragraphId,start:T.start,end:T.end,properties:cn(T.properties,y),...T.targetRunIds?{targetRunIds:T.targetRunIds}:{}});P.whole&&h.push({op:"setParagraphMarkProperties",paragraphId:P.paragraphId,properties:cn(chunkMDP5SNK4_cjs.ya(R,P.paragraphId,l.value.filter(T=>T.localName!=="vertAlign")),y)});}return h.length===0?f("invalid-offset","that range covers no characters to format","collapsed-range"):{ok:true,kind:"command",ops:h,story:I.story,answer:()=>tt}},ht=(a,c,y)=>{let I=a.reads,R=I.part,o=g(a);if(o)return o;let l=we(y,I.styles());if(!l.ok)return f("unsupported-content","that is not a style this document has",l.detail);let h={localName:"pStyle",attributes:{val:l.styleId}},P=[];for(let O of At(c,I)){let T=F(a,O,"paragraph");if(T)return T;P.push({op:"setParagraphProperties",paragraphId:O,properties:chunkMDP5SNK4_cjs.ta(chunkMDP5SNK4_cjs.ra(R,O),h)});}return P.length===0?f("invalid-offset","that story holds no paragraph to style","empty-story"):{ok:true,kind:"command",ops:P,story:I.story,answer:()=>tt}},q=(a,c,y)=>{let I=a.reads,R=I.part,o=g(a);if(o)return o;let l=gr(R,c.paragraphId,y??{},I.styles());if(!l.ok)return f("unsupported-content","that is not paragraph formatting this host writes",l.detail);let h=F(a,c.paragraphId,"paragraph");return h||{ok:true,kind:"command",ops:[{op:"setParagraphProperties",paragraphId:c.paragraphId,properties:l.value}],story:I.story,answer:()=>tt}},gt=(a,c)=>{let y=r.body;if(!y)return f("document-unavailable","this host holds no document right now");let I=r.sections();if(!I[a])return f("invalid-handle","that section is not in this document");let o=Po(c);if(!o.ok)return f("unsupported-content",o.reason,o.detail);let l=Bo(y,I,a);if(l===null)return f("unsupported-content","that section holds no paragraph to address it by","no-anchor");let h=d(y),P=g(h);return P||{ok:true,kind:"command",ops:[{op:"setSectionProperties",...o.value,anchorParagraphId:l}],story:Ft,answer:()=>tt}},Q=(a,c)=>({ok:true,kind:"command",ops:[{op:"deleteNote",noteKind:a,noteId:c}],story:Ft,lifecycle:true,answer:()=>tt}),Ot=a=>{let c=e.resolve(a,"list");if(!c||c.kind!=="list")return f("invalid-handle","that handle does not name a list","list");let y=r.story(c.story);if(!y)return f("invalid-handle","that story is not in this document");let I=zt(y).find(R=>R.numId===c.numId);return I?{ok:true,plan:d(y),list:I}:f("invalid-handle","this story numbers nothing with that list",c.numId)},Ue=a=>{if(typeof a!="object"||a===null)return f("invalid-handle","that is not a scope a control lives in","scope");let c=a;if("body"in a){let y=rt(c.body,"body",e,r);return y.ok?{reads:y.value,node:y.value.root}:f(y.code,"that handle does not name a body",y.detail)}if("contentControl"in a){let y=Rt(c.contentControl);return "control"in y?{reads:y.reads,node:y.node}:y}return f("invalid-handle","that is not a scope a control lives in","scope")},Rt=a=>{let c=e.resolve(a,"contentControl");if(!c||c.kind!=="contentControl")return f("invalid-handle","that handle does not name a content control","contentControl");let y=r.story(c.story);if(!y)return f("invalid-handle","that story is not in this document");let I=Er(y,c.nodeId),R=Lr(y,c.nodeId);return !I||!R?f("invalid-handle","this document no longer holds that content control"):{reads:y,control:I,node:R}},Gr=(a,c,y)=>{if(!Number.isInteger(y)||y<0||y>qt)return f("invalid-offset",`a list level is 0 to ${String(qt)}`,String(y));let I=pe(a.reads,c);if(!I)return f("unsupported-content","that paragraph is not in a list",c);if(!r.package||!ce(r.package,I.numId,y))return f("unsupported-content","list level is not defined; configure that level first",c);let R=g(a);if(R)return R;let o=F(a,c,"paragraph");return o||{ok:true,kind:"command",ops:[{op:"setListLevel",paragraphId:c,level:y}],story:a.reads.story,answer:()=>tt}},Xr=(a,c,y,I)=>{if(y!=="start"&&y!=="end")return f("unknown-operation","a list takes an item at its start or its end",String(y));let R=a.reads,o=y==="start"?c.paragraphIds[0]:c.paragraphIds[c.paragraphIds.length-1];if(o===void 0)return f("invalid-handle","that list holds no paragraph");let l={story:R.story,paragraphId:o,index:R.indexOf(o)};return Et(a,l,y==="start"?"before":"after",I)},xn=(a,c)=>{if(c.start.paragraphId!==c.end.paragraphId)return null;for(let y of kr(a,c.start.paragraphId))if(y.start<=c.start.offset&&y.end>=c.end.offset)return y;return null},Yr=(a,c,y)=>{if(typeof y!="string")return f("unsupported-content","a hyperlink target is a string","target");let I=a.reads,R=xn(I,c),o=c.start.paragraphId===c.end.paragraphId&&c.start.offset===c.end.offset,l=R&&(c.start.offset!==R.start||c.end.offset!==R.end),h=l?{range:{start:c.start.offset,end:c.end.offset}}:{};if(l){let U=I.node(R.paragraphId),M=U?.kind==="paragraph"?U.children.find(B=>B.id===R.id):void 0;if(o||!M||!chunk77DD4EBC_cjs._g(M)||U?.kind!=="paragraph"||!U.children.some(B=>B.id===R.id))return f("unsupported-capability","partial hyperlink edits require ordinary text in a paragraph")}if(y.length===0){if(!R)return f("unsupported-content","that text is not a link","no-link");let U=g(a);if(U)return U;let M=j(a,R.paragraphId);return M||{ok:true,kind:"command",ops:[{op:"removeHyperlink",linkId:R.id,...h}],story:I.story,answer:()=>tt}}let P={},O=null;if(y.startsWith("#")){let U=y.slice(1);if(U.length===0||!fn(I,U))return f("unsupported-content","this document declares no such bookmark",y);P={anchor:U};}else {if(chunk77DD4EBC_cjs.pf(y)===null)return f("unsupported-content","this engine will not author that target","target");O=y;}let T=g(a);if(T)return T;let L=U=>O===null?{ok:true,kind:"command",ops:[U(P)],story:I.story,answer:()=>tt}:{ok:true,kind:"command",ops:[],relate:{url:O,ops:M=>[U({relationshipId:M})]},story:I.story,answer:()=>tt};if(R){let U=j(a,R.paragraphId);return U||L(M=>({op:"setHyperlinkTarget",linkId:R.id,...h,...M}))}if(o)return f("unsupported-content","a link with no text has nothing to click","collapsed");if(c.start.paragraphId!==c.end.paragraphId)return f("unsupported-content","a link lives inside one paragraph","crosses-paragraph-mark");let $=j(a,c.start.paragraphId);if($)return $;let G=I.styles().idOf("hyperlink");return L(U=>({op:"insertHyperlink",paragraphId:c.start.paragraphId,start:c.start.offset,end:c.end.offset,...U,...G===null?{}:{styleId:G}}))},An=(a,c,y)=>{let I=a.reads;if(!n.selection||!t.select)return f("unsupported-capability","this host has no reader to move","selection");if(y!=="select"&&y!=="start"&&y!=="end")return f("unknown-operation","that is not a selection mode",String(y));let R=At(c,I);for(let o of R)if(a.touched.has(o))return f("conflicting-operations","this batch edits a paragraph the selection covers",o);for(let o of R)a.selected.add(o);return p.push({range:c,mode:y}),{ok:true,kind:"command",ops:[],story:I.story,answer:()=>tt}},vn=a=>{let c=e.resolve(a,"bookmark");if(!c||c.kind!=="bookmark")return f("invalid-handle","that handle does not name a bookmark","bookmark");let y=r.story(c.story);if(!y)return f("invalid-handle","that story is not in this document");let I=fn(y,c.name);if(!I)return f("invalid-handle","this document no longer declares that bookmark",c.name);let R=o=>({story:y.story,paragraphId:o.paragraphId,index:y.indexOf(o.paragraphId),offset:o.offset});return {reads:y,range:{start:R(I.start),end:R(I.end)}}},Jr=(a,c)=>{let y=Xo(a,t,o=>bn({...t,reads:o}));if(y)return c&&y.ok&&y.kind==="command"?f("unsupported-content","header/footer creation cannot be tracked"):y;let I=Ko(a,{handles:e,reads:r,admitWrite:(o,l,h)=>{let P=d(o),O=g(P);if(O)return O;for(let T of h){let L=E(P,T);if(L)return L}return P.externalCreatedCount+=l,null}});if(I)return I;let R=c!==void 0;switch(R&&a.op==="insertText"?a={op:"proposeInsertion",span:{start:a.at,end:a.at},text:a.text,where:"Before",author:c}:R&&a.op==="replaceSpan"&&(a={op:"proposeReplacement",span:a.span,text:a.text,author:c}),a.op){case "getFields":case "getField":case "setFieldCode":case "deleteField":case "updateFieldResult":case "insertField":return Uo(a,e,r,(o,l,h)=>{let P=d(o);return g(P)??(h?null:E(P,l))},t.fieldPageContext);case "getInlinePictures":case "getInlinePicture":case "setInlinePicture":case "deleteInlinePicture":case "insertInlinePicture":return tr(a,e,r,(o,l)=>{let h=d(o);return g(h)??E(h,l)});case "insertBreak":return er(a,e,r,(o,l,h)=>{let P=d(o),O=g(P)??E(P,l);return O||(P.externalCreatedCount+=h),O});case "startNewList":case "attachToList":case "detachFromList":case "setListLevelFormat":return ar(a,e,r,(o,l,h)=>{let P=d(o);return g(P)??F(P,l,h?`list:${h.numId}:${h.level}`:"paragraph")});case "getDocument":return N({kind:"handle",handle:e.document()});case "getBody":return e.resolve(a.document,"document")?r.body?N({kind:"handle",handle:e.body(Ft)}):f("document-unavailable","this host holds no document right now"):f("invalid-handle","that handle does not name a document","document");case "getParagraphs":{let o=rt(a.body,"body",e,r);return o.ok?N({kind:"handles",handles:o.value.paragraphIds.map(l=>e.paragraph(l,o.value.story))}):f(o.code,"that handle does not name a body",o.detail)}case "getRange":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","empty story");if(!["Whole","Content","Start","End"].includes(a.location))return f("unsupported-content","unsupported range location");let l=o.value,h=a.location==="Start"?{start:l.start,end:l.start}:a.location==="End"?{start:l.end,end:l.end}:l;return N({kind:"span",span:Nt(h,e)})}case "getSpanParagraphs":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.span,e,r);return l.ok?N({kind:"handles",handles:At(o.value,l.value).map(h=>e.paragraph(h,l.value.story))}):f(l.code,"that span is not a place",l.detail)}case "getText":{if(!Z(a.projection))return f("unsupported-content","unknown text projection","projection");if(e.resolve(a.target,"body")){let P=rt(a.target,"body",e,r);return P.ok?N({kind:"text",text:P.value.text(a.projection??"allMarkup")}):f(P.code,"that handle does not name a body",P.detail)}let l=pt(a.target,e,r);if(!l.ok)return f(l.code,"that handle does not name a body or a paragraph",l.detail);let h=r.story(l.value.story);return N({kind:"text",text:h?.paragraphText(l.value.paragraphId,a.projection??"allMarkup")??""})}case "getSpanText":{if(!Z(a.projection))return f("unsupported-content","unknown text projection","projection");let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.span,e,r);return l.ok?N({kind:"text",text:Eo(o.value,l.value,on,a.projection??"allMarkup")}):f(l.code,"that span is not a place",l.detail)}case "getParagraphId":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let h=r.story(o.value.story)?.paragraph(o.value.paragraphId);return N({kind:"text",text:h?.paraId??""})}case "search":{let o=z(a.scope,e,r);if(!o.ok)return f(o.code,"that is not a scope to search",o.detail);let l=ot(a.scope,e,r);return l.ok?et(l.value,o.value,a.text,a.options):f(l.code,"that is not a scope to search",l.detail)}case "proposeInsertion":case "proposeDeletion":case "proposeReplacement":return Pr(a,R,e,r,(o,l)=>{let h=d(o);return g(h)??E(h,l)});case "insertText":{let o=Zt(a.at,e,r);if(!o.ok)return f(o.code,"that is not a place to insert at",o.detail);let l=r.story(o.value.story);return l?nt(d(l),o.value,a.text,"at"in a.at&&a.at.at==="start"):f("invalid-handle","that story is not in this document")}case "replaceSpan":{if("body"in a.span){let h=rt(a.span.body,"body",e,r);return h.ok?ct(d(h.value),a.text):f(h.code,"that handle does not name a body",h.detail)}let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds no paragraph to write into","empty-story");let l=D(o.value);return l?at(d(l),o.value,a.text):f("invalid-handle","that story is not in this document")}case "replaceStoryBlocks":{let o=rt(a.body,"body",e,r);return o.ok?Mt(d(o.value),a.paragraphs):f(o.code,"that handle does not name a body",o.detail)}case "insertParagraph":{let o=Le(a.anchor,e,r);if(!o.ok)return f(o.code,"that is not a paragraph to insert beside",o.detail);if(a.where!=="before"&&a.where!=="after")return f("unknown-operation","that is not a place to insert",String(a.where));let l=r.story(o.value.story);return l?Et(d(l),o.value,a.where,a.text):f("invalid-handle","that story is not in this document")}case "splitParagraph":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let l=r.story(o.value.story);return l?ee(d(l),o.value,a.delimiters,a.trimDelimiters===true,a.trimSpacing===true):f("invalid-handle","that story is not in this document")}case "getFont":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.span,e,r);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let h=Ut(o.value,l.value);return N({kind:"font",font:pr(l.value.part,h,t.displayMode)})}case "setFont":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds no paragraph to format","empty-story");let l=D(o.value);return l?Pt(d(l),o.value,a.font):f("invalid-handle","that story is not in this document")}case "getStyle":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.span,e,r);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let h=l.value.part,P=l.value.styles(),O=At(o.value,l.value).map(L=>Ce(h,L,P)),T=O.length>0&&O.every(L=>L!==null&&L===O[0])?O[0]:null;return N({kind:"style",name:T})}case "setStyle":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds no paragraph to style","empty-story");let l=D(o.value);return l?ht(d(l),o.value,a.name):f("invalid-handle","that story is not in this document")}case "getParagraphFormat":{let o=Le(a.paragraph,e,r);if(!o.ok)return f(o.code,"that is not a paragraph",o.detail);let l=r.story(o.value.story);if(!l)return f("document-unavailable","this host holds no document right now");let h=mr(l.part,o.value.paragraphId,l.styles());return h?N({kind:"paragraphFormat",format:h}):f("invalid-handle","that handle does not name a paragraph")}case "setParagraphFormat":{let o=Le(a.paragraph,e,r);if(!o.ok)return f(o.code,"that is not a paragraph",o.detail);let l=r.story(o.value.story);return l?q(d(l),o.value,a.format):f("invalid-handle","that story is not in this document")}case "deleteParagraph":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let l=r.story(o.value.story);return l?V(d(l),o.value):f("invalid-handle","that story is not in this document")}case "getSections":return e.resolve(a.document,"document")?N({kind:"handles",handles:r.sections().map(o=>e.section(o.index))}):f("invalid-handle","that handle does not name a document","document");case "getPageSetup":{let o=e.resolve(a.section,"section");if(!o||o.kind!=="section")return f("invalid-handle","that handle does not name a section","section");let l=r.sections()[o.index];return l?N({kind:"pageSetup",setup:l.pageSetup}):f("invalid-handle","that section is not in this document")}case "setPageSetup":{let o=e.resolve(a.section,"section");return !o||o.kind!=="section"?f("invalid-handle","that handle does not name a section","section"):gt(o.index,a.setup)}case "getFurniture":{let o=e.resolve(a.section,"section");if(!o||o.kind!=="section")return f("invalid-handle","that handle does not name a section","section");if(a.kind!=="header"&&a.kind!=="footer")return f("unknown-operation","that is not furniture",String(a.kind));let l={kind:a.kind,sectionIndex:o.index,variant:a.variant};return Io(l)?r.sections()[o.index]?N({kind:"handle",handle:e.body(l)}):f("invalid-handle","that section no longer exists"):f("unknown-operation","that is not a furniture variant",String(a.variant))}case "getNotes":{if(!e.resolve(a.document,"document"))return f("invalid-handle","that handle does not name a document","document");if(a.noteKind!=="footnote"&&a.noteKind!=="endnote")return f("unknown-operation","that is not a kind of note",String(a.noteKind));let o=a.noteKind,l=r.noteIds(o);return l.ok?N({kind:"handles",handles:l.ids.map(h=>e.note(o,h))}):f("ambiguous-document",`${o} identities are not completely and unambiguously enumerable`,l.reason==="duplicates"?l.duplicateIds.join(","):l.reason)}case "getNoteBody":case "getNoteText":{let o=e.resolve(a.note,"note");if(!o||o.kind!=="note")return f("invalid-handle","that handle does not name a note","note");let l=o,h=r.story(l);return h?a.op==="getNoteText"?N({kind:"text",text:h.text(a.projection)}):N({kind:"handle",handle:e.body(l)}):f("invalid-handle","that note is not in this document",J(l))}case "getNoteKind":{let o=e.resolve(a.note,"note");return !o||o.kind!=="note"?f("invalid-handle","that handle does not name a note","note"):N({kind:"text",text:o.noteKind})}case "deleteNote":{let o=e.resolve(a.note,"note");if(!o||o.kind!=="note")return f("invalid-handle","that handle does not name a note","note");let l=r.noteIds(o.noteKind);return l.ok?l.ids.includes(o.noteId)?Q(o.noteKind,o.noteId):f("invalid-handle","that note is not in this document"):f("ambiguous-document",`${o.noteKind} identities are not completely and unambiguously enumerable`,l.reason==="duplicates"?l.duplicateIds.join(","):l.reason)}case "getLists":{let o=rt(a.body,"body",e,r);return o.ok?N({kind:"handles",handles:zt(o.value).map(l=>e.list(l.numId,o.value.story))}):f(o.code,"that handle does not name a body",o.detail)}case "getListId":{let o=Ot(a.list);return "list"in o?N({kind:"number",value:Number(o.list.numId)}):o}case "getListById":{let o=rt(a.body,"body",e,r);if(!o.ok)return f(o.code,"that handle does not name a body",o.detail);if(!Number.isInteger(a.id)||a.id<=0)return f("unsupported-content","a list is numbered from one",String(a.id));let l=String(a.id),h=zt(o.value).find(P=>P.numId===l);return h?N({kind:"handle",handle:e.list(h.numId,o.value.story)}):f("invalid-handle","no list in that story carries that number",l)}case "getListParagraphs":{let o=Ot(a.list);if(!("list"in o))return o;let l=a.level;if(l!==void 0&&(!Number.isInteger(l)||l<0||l>qt))return f("invalid-offset",`a list level is 0 to ${String(qt)}`,String(l));let h=o.plan.reads,P=l===void 0?o.list.paragraphIds:o.list.paragraphIds.filter(O=>pe(h,O)?.level===l);return N({kind:"handles",handles:P.map(O=>e.paragraph(O,h.story))})}case "getParagraphList":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let l=r.story(o.value.story);if(!l)return f("invalid-handle","that story is not in this document");let h=pe(l,o.value.paragraphId);return h?N({kind:"handle",handle:e.list(h.numId,l.story)}):f("unsupported-content","that paragraph is not in a list",o.value.paragraphId)}case "getListLevel":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let l=r.story(o.value.story);if(!l)return f("invalid-handle","that story is not in this document");let h=pe(l,o.value.paragraphId);return h?N({kind:"number",value:h.level}):f("unsupported-content","that paragraph is not in a list",o.value.paragraphId)}case "setListLevel":{let o=pt(a.paragraph,e,r);if(!o.ok)return f(o.code,"that handle does not name a paragraph",o.detail);let l=r.story(o.value.story);return l?Gr(d(l),o.value.paragraphId,a.level):f("invalid-handle","that story is not in this document")}case "insertListParagraph":{let o=Ot(a.list);return "list"in o?Xr(o.plan,o.list,a.where,a.text):o}case "getHyperlink":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.span,e,r);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let h=r.package;if(!h||!o.value)return N({kind:"text",text:""});let P=xn(l.value,o.value);if(!P)return N({kind:"text",text:""});let O=chunk77DD4EBC_cjs.Ga(l.value.part,P.id),T=O?br(h,l.value.part.name,O):null;return N({kind:"text",text:T??""})}case "setHyperlink":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds no text to link","empty-story");let l=D(o.value);return l?Yr(d(l),o.value,a.target):f("invalid-handle","that story is not in this document")}case "getBookmarks":{let o=z(a.scope,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);let l=ot(a.scope,e,r);if(!l.ok)return f(l.code,"that span is not a place",l.detail);let h=l.value,P=o.value,O=P===null?null:new Set(At(P,h)),T=mn(h).filter(L=>{if(!O||!O.has(L.start.paragraphId)&&!O.has(L.end.paragraphId)||P===null)return false;let $=L.start.paragraphId===P.end.paragraphId&&L.start.offset>P.end.offset,G=L.end.paragraphId===P.start.paragraphId&&L.end.offset<P.start.offset;return !$&&!G});return N({kind:"handles",handles:T.map(L=>e.bookmark(L.name,h.story))})}case "getBookmarkName":{let o=e.resolve(a.bookmark,"bookmark");return !o||o.kind!=="bookmark"?f("invalid-handle","that handle does not name a bookmark","bookmark"):N({kind:"text",text:o.name})}case "getBookmarkRange":{let o=vn(a.bookmark);return "reads"in o?N({kind:"span",span:C(o.range)}):o}case "getComments":{let o=z(a.scope,e,r);if(!o.ok)return f(o.code,"that scope is not a place",o.detail);let l=ot(a.scope,e,r);if(!l.ok)return f(l.code,"that scope names no story",l.detail);let h=l.value,P=k(h);if(!P)return f("document-unavailable","this host holds no document");let O=o.value,T=P.roots.filter(L=>{if(!O)return true;let $=L.range;if(!$)return false;let G=h.indexOf($.start.paragraphId),U=h.indexOf($.end.paragraphId),M=h.indexOf(O.start.paragraphId),B=h.indexOf(O.end.paragraphId);return U<M||G>B?false:U===M&&G===M&&B===M?$.end.offset>O.start.offset&&$.start.offset<O.end.offset:true});return N({kind:"handles",handles:T.map(L=>e.comment(L.id,h.story))})}case "getCommentReplies":{let o=b(a.comment);return o.ok?N({kind:"handles",handles:o.item.replyIds.map(l=>e.comment(l,o.reads.story))}):o.planned}case "getCommentId":{let o=b(a.comment);return o.ok?N({kind:"text",text:o.item.id}):o.planned}case "getCommentAuthor":{let o=b(a.comment);return o.ok?N({kind:"text",text:o.item.comment.author}):o.planned}case "getCommentDate":{let o=b(a.comment);return o.ok?N({kind:"text",text:o.item.comment.date??""}):o.planned}case "getCommentText":{let o=b(a.comment);if(!o.ok)return o.planned;let l=k(o.reads);return N({kind:"text",text:l?.textOf(o.item.id)??""})}case "getCommentRange":{let o=b(a.comment);if(!o.ok)return o.planned;let l=o.item.range;if(!l||o.item.orphaned)return f("invalid-handle","that comment has no range in this document");let h=S(o.reads,l);return h?N({kind:"span",span:h}):f("invalid-handle","that comment\u2019s range is no longer in the story")}case "getCommentResolved":{let o=b(a.comment);return o.ok?N({kind:"flag",value:o.item.resolved}):o.planned}case "insertComment":return wr(a,e,r,x);case "setCommentResolved":{let o=b(a.comment);if(!o.ok)return o.planned;if(typeof a.resolved!="boolean")return f("unsupported-content","resolved is a yes or a no",String(a.resolved));let l=g(d(o.reads));return l||{ok:true,kind:"commentWrite",write:{kind:"resolve",commentId:o.item.id,resolved:a.resolved},story:o.reads.story,answer:()=>tt}}case "replyToComment":{let o=b(a.comment);if(!o.ok)return o.planned;let l=hn({author:a.author,text:a.text,date:a.date,kind:"reply"});if(l)return l;let h=o.item.range;if(!h||o.item.orphaned)return f("invalid-handle","that comment has no range to reply over");let P=g(d(o.reads));if(P)return P;let O=o.reads.story,T=kn(a.date);return {ok:true,kind:"commentWrite",write:{kind:"reply",parentCommentId:o.item.id,anchor:{paragraphId:h.start.paragraphId,start:h.start.offset,end:h.end.offset,...h.end.paragraphId===h.start.paragraphId?{}:{endParagraphId:h.end.paragraphId}},text:a.text,author:a.author,...T===void 0?{}:{date:T}},story:o.reads.story,answer:(L,$)=>$===void 0?tt:{kind:"handle",handle:e.comment($,O)}}}case "deleteComment":{let o=b(a.comment);return o.ok?Tr(o.item,o.reads,l=>g(d(l))):o.planned}case "getRevisions":{let o=rt(a.body,"body",e,r);if(!o.ok)return f(o.code,"that handle does not name a body",o.detail);let l=o.value;return N({kind:"handles",handles:gn(l).map(h=>e.revision(h.id,l.story))})}case "getRevisionType":{let o=v(a.revision);return o.ok?N({kind:"text",text:o.item.type}):o.planned}case "getRevisionAuthor":{let o=v(a.revision);return o.ok?N({kind:"text",text:o.item.author}):o.planned}case "getRevisionDate":{let o=v(a.revision);return o.ok?N({kind:"text",text:o.item.date}):o.planned}case "getRevisionRange":{let o=v(a.revision);if(!o.ok)return o.planned;let[l]=o.item.item.ranges;if(!l)return f("invalid-handle","that change covers no characters");let h=S(o.reads,l);return h?N({kind:"span",span:h}):f("invalid-handle","that change\u2019s range is no longer in the story")}case "acceptRevision":case "rejectRevision":{let o=v(a.revision);if(!o.ok)return o.planned;let l=d(o.reads),h=g(l);if(h)return h;let P=a.op==="acceptRevision";return {ok:true,kind:"command",story:o.reads.story,ops:o.item.item.addresses.map(O=>P?{op:"acceptRevision",revision:O}:{op:"rejectRevision",revision:O}),answer:()=>tt}}case "acceptAllRevisions":case "rejectAllRevisions":{let o=Or(a,e,r);if(!o.ok)return f(o.code,o.message,o.detail);let l=d(o.reads),h=g(l);if(h)return h;let P=Rr(a,o.reads);return {ok:true,kind:"command",story:o.reads.story,ops:P,answer:()=>tt}}case "selectSpan":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds no paragraph to select","empty-story");let l=D(o.value);return l?An(d(l),o.value,a.mode):f("invalid-handle","that story is not in this document")}case "selectBookmark":{let o=vn(a.bookmark);return "reads"in o?An(d(o.reads),o.range,a.mode):o}case "getContentControls":{let o=Ue(a.scope);return "reads"in o?N({kind:"handles",handles:Nr(o.reads,o.node).map(l=>e.contentControl(l.nodeId,o.reads.story))}):o}case "getContentControlById":{let o=Ue(a.scope);if(!("reads"in o))return o;if(!Number.isInteger(a.id))return f("unsupported-content","a control id is a whole number",String(a.id));let l=me(o.node).find(h=>chunk77DD4EBC_cjs.Ic(h).id===a.id);return l?N({kind:"handle",handle:e.contentControl(l.id,o.reads.story)}):f("invalid-handle","no control in that scope carries that id",String(a.id))}case "getContentControlsByTag":case "getContentControlsByTitle":{let o=Ue(a.scope);if(!("reads"in o))return o;let l=a.op==="getContentControlsByTag"?a.tag:a.title;if(typeof l!="string"||l.length===0)return f("unsupported-content","a tag or title to match is required",a.op);let h=me(o.node).filter(P=>{let O=chunk77DD4EBC_cjs.Ic(P);return a.op==="getContentControlsByTag"?O.tag===l:O.alias===l});return N({kind:"handles",handles:h.map(P=>e.contentControl(P.id,o.reads.story))})}case "getContentControlTag":case "getContentControlTitle":case "getContentControlFileId":case "getContentControlSubtype":case "getContentControlLock":{let o=Rt(a.contentControl);if(!("control"in o))return o;let l=o.control.properties;if(a.op==="getContentControlLock")return N({kind:"text",text:o.control.lock});if(a.op==="getContentControlSubtype")return N({kind:"text",text:l.type});if(a.op==="getContentControlFileId")return N({kind:"text",text:l.id===void 0?"":String(l.id)});let h=a.op==="getContentControlTag"?l.tag:l.alias;return N({kind:"text",text:h??""})}case "getContentControlIsBound":case "getContentControlPlaceholderShown":case "getContentControlTemporary":{let o=Rt(a.contentControl);if(!("control"in o))return o;let l=a.op==="getContentControlIsBound"?o.control.properties.dataBinding!==void 0:a.op==="getContentControlPlaceholderShown"?o.control.properties.showingPlaceholder:o.control.properties.temporary;return N({kind:"flag",value:l})}case "getContentControlText":{let o=Rt(a.contentControl);return "control"in o?N({kind:"text",text:Fr(o.reads,o.node,a.projection)}):o}case "getContentControlParagraphs":{let o=Rt(a.contentControl);return "control"in o?N({kind:"handles",handles:o.control.paragraphIds.map(l=>e.paragraph(l,o.reads.story))}):o}case "getContentControlRange":{let o=Rt(a.contentControl);if(!("control"in o))return o;let l=a.location??"whole";if(!Br.has(l))return f("unsupported-content","that is not a place in a control",l);let h=We(o.reads,o.node);if(!h)return f("unsupported-content","that control holds nothing addressable","empty");let P=l==="start"||l==="before"?h.start:h.end,O=l!=="whole"&&l!=="content",T=L=>({story:o.reads.story,paragraphId:L.paragraphId,index:o.reads.indexOf(L.paragraphId),offset:L.offset});return N({kind:"span",span:Nt(O?{start:T(P),end:T(P)}:{start:T(h.start),end:T(h.end)},e)})}case "setContentControlValue":{let o=Rt(a.contentControl);if(!("control"in o))return o;let l=Vr(a.value);if(!l.ok)return f(l.code,l.message,l.detail);let h=d(o.reads),P=g(h);return P||{ok:true,kind:"command",story:o.reads.story,ops:[{op:"setContentControlValue",controlId:o.control.nodeId,value:l.value}],answer:()=>tt}}case "setContentControlProperties":{let o=Rt(a.contentControl);if(!("control"in o))return o;if(a.tag===void 0&&a.title===void 0&&a.lock===void 0&&a.cannotEdit===void 0&&a.cannotDelete===void 0)return f("unsupported-content","nothing to write","no-properties");if(a.lock!==void 0&&!Dr.has(a.lock))return f("unsupported-content","that is not a lock this schema declares",a.lock);for(let O of [a.cannotEdit,a.cannotDelete])if(O!==void 0&&typeof O!="boolean")return f("unsupported-content","lock flags must be boolean");let l=d(o.reads),h=a.lock;if(a.cannotEdit!==void 0||a.cannotDelete!==void 0){let O=h??s.get(l)?.get(o.control.nodeId)??o.control.properties.lock,T=a.cannotEdit??(O==="contentLocked"||O==="sdtContentLocked"),L=a.cannotDelete??(O==="sdtLocked"||O==="sdtContentLocked");h=T?L?"sdtContentLocked":"contentLocked":L?"sdtLocked":"unlocked";}let P=g(l);if(P)return P;if(h!==void 0){let O=s.get(l)??new Map;O.set(o.control.nodeId,h),s.set(l,O);}return {ok:true,kind:"command",story:o.reads.story,ops:[{op:"setContentControlProperties",controlId:o.control.nodeId,...a.tag===void 0?{}:{tag:a.tag},...a.title===void 0?{}:{alias:a.title},...h===void 0?{}:{lock:h}}],answer:()=>tt}}case "insertContentControlText":{let o=Rt(a.contentControl);if(!("control"in o))return o;if(typeof a.text!="string")return f("unsupported-content","text is required","text");if(a.at!=="replace"&&a.at!=="start"&&a.at!=="end")return f("unsupported-content","that is not a place to insert at",String(a.at));let l=d(o.reads),h=g(l);if(h)return h;let P=We(o.reads,o.node);if(!P)return f("unsupported-content","that control holds nothing addressable","empty");let O=a.at==="end"?P.end:P.start,T=()=>({kind:"span",span:C({start:{story:o.reads.story,paragraphId:O.paragraphId,index:o.reads.indexOf(O.paragraphId),offset:O.offset},end:{story:o.reads.story,paragraphId:O.paragraphId,index:o.reads.indexOf(O.paragraphId),offset:O.offset+a.text.length}})});return a.at==="replace"?{ok:true,kind:"command",story:o.reads.story,ops:[{op:"setContentControlValue",controlId:o.control.nodeId,value:{kind:"text",text:a.text}}],answer:T}:{ok:true,kind:"command",story:o.reads.story,ops:a.text.length===0?[]:[{op:"insertText",paragraphId:O.paragraphId,offset:O.offset,text:a.text,inside:o.node.id}],answer:T}}case "deleteContentControl":{let o=Rt(a.contentControl);if(!("control"in o))return o;if(typeof a.keepContent!="boolean")return f("unsupported-content","keepContent is required","keepContent");let l=d(o.reads),h=g(l);return h||{ok:true,kind:"command",story:o.reads.story,ops:[{op:"removeContentControl",controlId:o.control.nodeId,keepContent:a.keepContent}],answer:()=>tt}}case "insertContentControl":{let o=z(a.span,e,r);if(!o.ok)return f(o.code,"that span is not a place",o.detail);if(!o.value)return f("invalid-offset","that story holds nothing to wrap","empty-story");let l=D(o.value);if(!l)return f("invalid-handle","that story is not in this document");let h=o.value;if(h.start.paragraphId!==h.end.paragraphId)return f("unsupported-content","wrapping several paragraphs in one control is not supported here","multi-paragraph");if(!_r.has(a.subtype))return f("unsupported-content","that control type cannot be inserted",a.subtype);let P=new Set(me(l.root).map($=>$.id)),O=d(l),T=g(O);if(T)return T;let L=E(O,h.start.paragraphId);return L||{ok:true,kind:"command",story:l.story,ops:[{op:"insertContentControl",paragraphId:h.start.paragraphId,start:h.start.offset,end:h.end.offset,type:a.subtype,...a.tag===void 0?{}:{tag:a.tag},...a.title===void 0?{}:{alias:a.title}}],answer:$=>{if(!a.returnHandle)return tt;let G=$.story(l.story),U=G&&me(G.root).find(M=>!P.has(M.id));if(!U)throw new Error("content control insertion did not create a control");return {kind:"handle",handle:e.contentControl(U.id,l.story)}}}}case "insertCustomNode":{let o=$r(a);if(o)return f("unsupported-content",o.message,o.detail);let l=Ur(a.payload);if(!l.ok)return f("unsupported-content","that payload cannot be written",l.field);let h=Kr(a,e,r);if("code"in h)return f(h.code,h.message,h.detail);let{start:P,end:O}=h.range,T=D(h.range);if(!T)return f("invalid-handle","that story is not in this document");let L=g(d(T));return L||{ok:true,kind:"customNodeWrite",story:T.story,write:zr(a,P,O,l.value),answer:()=>tt}}default:return f("unknown-operation","this host does not implement that operation",String(a.op))}};return {plan(a,c){if(m&&Wt(a))return f("conflicting-operations","header/footer creation must commit alone");let y=u.conflict(a);if(y)return f("conflicting-operations",y.message,y.detail);let I=Jr(a,c);if(I.ok&&I.kind==="command"&&I.solitary){if(u.hasCommands)return f("conflicting-operations","header/footer creation must commit alone");m=true;}return I.ok&&u.note(a),I},get hasCommands(){return u.hasCommands},get writeScope(){return A?.reads.scope??null},settle(a){let c=A;if(c){let y=a.story(c.reads.story),I=y&&chunk77DD4EBC_cjs.Ga(y.part,c.reads.root.id),R=y&&I&&I.id!==y.root.id?Ee(y,I):y;if(!R)return {ok:false,detail:`the story this batch wrote is gone: ${J(c.reads.story)}`};let o=new Set(c.reads.paragraphIds),l=R.paragraphIds.filter(P=>!o.has(P));if(l.length!==c.created.length+c.externalCreatedCount)return {ok:false,detail:`planned ${String(c.created.length+c.externalCreatedCount)} new paragraphs, the transaction made ${String(l.length)}`};c.order.filter(P=>P.id===null).forEach((P,O)=>{P.id=l[O]??null;});for(let P of c.retargets)P.slot.id&&e.retarget(P.from,P.slot.id);}for(let y of p){let I=a.story(y.range.start.story);!I||!_o(y.range,I)||t.select?.(y.range,y.mode);}return {ok:true}}}}var si=Object.freeze({status:"skipped"});function ut(t,e,n){return Object.freeze(n===void 0?{code:t,message:e}:{code:t,message:e,detail:n})}function li(t){if(t==="review-module-required"||t==="automation-structural-tracking-unsupported")return ut("unsupported-capability","this edit requires a supported review mode",t);let e=t==="unsupported-revision"||t.startsWith("unsupported-revision:");return ut(e?"unsupported-revision":"transaction-refused",e?"that story contains a tracked change this engine cannot resolve":"the document store refused the transaction",t)}function yt(t,e,n,r){return {ok:false,results:t.map((i,s)=>s===e?{status:"error",error:n}:si),revision:r,changed:false}}function Qd(t){let{port:e}=t,n=Object.freeze({...t.capabilities}),r=No(),i=new Set,s=false,d={mode:"Off"},p=0,u=null,m=null,A=n.events?e.subscribe(()=>{if(s)return;let b=Object.freeze({revision:e.revision()});if(p>0)u=b;else for(let v of [...i])v(b);}):()=>{},g=b=>{if(m&&m.pkg===b)return m.value;let v=de(b);return m={pkg:b,value:v},v},x=b=>{let v=Array.isArray(b?.operations)?b.operations:[],S=e.revision();if(s)return yt(v,0,ut("disposed","this host was disposed"),S);if(!n.document)return yt(v,0,ut("unsupported-capability","this host has no document","document"),S);let w=e.currentPackage();if(!w)return yt(v,0,ut("document-unavailable","this host holds no document right now"),S);if(b.expectedRevision!==void 0&&b.expectedRevision!==S)return yt(v,0,ut("stale-revision","the document moved since that revision",`expected ${String(b.expectedRevision)}, at ${S}`),S);let H=bn({handles:r,reads:g(w),capabilities:n,...e.revisionDisplayMode?{displayMode:e.revisionDisplayMode()}:{},...e.replacementLanding?{replacementLanding:e.replacementLanding.bind(e)}:{},...e.fieldPageContext?{fieldPageContext:e.fieldPageContext.bind(e)}:{},...e.select?{select:e.select.bind(e)}:{}}),E=[],j=[],F=null,K=[],C=[],D=null,Z,et=null,_=-1,nt=d;for(let V=0;V<v.length;V+=1){let Pt=v[V];if(e.suggesting?.()&&Pt.op!=="replaceSpan"&&!rn(Pt))return yt(v,V,ut("unsupported-capability","this operation has no supported tracked form in suggesting mode"),S);let ht=To(Pt,e.localChangeTracking===true,nt),q=ht?.step??H.plan(Pt,nt.author);if(ht&&(nt=ht.state),!q.ok)return yt(v,V,q.error,S);if(E.push(q),q.kind==="command")if(q.packageEdits&&K.push(...q.packageEdits),_<0&&(_=V),q.lifecycle)F=q.ops[0]??null;else if(q.relate){let gt=q.relate;j.push(Q=>{let Ot=Q(gt.url);return Ot===null?null:gt.ops(Ot)});}else {let{ops:gt}=q;j.push(()=>gt);}else q.kind==="commentWrite"?(_<0&&(_=V),C.push(q.write),D=H.writeScope??{kind:"body"}):q.kind==="customNodeWrite"&&(_<0&&(_=V),et={write:q.write,scope:H.writeScope??{kind:"body"}});}let at=false;if(C.length>0){let V=e.applyCommentWrites(C,D??{kind:"body"});if(!V.ok)return yt(v,_<0?0:_,ut("transaction-refused","the document store refused the comment write",V.reason),S);at=V.changed,Z=V.commentId;}if(et){let V=e.applyCustomNodeWrite(et.write,et.scope);if(!V.ok)return yt(v,_<0?0:_,ut("transaction-refused","the document store refused the custom-node write",V.reason),S);at=V.changed;}if(F){let V=e.applyLifecycle(F);if(!V.ok)return yt(v,_<0?0:_,ut("transaction-refused","the document store refused the transaction",V.reason),S);at=V.changed;}if(j.length>0){let V=e.apply(Pt=>{let ht=[];for(let q of j){let gt=q(Pt);if(gt===null)return null;ht.push(...gt);}return ht},H.writeScope??{kind:"body"},K);if(!V.ok)return yt(v,_<0?0:_,li(V.reason),S);at=V.changed;}let ct=e.currentPackage();if(!ct)return yt(v,0,ut("document-unavailable","this host holds no document right now"),S);let Mt=g(ct),Et=H.settle(Mt);return Et.ok?(d=nt,{ok:true,results:E.map(V=>({status:"ok",value:V.kind==="query"?V.value:V.kind==="customNodeWrite"?V.answer(Mt):V.answer(Mt,Z)})),revision:e.revision(),changed:at}):yt(v,_<0?0:_,ut("transaction-refused","the transaction did not produce the document the batch planned",Et.detail),e.revision())};return {capabilities:n,revision:()=>e.revision(),execute:b=>{p+=1;try{return x(b)}finally{if(p-=1,p===0&&u){let v=u;u=null;for(let S of [...i])S(v);}}},...e.prepare?{prepare:e.prepare.bind(e)}:{},save(){if(s)return {ok:false,error:ut("disposed","this host was disposed")};if(!n.save)return {ok:false,error:ut("unsupported-capability","this host cannot save","save")};let b=e.save();return b?{ok:true,bytes:b}:{ok:false,error:ut("document-unavailable","this host holds no document right now")}},subscribe(b){return s||!n.events?()=>{}:(i.add(b),()=>{i.delete(b);})},dispose(){s||(s=true,i.clear(),A(),e.dispose(),m=null);}}}
|
|
2
|
-
exports.a=ta;exports.b=mi;exports.c=fi;exports.d=Se;exports.e=de;exports.f=hi;exports.g=ea;exports.h=na;exports.i=nn;exports.j=Wt;exports.k=Qd;
|